Sourceforge.net - The VCF's Project Host
   The VCF Website Home   |   Online Discussion Forums   |   Sourceforge.net Project Page   

VCF::Class Class Reference

Class is the base class for all RTTI in the Framework. More...

#include <vcf/FoundationKit/Class.h>

List of all members.

Public Member Functions

 Class (const String &className, const String &classID, const String &superClass)
 the constructor for a new Class.
virtual ~Class ()
ClassgetSuperClass ()
 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
PropertygetProperty (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
FieldgetField (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
MethodgetMethod (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.
EventPropertygetEvent (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)
InterfaceClassgetInterfaceByName (const String &interfaceName)
InterfaceClassgetInterfaceByID (const String &interfaceID)
void addInterface (InterfaceClass *newInterface)
virtual bool isEqual (Object *object) const
 compares an object to the stored object instance.
virtual ObjectcreateInstance () 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:

In order for the RTTI to work in the Framework developers of derived classes must do three things for their classes to participate in the Framework. Failure to implement these steps will mean their classes will not have correct RTTI. A series of macros (defined in ClassInfo.h) have been written to make this easier.

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"
The next step is to add to macros to your class defintion (.h/.hpp file). These are required for the basic RTTI info (class-super class relation ships) and to make sure you'll inherit any properties of your super class. For example:
    class Foo : public VCF::Object {
        _class_rtti_(Foo, "VCF::Object", FOO_CLASSID)
        _class_rtti_end_
    ...
    };
The macros create a public nested class used to register your class that you're writing. The above macros generate the following inline code for the developer of the Foo class.
    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 );
    ...
    };
If the properties are Object derived properties then the following can be done:
    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

VCF::Class::Class const String className,
const String classID,
const String superClass
 

the constructor for a new Class.

Parameters:
String the class name of the class
String the class id for the class. This MUST be a string that represents unique ID as returned by a UUID function/algorithm the format is this: 96B6A350-2873-11d4-8E88-00207811CFAB
String the name of the class's super class

virtual VCF::Class::~Class  )  [virtual]
 


Member Function Documentation

void VCF::Class::addEvent EventProperty event  ) 
 

Adds an event to the Class.

Parameters:
EventProperty* the event to add - see EventProperty for more info.

void VCF::Class::addField Field field  ) 
 

adds a new property to the Class's property map.

void VCF::Class::addInterface InterfaceClass newInterface  ) 
 

void VCF::Class::addMethod Method method  ) 
 

adds a new property to the Class's property map.

void VCF::Class::addProperty Property property  ) 
 

adds a new property to the Class's property map.

virtual bool VCF::Class::compareObject Object object  )  const [pure virtual]
 

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.

virtual Object* VCF::Class::createInstance  )  const [pure virtual]
 

creates a new instance of an Object based on the Class Type.

Actual implementation is performed by the template instance of the class.

String VCF::Class::getClassName  ) 
 

returns the class name for the Class

static String VCF::Class::getClassNameForProperty Property property  )  [static]
 

returns the class name of a Property.

This will also return the correct type for C++ basic pritives (i.e. int, bool, etc)

EventProperty* VCF::Class::getEvent const String delegateName  ) 
 

Returns an EventProperty by name.

Parameters:
String the event delegate to return

Enumerator<EventProperty*>* VCF::Class::getEvents  )  [inline]
 

returns an enumerator containing the EventProperty values.

the enumerator does not reflect the order in which the events were added.

Field* VCF::Class::getField const String fieldName  ) 
 

gets the field (or member variable) specified by fieldName, if the class has that field.

Parameters:
String the name of the field to try and retrieve
Returns:
Field a pointer to a field of the class.

uint32 VCF::Class::getFieldCount  ) 
 

the number of fields the Class has

Enumerator<Field*>* VCF::Class::getFields  )  [inline]
 

returns an enumerator containing the Field values the enumerator does not reflect the order in which the fields were added.

String VCF::Class::getID  ) 
 

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

InterfaceClass* VCF::Class::getInterfaceByID const String interfaceID  ) 
 

InterfaceClass* VCF::Class::getInterfaceByName const String interfaceName  ) 
 

uint32 VCF::Class::getInterfaceCount  ) 
 

Enumerator<InterfaceClass*>* VCF::Class::getInterfaces  )  [inline]
 

Returns an enumeration of interfaces implemented by this class.

Method* VCF::Class::getMethod const String methodName  ) 
 

gets the method specified by methodName, if the class has that method.

Parameters:
String the name of the method to try and retrieve
Returns:
Method a pointer to a method of the class.

uint32 VCF::Class::getMethodCount  ) 
 

the number of methods the Class has

Enumerator<Method*>* VCF::Class::getMethods  )  [inline]
 

returns an enumerator containing the Methods of the Class the enumerator does not reflect the order in which the properties were added.

Enumerator<Property*>* VCF::Class::getProperties  )  [inline]
 

returns an enumerator containing the Property values the enumerator does not reflect the order in which the properties were added.

Property* VCF::Class::getProperty const String propertyName  ) 
 

gets the property specified by propertyName, if the class has that property.

Parameters:
String the name of the property to try and retrieve
Returns:
Property a pointer to a property of the class.

uint32 VCF::Class::getPropertyCount  ) 
 

the number of properties the Class has

Class* VCF::Class::getSuperClass  ) 
 

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.

bool VCF::Class::hasEventHandler const String delegateName  ) 
 

does the Class have this particular event handler ?

Returns:
bool returns true if the Class has an event handler by this name

bool VCF::Class::hasField const String fieldName  ) 
 

does the Class have a have a particular property ?

Parameters:
String the name of the property to find
Returns:
bool true if the class has the specified property, otherwise false

bool VCF::Class::hasInterface const String interfaceName  ) 
 

bool VCF::Class::hasInterfaceID const String interfaceID  ) 
 

bool VCF::Class::hasMethod const String methodName  ) 
 

does the Class have a have a particular property ?

Parameters:
String the name of the property to find
Returns:
bool true if the class has the specified property, otherwise false

bool VCF::Class::hasProperty const String propertyName  ) 
 

does the Class have a have a particular property ?

Parameters:
String the name of the property to find
Returns:
bool true if the class has the specified property, otherwise false

virtual bool VCF::Class::isEqual Object object  )  const [inline, virtual]
 

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

Parameters:
Object another Class instance to compare this Class instance to
Returns:
bool true if the object's typeid is equal to this' typeid

void VCF::Class::setSource Object source  ) 
 

sets the source of all properties in the Class to source.

Parameters:
Object the source to which the properties are set


The documentation for this class was generated from the following file:
   Comments or Suggestions?    License Information