TDbAttribute


This template class represent Active Record / Model attributes. By default, it works with numbers, strings and other values than can be represented as DbValue. If you need it to work with other types (for instance, enumerations), you can use partial template specialization to implement working with the type you need.

You can find more information in comments below. Overrided methods can be found in corresponding base class or interface.

template<class Type>
class TDbAttribute : public virtual IDbAttribute
{
protected:
    void SetInternal(const DbValue &value, const bool &changed) override; // Change value marking as changed or unchanged 
public:
    TDbAttribute(CDbModel *model, const String &name); // Constructor specifying parent model and attribute name 
    TDbAttribute(CDbModel *model, const String &name, const Type &value); // Constructor specifying parent model, attribute name and attribute value 
    TDbAttribute(CDbModel *model, const wchar_t *name); // Constructor specifying parent model and attribute name 
    TDbAttribute(CDbModel *model, const wchar_t *name, const Type &value); // Constructor specifying parent model, attribute name and attribute value 

    TDbAttribute &operator=(const Type &value); // Attribute value assignment operator 
    TDbAttribute &operator=(void *); // Assigning any pointer value will mark attribute as Null 

    operator Type(); // Getting value operator 

    void Set(const DbValue &value); override // Set attribute value from specified DbValue 
    DbValue Get(); const override // Return attribute value in form of DbValue 
    DbValue Old(); const override // Return old attribute value in form of DbValue 
};
Namespace: nitisa
Include: Nitisa/Db/DbAttribute.h