wxArt2D
Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
a2dPropertyIdTyped< basetype, proptype > Class Template Reference

This template class is for property ids with a known data type. More...

#include <id.h>

Inheritance diagram for a2dPropertyIdTyped< basetype, proptype >:
Inheritance graph
[legend]
Collaboration diagram for a2dPropertyIdTyped< basetype, proptype >:
Collaboration graph
[legend]

Public Types

typedef basetype(wxObject::* Get )() const
 
typedef const basetype
&(wxObject::* 
ConstGet )() const
 
typedef void(wxObject::* Set )(basetype)
 
typedef void(wxObject::* ConstSet )(const basetype &value)
 
typedef basetype wxObject::* Mptr
 
- Public Types inherited from a2dPropertyId
enum  Flags {
  flag_none = 0x00000000, flag_temporary = 0x00000001, flag_transfer = 0x00000002, flag_onlymember = 0x00000004,
  flag_onlymemberhint = 0x00000008, flag_listfirst = 0x00000010, flag_multiple = 0x00000020, flag_clonedeep = 0x00000040,
  flag_listonly = 0x00000080, flag_norender = 0x00000100, flag_userDefined = 0x00000200, flag_isEditable = 0x00000400,
  flag_notify = 0x00000800
}
 Flags for property ids. More...
 
enum  SetFlags { set_none = 0x00000000, set_onlymember = 0x00000010, set_remove_non_member = 0x00000020, set_remove_property = 0x00000040 }
 Flags used for manipulating the way a property is set to a2dObject. More...
 

Public Member Functions

 a2dPropertyIdTyped (const wxString &name, Flags flags, const basetype &defaultvalue)
 constructor for dynamic properties on objects More...
 
 a2dPropertyIdTyped (const wxString &name, basetype defaultvalue, Flags flags=flag_listfirst)
 
 a2dPropertyIdTyped (const wxString &name, Flags flags, const basetype &defaultvalue, Get getFunc, Set setFunc)
 constructor for Get and Set functions to get the property More...
 
 a2dPropertyIdTyped (const wxString &name, Flags flags, const basetype &defaultvalue, Get getFunc, ConstSet setFunc)
 constructor for Get and ConstSet functions to get the property More...
 
 a2dPropertyIdTyped (const wxString &name, Flags flags, const basetype &defaultvalue, ConstGet getFunc, ConstSet setFunc)
 
 a2dPropertyIdTyped (const wxString &name, Flags flags, const basetype &defaultvalue, Mptr ptm)
 constructor for a pointer to a member variable to get the property More...
 
void SetPropertyToObject (a2dObject *obj, const basetype &value, SetFlags setflags=set_none) const
 Set the property in obj to value.
 
void SetPropertyToObject (a2dObject *obj, proptype *property, SetFlags setflags=set_none) const
 Given the object to set the property on, and a a2dNamedProperty to. More...
 
proptype * GetPropertyClone (const a2dObject *obj) const
 retrieve in form of a a2dNamedProperty the value of the property identified with this id More...
 
a2dNamedPropertyGetPropertyAsNamedProperty (const a2dObject *obj) const
 
void SetNamedPropertyToObject (a2dObject *obj, a2dNamedProperty *nprop, SetFlags setflags=set_none) const
 Set the property in obj to value (not cloning value)
 
proptype * GetPropertyListOnly (const a2dObject *obj) const
 Get the property from the list in obj ( no members, not cloned )
 
basetype GetPropertyValue (const a2dObject *obj) const
 Get the property value in obj.
 
basetype GetPropertyValue (const a2dObject *obj, const basetype &defaultvalue) const
 Get the property value in obj, if not found return default value given.
 
basetype * GetPropertyValuePtr (a2dObject *obj) const
 Get a pointer to the property value in obj.
 
const basetype & GetDefaultValue () const
 Get the default value for this property.
 
a2dNamedPropertyCreatePropertyFromString (const wxString &value) const
 Create a new property object from a value string.
 
- Public Member Functions inherited from a2dPropertyId
 a2dPropertyId (const wxString &name, Flags flags)
 Default constructor.
 
virtual ~a2dPropertyId ()
 destructor
 
virtual wxString GetName () const
 Get the ids print and serialization name.
 
void SetName (const wxString &name)
 Set the ids print and serialization name.
 
