VCF::Class Class Reference
Class is the base class for all RTTI in the Framework. More...
#include <vcf/FoundationKit/Class.h>
Public Member Functions | |
| Class (const String &className, const String &classID, const String &superClass) | |
| the constructor for a new Class. | |
| virtual | ~Class () |
| Class * | getSuperClass () |
| returns the super class for the class. | |
| String | getID () |
| returns the class id for the class. | |
| String | getClassName () |
| returns the class name for the Class | |
| Enumerator< Property * > * | getProperties () |
| returns an enumerator containing the Property values the enumerator does not reflect the order in which the properties were added. | |
| Enumerator< Field * > * | getFields () |
| returns an enumerator containing the Field values the enumerator does not reflect the order in which the fields were added. | |
| Enumerator< Method * > * | getMethods () |
| returns an enumerator containing the Methods of the Class the enumerator does not reflect the order in which the properties were added. | |
| void | addProperty (Property *property) |
| adds a new property to the Class's property map. | |
| bool | hasProperty (const String &propertyName) |
| does the Class have a have a particular property ? | |
| uint32 | getPropertyCount () |
| the number of properties the Class has | |
| Property * | getProperty (const String &propertyName) |
| gets the property specified by propertyName, if the class has that property. | |
| void | addField (Field *field) |
| adds a new property to the Class's property map. | |
| bool | hasField (const String &fieldName) |
| does the Class have a have a particular property ? | |
| uint32 | getFieldCount () |
| the number of fields the Class has | |
| Field * | getField (const String &fieldName) |
| gets the field (or member variable) specified by fieldName, if the class has that field. | |
| void | addMethod (Method *method) |
| adds a new property to the Class's property map. | |
| bool | hasMethod (const String &methodName) |
| does the Class have a have a particular property ? | |
| uint32 | getMethodCount () |
| the number of methods the Class has | |
| Method * | getMethod (const String &methodName) |
| gets the method specified by methodName, if the class has that method. | |
| void | addEvent (EventProperty *event) |
| Adds an event to the Class. | |
| bool | hasEventHandler (const String &delegateName) |
| does the Class have this particular event handler ? | |
| Enumerator< EventProperty * > * | getEvents () |
| returns an enumerator containing the EventProperty values. | |
| EventProperty * | getEvent (const String &delegateName) |
| Returns an EventProperty by name. | |
| Enumerator< InterfaceClass * > * | getInterfaces () |
| Returns an enumeration of interfaces implemented by this class. | |
| uint32 | getInterfaceCount () |
| bool | hasInterface (const String &interfaceName) |
| bool | hasInterfaceID (const String &interfaceID) |
| InterfaceClass * | getInterfaceByName (const String &interfaceName) |
| InterfaceClass * | getInterfaceByID (const String &interfaceID) |
| void | addInterface (InterfaceClass *newInterface) |
| virtual bool | isEqual (Object *object) const |
| compares an object to the stored object instance. | |
| virtual Object * | createInstance () const =0 |
| creates a new instance of an Object based on the Class Type. | |
| virtual bool | compareObject (Object *object) const =0 |
| Used to compare the object instance passed in with the class type. | |
| void | setSource (Object *source) |
| sets the source of all properties in the Class to source. | |
Static Public Member Functions | |
| static String | getClassNameForProperty (Property *property) |
| returns the class name of a Property. | |
Detailed Description
Class is the base class for all RTTI in the Framework.Class was written because C++ RTTI is shockingly primitive, and many of these features are found in other OO languages (i.e. ObjectPascal, ObjectiveC, SmallTalk, Java, et. al) and are immensely useful and powerful.
Class is an abstract base class that template class's derive from. Classes provide the following information:
- the name of the Class - this is stored in a member variable rather than relying on typeid().name() to retreive the class name. Not all compiler's support the typeid().name() function (i.e. MSVC 6.0 does, Borland probably does, but GCC does not)
- the Class ID - this represents a UUID for the class. This will prove useful when distributed features creep in.
- the ability to discover all the properties of a Class at runtime. A property is defined as some class attribute that is provided access to via getter and setter methods. Properties can be primitive types (int, long double, etc) or Object derived types, or enums. Properties can also be collections of other properties.
- retreiving the super class of the class.
- the ability to create a new instance of the class the Class object represents. This of course assumes a default constructor is available.
The first step is (obviously) making sure that your class is derived from a Framework object. For example:
class Foo : public VCF::Object { //this is OK ... }; class Foo { //this is bad - there is no way to hook the RTTI up without at ... //least deriving from VCF::Object };
Next you should define a class id (as a string) for your class. If you are on winblows use guidgen.exe to create UUID's for you. The define should look something like this:
#define FOO_CLASSID "1E8CBE21-2915-11d4-8E88-00207811CFAB"
class Foo : public VCF::Object { _class_rtti_(Foo, "VCF::Object", FOO_CLASSID) _class_rtti_end_ ... };
class Foo : public VCF::Object { class Foo_rtti_ClassInfo : public VCF::ClassInfo<Foo> { public: typedef Foo RttiClassType; Foo_rtti_ClassInfo (): VCF::ClassInfo<RttiClassType>( VCF::StringUtils::getClassNameFromTypeInfo(typeid(Foo)), "VCF::Object", "1E8CBE21-2915-11d4-8E88-00207811CFAB" ){ VCF::String tmpClassName = VCF::StringUtils::getClassNameFromTypeInfo(typeid(Foo)); if ( isClassRegistered() ){ } } };//end of FooInfo ... };
The next step is to add any properties to the class. This is optional and is only neccessary if the you want to expose the properties of the class you're writing. Adding properties is also done through macros and looks like this:
class Foo : public VCF::Object { _class_rtti_(Foo, "VCF::Object", FOO_CLASSID) _property_( double, "fooVal", getFooVal, setFooVal, "The foo value property" ) _class_rtti_end_ ... double getFooVal(); void setFooVal( const double& val ); ... };
class Foo : public VCF::Object { _class_rtti_(Foo, "VCF::Object", FOO_CLASSID) _property_object_( Foo, "fooObj", getFoo, setFoo, "The Foo object property" ) _class_rtti_end_(Foo) ... Foo* getFoo(); void setFoo( Foo* val ); ... };
- Author:
- Jim Crafton
- Version:
- 1.0
Constructor & Destructor Documentation
|
||||||||||||||||
|
the constructor for a new Class.
|
|
|
|
Member Function Documentation
|
|
Adds an event to the Class.
|
|
|
adds a new property to the Class's property map.
|
|
|
|
|
|
adds a new property to the Class's property map.
|
|
|
adds a new property to the Class's property map.
|
|
|
Used to compare the object instance passed in with the class type. Implemented in the template derived class so a type safe compare is made. |
|
|
creates a new instance of an Object based on the Class Type. Actual implementation is performed by the template instance of the class. |
|
|
returns the class name for the Class
|
|
|
returns the class name of a Property. This will also return the correct type for C++ basic pritives (i.e. int, bool, etc) |
|
|
Returns an EventProperty by name.
|
|
|
returns an enumerator containing the EventProperty values. the enumerator does not reflect the order in which the events were added. |
|
|
gets the field (or member variable) specified by fieldName, if the class has that field.
|
|
|
the number of fields the Class has
|
|
|
returns an enumerator containing the Field values the enumerator does not reflect the order in which the fields were added.
|
|
|
returns the class id for the class. Class's may have the same name so to prevent this, an ID is provided. This is ID MUST be generated using some algorithm that guarantees a valid UUID |
|
|
|
|
|
|
|
|
|
|
|
Returns an enumeration of interfaces implemented by this class.
|
|
|
gets the method specified by methodName, if the class has that method.
|
|
|
the number of methods the Class has
|
|
|
returns an enumerator containing the Methods of the Class the enumerator does not reflect the order in which the properties were added.
|
|
|
returns an enumerator containing the Property values the enumerator does not reflect the order in which the properties were added.
|
|
|
gets the property specified by propertyName, if the class has that property.
|
|
|
the number of properties the Class has
|
|
|
returns the super class for the class. If the Rect::getClass() was called and then getSuperClass() was called on the return value of Rect::getClass(), the return would be a Class* for Object. |
|
|
does the Class have this particular event handler ?
|
|
|
does the Class have a have a particular property ?
|
|
|
|
|
|
|
|
|
does the Class have a have a particular property ?
|
|
|
does the Class have a have a particular property ?
|
|
|
compares an object to the stored object instance. This uses typeid which is OK in GCC. The actual compare is made in compareObject() which is implemented in the derived Template classes
|
|
|
sets the source of all properties in the Class to source.
|
The documentation for this class was generated from the following file:
- vcf/FoundationKit/Class.h
