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 () const
 returns the super class for the class.
String getID () const
 returns the class id for the class.
String getClassName () const
 returns the class name for the Class
Enumerator< Property * > * getProperties () const
 returns an enumerator containing the Property values the enumerator does not reflect the order in which the properties were added.
Enumerator< Field * > * getFields () const
 returns an enumerator containing the Field values the enumerator does not reflect the order in which the fields were added.
Enumerator< Method * > * getMethods () const
 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) const
 does the Class have a have a particular property ?
uint32 getPropertyCount () const
 the number of properties the Class has
PropertygetProperty (const String &propertyName) const
 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) const
 does the Class have a have a particular property ?
uint32 getFieldCount () const
 the number of fields the Class has
FieldgetField (const String &fieldName) const
 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) const
 does the Class have a have a particular property ?
uint32 getMethodCount () const
 the number of methods the Class has
MethodgetMethod (const String &methodName) const
 gets the method specified by methodName, if the class has that method.
void addDelegate (DelegateProperty *event)
 Adds an event to the Class.
bool hasDelegate (const String &delegateName) const
 does the Class have this particular event handler ?
Enumerator< DelegateProperty * > * getDelegates () const
 returns an enumerator containing the DelegateProperty values.
DelegatePropertygetDelegate (const String &delegateName) const
 Returns an DelegateProperty by name.
Enumerator< InterfaceClass * > * getInterfaces () const
 Returns an enumeration of interfaces implemented by this class.
uint32 getInterfaceCount () const
bool hasInterface (const String &interfaceName) const
bool hasInterfaceID (const String &interfaceID) const
InterfaceClassgetInterfaceByName (const String &interfaceName) const
InterfaceClassgetInterfaceByID (const String &interfaceID) const
void addInterface (InterfaceClass *newInterface)
virtual bool isEqual (const 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 (const 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.
void setSource (const Object *source)
uint32 sizeOf () const

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::addDelegate DelegateProperty event  ) 
 

Adds an event to the Class.

Parameters:
DelegateProperty* the event to add - see DelegateProperty 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 const 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  )  const
 

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)

DelegateProperty* VCF::Class::getDelegate const String delegateName  )  const
 

Returns an DelegateProperty by name.

Parameters:
String the event delegate to return

Enumerator<DelegateProperty*>* VCF::Class::getDelegates  )  const [inline]
 

returns an enumerator containing the DelegateProperty values.

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

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

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  )  const
 

the number of fields the Class has

Enumerator<Field*>* VCF::Class::getFields  )  const [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  )  const
 

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  )  const
 

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

uint32 VCF::Class::getInterfaceCount  )  const
 

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

Returns an enumeration of interfaces implemented by this class.

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

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  )  const
 

the number of methods the Class has

Enumerator<Method*>* VCF::Class::getMethods  )  const [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  )  const [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  )  const
 

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  )  const
 

the number of properties the Class has

Class* VCF::Class::getSuperClass  )  const
 

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::hasDelegate const String delegateName  )  const
 

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  )  const
 

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  )  const
 

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

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

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  )  const
 

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 const 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 const Object source  ) 
 

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

uint32 VCF::Class::sizeOf  )  const
 


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