virtual const a2dPropertyIdGetMainID () const
 Get the main (pre-dot) part of a hierarchical id.
 
virtual const a2dPropertyIdGetSubID () const
 Get the sub (post-dot) part of a hierarchical id.
 
virtual bool operator== (const a2dPropertyId &other) const
 Check if this id is equal to another id.
 
bool IsCloneDeep () const
 Test if this id identifies a property that needs to be cloned deep.
 
bool IsTemporary () const
 Test if this id identifies a temporary property.
 
bool IsTransfer () const
 true if this property is transfered via e.g. a command processor
 
bool IsOnlyMember () const
 true if this property is only set as member
 
bool IsOnlyMemberHint () const
 true if this property has the only set as member hint set
 
bool IsListFirst () const
 true if this property searches the list first, then members
 
bool IsListOnly () const
 true if this property searches the list only
 
bool IsUserDefined () const
 true if this property is user defined
 
bool IsEditable () const
 true if this property is editable ( can be tested in a property editor ).
 
bool CheckFlags (Flags flags) const
 check a flag mask (all given flags must be set)
 
bool CheckCollect (const a2dPropertyId *id, Flags flags) const
 check a property id and flags to see if the property shall be collected
 
void RemovePropertyFromObject (a2dObject *obj) const
 Dynamic properties with this id will be removed from the object. More...
 

Static Public Member Functions

static a2dPropertyIdTyped
< basetype, proptype > * 
GetDummy ()
 returns a dummy property id of this type, that can be used in non-id applications More...
 

Protected Member Functions

 a2dPropertyIdTyped ()
 this constructor is only for property ids referencing other property ids
 
- Protected Member Functions inherited from a2dPropertyId
 a2dPropertyId ()
 this constructor is only for property ids referencing other property ids
 
void DoAddPropertyToObject (a2dObject *obj, a2dNamedProperty *prop) const
 this is called by derived classes to add a list property in an object More...
 
bool DoIgnoreIfNotMember (a2dObject *obj) const
 this is called by derived to check if a property should be added as non-member More...
 

Protected Attributes

Get m_get
 
ConstGet m_constget
 
Set m_set
 
ConstSet m_constset
 
basetype a2dObject::* m_ptm
 
basetype m_defaultvalue
 this is the value returned if e.g. a property is not found
 
- Protected Attributes inherited from a2dPropertyId
wxString m_name
 
Flags m_flags
 

Additional Inherited Members

- Static Protected Member Functions inherited from a2dPropertyId
static void DoSetPropertyId (a2dNamedProperty *prop, a2dPropertyId *id)
 this is called by derived classes to change an id in a property More...
 

Detailed Description

template<class basetype, class proptype>
class a2dPropertyIdTyped< basetype, proptype >

This template class is for property ids with a known data type.

When the property type has only a single value stored, this is the template to use,
since this has many function to get/set that object without further effort.
So for a a2dBoundingBox in a a2dBoudingBoxProperty it is best to use this:
<code>
    typedef a2dPropertyIdTyped<a2dBoundingBox, a2dBoudingBoxProperty> a2dPropertyIdBoundingBox;
</code>

    Assume that a2dCanvasObject has:

<code>

declare of static member in the class static const a2dPropertyIdBoundingBox PROPID_BoundingBox;

initialize static member in cpp file const a2dPropertyIdBoundingBox a2dCanvasObject::PROPID_BoundingBox( CLASSNAME( a2dCanvasObject ), wxT("statebox"), a2dPropertyId::flag_temporary|a2dPropertyId::flag_multiple, a2dBoundingBox() );

We can set it like this: a2dBoundingBox updatearea(0,0,100,100); a2dCanvasObject::PROPID_BoundingBox->SetPropertyToObject( a_canvasobject, updatearea ); a2dBoundingBox updatearea2(0,0,100,100); a2dCanvasObject::PROPID_BoundingBox->SetPropertyToObject( a_canvasobject, updatearea2 );

This will give us two dynamic properties (see flag_multiple ) on the a_canvasobject.

Definition at line 477 of file id.h.

Constructor & Destructor Documentation

template<class basetype , class proptype >
a2dPropertyIdTyped< basetype, proptype >::a2dPropertyIdTyped ( const wxString &  name,
Flags  flags,
const basetype &  defaultvalue 
)

constructor for dynamic properties on objects

