Removed redundant explicit instantiations.
Change-Id: I3ef73ddb94edc9b72e553710d158dce7fa4e6820
Signed-off-by: Eugene Kurzberg <i.kurtsberg@samsung.com>
#define CONTACTS_INPUT_CONTACT_COMPOUND_FIELD_CONTROL_H
#include "Contacts/Input/ContactTextFieldControl.h"
+#include "Contacts/Model/ContactCompoundObject.h"
namespace Contacts
{
- namespace Model
- {
- class ContactCompoundObject;
- }
-
namespace Input
{
/**
#ifndef CONTACTS_INPUT_CONTACT_DATE_FIELD_CONTROL_H
#define CONTACTS_INPUT_CONTACT_DATE_FIELD_CONTROL_H
+#include "Contacts/Model/ContactDateField.h"
#include "Ui/Control.h"
namespace Contacts
{
- namespace Model
- {
- class ContactDateField;
- }
-
namespace Input
{
/**
#ifndef CONTACTS_INPUT_CONTACT_IMAGE_FIELD_CONTROL_H
#define CONTACTS_INPUT_CONTACT_IMAGE_FIELD_CONTROL_H
+#include "Contacts/Model/ContactTextField.h"
#include "App/AppControl.h"
#include "Ui/Thumbnail.h"
namespace Contacts
{
- namespace Model
- {
- class ContactTextField;
- }
-
namespace Input
{
/**
#ifndef CONTACTS_INPUT_CONTACT_TEXT_FIELD_CONTROL_H
#define CONTACTS_INPUT_CONTACT_TEXT_FIELD_CONTROL_H
+#include "Contacts/Model/ContactTextField.h"
#include "Ui/Editfield.h"
#include <string>
namespace Contacts
{
- namespace Model
- {
- class ContactTextField;
- }
-
namespace Input
{
/**
#ifndef CONTACTS_INPUT_CONTACT_TYPED_FIELD_CONTROL_H
#define CONTACTS_INPUT_CONTACT_TYPED_FIELD_CONTROL_H
+#include "Contacts/Model/ContactEnumField.h"
+#include "Contacts/Model/ContactTextField.h"
#include "Ui/Hoversel.h"
namespace Contacts
{
- namespace Model
- {
- class ContactEnumField;
- class ContactTextField;
- }
-
namespace Input
{
/**
UpdateCallback m_OnUpdated;
};
+ template <typename FieldType>
+ FieldType &ContactField::cast()
+ {
+ return static_cast<FieldType &>(*this);
+ }
+
+ template <typename FieldType>
+ const FieldType &ContactField::cast() const
+ {
+ return static_cast<const FieldType &>(*this);
+ }
+
typedef std::unique_ptr<ContactField> ContactFieldPtr;
typedef std::vector<ContactFieldPtr> ContactFields;
}
* @param[in] index Child field index
* @return Child field.
*/
+ template <typename FieldType>
+ FieldType *getField(unsigned index) const;
ContactField *getField(unsigned index) const;
/**
ContactFields m_Fields;
size_t m_FilledCount = 0;
};
+
+ template <typename FieldType>
+ FieldType *ContactFieldContainer::getField(unsigned index) const
+ {
+ return static_cast<FieldType *>(getField(index));
+ }
}
}
* @param[in] id Child field id
* @return Child field.
*/
+ template <typename FieldType>
+ FieldType *getFieldById(unsigned id) const;
ContactField *getFieldById(unsigned id) const;
/**
protected:
/**
- * @return Record ID.
- */
- int getRecordId(contacts_record_h record) const;
-
- /**
* @return Object type metadata.
*/
const ContactObjectMetadata &getObjectMetadata() const;
static contacts_record_h getChildRecord(contacts_record_h record,
const ContactFieldMetadata &metadata);
};
+
+ template <typename FieldType>
+ FieldType *ContactObject::getFieldById(unsigned id) const
+ {
+ return static_cast<FieldType *>(getFieldById(id));
+ }
}
}
BasicInfoItem::BasicInfoItem(Contact &contact)
: m_Contact (contact),
- m_Favorite (&contact.getFieldById(FieldFavorite)->cast<ContactBoolField>()),
+ m_Favorite (contact.getFieldById<ContactBoolField>(FieldFavorite)),
- m_Image (contact.getFieldById(FieldImage)->cast<ContactObject>()),
- m_ImagePath (m_Image.getField(0)->cast<ContactTextField>()),
+ m_Image (*contact.getFieldById<ContactObject>(FieldImage)),
+ m_ImagePath (*m_Image.getField<ContactTextField>(0)),
- m_Name (contact.getFieldById(FieldDisplayName)->cast<ContactTextField>()),
- m_PhoneticName(contact.getFieldById(FieldPhoneticName)->cast<ContactCompoundObject>()),
+ m_Name (*contact.getFieldById<ContactTextField>(FieldDisplayName)),
+ m_PhoneticName(*contact.getFieldById<ContactCompoundObject>(FieldPhoneticName)),
- m_Company (contact.getFieldById(FieldCompany)->cast<ContactObject>()),
- m_CompanyName (m_Company.getFieldById(CompanyFieldName)->cast<ContactTextField>()),
- m_JobTitle (m_Company.getFieldById(CompanyFieldJobTitle)->cast<ContactTextField>()),
+ m_Company (*contact.getFieldById<ContactObject>(FieldCompany)),
+ m_CompanyName (*m_Company.getFieldById<ContactTextField>(CompanyFieldName)),
+ m_JobTitle (*m_Company.getFieldById<ContactTextField>(CompanyFieldJobTitle)),
m_SelectMode(Ux::SelectNone)
{
ContactCompoundFieldControl::ContactCompoundFieldControl(Ui::GenlistItem *parent,
ContactCompoundObject &object)
- : ContactTextFieldControl(parent, object.getField(0)->cast<ContactTextField>()),
+ : ContactTextFieldControl(parent, *object.getField<ContactTextField>(0)),
m_Object(object), m_IsCompoundMode(true)
{
}
#include "Contacts/Input/ContactCompoundFieldItem.h"
#include "Contacts/Input/ContactCompoundFieldControl.h"
#include "Contacts/Model/ContactObject.h"
+#include "Contacts/Model/ContactCompoundObject.h"
#include "App/Path.h"
#include "Utils/Callback.h"
if (field.getInterfaces() & InterfaceCompoundObject) {
field.cast<ContactCompoundObject>().setValue(value);
} else {
- ContactField *subField = field.getField(0);
+ ContactTextField *subField = field.getField<ContactTextField>(0);
if (subField && subField->getType() == TypeText) {
- subField->cast<ContactTextField>().setValue(value);
+ subField->setValue(value);
} else {
removeField(field);
return;
{
std::vector<const char *> values;
for (auto &&fieldId : fieldIds) {
- auto field = getFieldById(fieldId);
- const char *value = field->cast<ContactTextField>().getValue();
+ auto field = getFieldById<ContactTextField>(fieldId);
+ const char *value = field->getValue();
values.push_back(value);
}
void ContactCompoundObject::setValues(Utils::Range<const char **> values)
{
for (size_t i = 0; i < values.count(); ++i) {
- auto field = getField(i);
+ ContactTextField *field = getField<ContactTextField>(i);
if (values[i]) {
- field->cast<ContactTextField>().setValue(values[i]);
+ field->setValue(values[i]);
} else {
field->reset();
}
*/
#include "Contacts/Model/ContactField.h"
-#include "Contacts/Model/ContactArray.h"
-#include "Contacts/Model/ContactBoolField.h"
-#include "Contacts/Model/ContactDateField.h"
-#include "Contacts/Model/ContactEnumField.h"
-#include "Contacts/Model/ContactTypedObject.h"
-#include "Contacts/Model/ContactCompoundObject.h"
+#include "Contacts/Model/ContactFieldContainer.h"
#include "Contacts/Model/ContactFieldMetadata.h"
using namespace Contacts::Model;
}
}
-template <typename FieldType>
-FieldType &ContactField::cast()
-{
- return static_cast<FieldType &>(*this);
-}
-
-template <typename FieldType>
-const FieldType &ContactField::cast() const
-{
- return static_cast<const FieldType &>(*this);
-}
-
-template ContactArray &ContactField::cast();
-template ContactBoolField &ContactField::cast();
-template ContactDateField &ContactField::cast();
-template ContactEnumField &ContactField::cast();
-template ContactTextField &ContactField::cast();
-template ContactObject &ContactField::cast();
-template ContactTypedObject &ContactField::cast();
-template ContactCompoundObject &ContactField::cast();
-
-template const ContactArray &ContactField::cast() const;
-template const ContactBoolField &ContactField::cast() const;
-template const ContactDateField &ContactField::cast() const;
-template const ContactEnumField &ContactField::cast() const;
-template const ContactTextField &ContactField::cast() const;
-template const ContactObject &ContactField::cast() const;
-template const ContactTypedObject &ContactField::cast() const;
-template const ContactCompoundObject &ContactField::cast() const;
-
bool ContactField::isRequired() const
{
return m_Metadata.isRequired;
unsigned fieldIds[] = { NameFieldTitle, NameFieldFirst, NameFieldMiddle, NameFieldLast };
std::string value = getValues(fieldIds);
- auto suffixField = getFieldById(NameFieldSuffix);
- const char *suffix = suffixField->cast<ContactTextField>().getValue();
+ auto suffixField = getFieldById<ContactTextField>(NameFieldSuffix);
+ const char *suffix = suffixField->getValue();
if (suffix) {
if (!value.empty()) {
value += ", ";
#include "Contacts/Model/ContactObject.h"
#include "Contacts/Model/ContactFieldMetadata.h"
+#include "Common/Database/RecordUtils.h"
+using namespace Common::Database;
using namespace Contacts::Model;
ContactField *ContactObject::getFieldById(unsigned id) const
int ContactObject::getRecordId() const
{
- return getRecordId(getRecord());
+ return getRecordInt(getRecord(), getObjectMetadata().idPropId);
}
bool ContactObject::operator==(contacts_record_h record) const
{
- return getRecordId() == getRecordId(record);
-}
-
-int ContactObject::getRecordId(contacts_record_h record) const
-{
- int id = 0;
- contacts_record_get_int(record, getObjectMetadata().idPropId, &id);
- return id;
+ return compareRecordsInt(getRecord(), record, getObjectMetadata().idPropId);
}
const ContactObjectMetadata &ContactObject::getObjectMetadata() const