This constructor is for purely dynamic properties ( stored a a2dNamedProperty on a a2dObject ).

Parameters
namethe name of the propertyId
flagsdefines how a property needs to be set and retrieved.
defaultvalueif property is not available, and still asked for, and allowed as dynamic property, this value is returned.

Definition at line 152 of file id.inl.

template<class basetype , class proptype >
a2dPropertyIdTyped< basetype, proptype >::a2dPropertyIdTyped ( const wxString &  name,
Flags  flags,
const basetype &  defaultvalue,
Get  getFunc,
Set  setFunc 
)

constructor for Get and Set functions to get the property

Parameters
namethe name of the propertyId
flagsdefines how a property needs to be set and retrieved.
defaultvalueif property is not available, and still asked for, and allowed as dynamic property, this value is returned.
getFuncfunction to get the property to a class member, if NULL property is retrieved in a different manner
setFuncfunction to set the property to a class member, if NULL property is set in a different manner

Definition at line 176 of file id.inl.

template<class basetype , class proptype >
a2dPropertyIdTyped< basetype, proptype >::a2dPropertyIdTyped ( const wxString &  name,
Flags  flags,
const basetype &  defaultvalue,
Get  getFunc,
ConstSet  setFunc 
)

constructor for Get and ConstSet functions to get the property

Parameters
namethe name of the propertyId
flagsdefines how a property needs to be set and retrieved.
defaultvalueif property is not available, and still asked for, and allowed as dynamic property, this value is returned.
getFuncfunction to get the property from a class member, if NULL property is retrieved in a different manner
setFuncfunction to set the property to a class member, if NULL property is set in a different manner

Definition at line 188 of file id.inl.

template<class basetype , class proptype >
a2dPropertyIdTyped< basetype, proptype >::a2dPropertyIdTyped ( const wxString &  name,
Flags  flags,
const basetype &  defaultvalue,
Mptr  ptm 
)

constructor for a pointer to a member variable to get the property

Parameters
namethe name of the propertyId
flagsdefines how a property needs to be set and retrieved.
defaultvalueif property is not available, and still asked for, and allowed as dynamic property, this value is returned.
ptmpointer to a class field to get and set the property, if NULL property is retrieved in a different manner

Definition at line 212 of file id.inl.

Member Function Documentation

template<class basetype , class proptype >
a2dPropertyIdTyped< basetype, proptype > * a2dPropertyIdTyped< basetype, proptype >::GetDummy ( )
static

returns a dummy property id of this type, that can be used in non-id applications

Normally properties that are used internal in the library are declared by a a2dPropertyId as a static member of a class. Like this: static const a2dPropertyIdString PROPID_Name; And as this the property id is initialized, as to say what type of property it is and to which class it belongs. const a2dPropertyIdString a2dObject::PROPID_Name( wxT("name"), a2dPropertyId::flag_none, wxT("") );

If non of this is required, you can have non id properties. As an example you can have user defined properties, which the program will not know about, and will not treat as setting something inside a class, or holds in a dynamic fashion some information, which the program does use.

Like the user can add a dynamic property to a a2dObject, dynamic properties are stored in a2dObject::m_propertylist. And using this function here, you can give such a property the dummy id which is always there as a static existing id.

Definition at line 389 of file id.inl.

template<class basetype , class proptype >
proptype * a2dPropertyIdTyped< basetype, proptype >::GetPropertyClone ( const a2dObject obj) const

retrieve in form of a a2dNamedProperty the value of the property identified with this id

The property id is defining the way a a2dNamedProperty can be set or retrieved from the a2dObject. If the m_ptm is set that will be used, else m_get and m_set, and in the end via dynamic properties.

Parameters
objthe object on which the property needs to be retrieved

Definition at line 396 of file id.inl.

template<class basetype , class proptype >
void a2dPropertyIdTyped< basetype, proptype >::SetPropertyToObject ( a2dObject obj,
proptype *  property,
SetFlags  setflags = set_none 
) const

Given the object to set the property on, and a a2dNamedProperty to.

hold the property value and type, set it as a property to the object.

Definition at line 246 of file id.inl.


The documentation for this class was generated from the following files:
a2dPropertyIdTyped< basetype, proptype > Class Template Reference -- Sun Oct 12 2014 17:04:46 -- Sun Oct 12 2014 -- 1.8.5 -- wxArt2D -- . -- Main Page Reference Documentation