C12Adapter Opensource C++ Interface
|
Notion of a class that serves as the base for the reflection API. More...
Public Types | |
enum | { MAXIMUM_NUMBER_OF_SERVICE_PARAMETERS = 6, MAXIMUM_CLASS_NAME_LENGTH = 40 } |
Public Member Functions | |
const MClass * | GetParent () const |
Get parent of a class, or NULL if the class has no parent. More... | |
bool | IsKindOf (const MClass *) const |
Tell about the relationship between this class and a given class. More... | |
MConstChars | GetName () const |
Access the name of the MClass. More... | |
MConstChars | GetTypeName () const |
Access the type name of the class. More... | |
const MClass * | GetParentClass (const MStdString &name) const |
Get parent class by the name specified. More... | |
const MServiceDefinition * | GetServiceDefinitionOrNull (const MStdString &name, int expectedNumberOfParameters=-1) const |
Get the constant definition of service (method) with the given name, or return NULL if such service does not exist. More... | |
const MServiceDefinition * | GetServiceDefinition (const MStdString &name, int expectedNumberOfParameters=-1) const |
Get the constant definition of service (method) with the given name, or return NULL if such service does not exist. More... | |
bool | IsServicePresent (const MStdString &name) const |
Tell if the service (method) with the given name exists in the class. More... | |
MStdStringVector | GetAllServiceNames () const |
The collection of all publicly available reflection enabled services. More... | |
MStdStringVector | GetOwnServiceNames () const |
The collection of publicly available reflection enabled services owned by the class. More... | |
const MServiceDefinition * | GetOwnServiceDefinitions () const |
Return the pointer to the array of objects that represent publicly available services. More... | |
MVariant | Call (const MStdString &name, const MVariant ¶ms) const |
Call the static service of the class with parameters, given as variant. More... | |
MVariant | Call0 (const MStdString &name) const |
Call the static service of the object with no parameters. More... | |
MVariant | Call1 (const MStdString &name, const MVariant &p1) const |
Call the static service of the object with one parameter. More... | |
MVariant | Call2 (const MStdString &name, const MVariant &p1, const MVariant &p2) const |
Call the static service of the object with two parameter. More... | |
MVariant | CallV (const MStdString &name, const MVariant::VariantVector ¶ms) const |
Call the static service of the object with vector of parameter. More... | |
const MPropertyDefinition * | GetPropertyDefinition (const MStdString &name) const |
Get the existing constant definition of the property with the name specified. More... | |
const MPropertyDefinition * | GetPropertyDefinitionOrNull (const MStdString &name) const |
Get the constant definition of the property with the name specified, or NULL if such property does not exist. More... | |
bool | IsPropertyPresent (const MStdString &name) const |
Tell if the property with the given name exists. More... | |
MVariant | GetProperty (const MStdString &name) const |
Get the static class property value using name of the property. More... | |
void | SetProperty (const MStdString &name, const MVariant &value) const |
Set the static class property value using name of the property. More... | |
MStdStringVector | GetAllPropertyNames () const |
Return the whole list of publicly available properties of this class and parents. More... | |
MStdStringVector | GetOwnPropertyNames () const |
Return the list of publicly available properties owned by this class. More... | |
MStdStringVector | GetAllPersistentPropertyNames () const |
Return the list of publicly available persistent properties of this class and all parents of this class. More... | |
MVariant | GetPersistentPropertyDefaultValue (const MStdString &name) const |
Get the default value of persistent property with the name given. More... | |
bool | MatchesClassOrTypeName (const MStdString &name) const |
Whether the given string is either class name or type name. More... | |
Static Public Member Functions | |
static const MClass * | GetClass (const MStdString &name) |
Find an MClass of a class with the name given. More... | |
static const MClass * | GetExistingClass (const MStdString &name) |
Find an existing MClass of a class with the name given. More... | |
static MStdStringVector | GetAllClassNames () |
Return the list of all publicly available classes. More... | |
static bool | StaticIsKindOf (const MObject *obj, const MClass *cls) |
static bool | StaticIsKindOf (const MObject &ref, const MClass *cls) |
Friends | |
class M_CLASS | MObject |
Notion of a class that serves as the base for the reflection API.
Every class derived from MObject and exposed through Reflection has an associated class object. Class gives the way for an object to dynamically present the information about itself:
Somewhat more popular name for what is called "service" is "method."
Properties can be read-only, in which case their values cannot be set by direct assignment to property. Read-write properties can be persistent, which means there is a default value available for such property, and that the value of such property is suitable for persisting in configuration.
anonymous enum |
MVariant MClass::Call | ( | const MStdString & | name, |
const MVariant & | params | ||
) | const |
Call the static service of the class with parameters, given as variant.
Service of the class is the same as static method in C++.
name | Name of the static service (method) to call. |
params | Parameters to pass to the static service.
|
MVariant MClass::Call0 | ( | const MStdString & | name | ) | const |
Call the static service of the object with no parameters.
Service of the class is the same as static method in C++.
name | Name of the static service (method) to call. |
MVariant MClass::Call1 | ( | const MStdString & | name, |
const MVariant & | p1 | ||
) | const |
Call the static service of the object with one parameter.
Service of the class is the same as static method in C++.
name | Name of the static service (method) to call. |
p1 | The parameter to pass to static service. |
MVariant MClass::Call2 | ( | const MStdString & | name, |
const MVariant & | p1, | ||
const MVariant & | p2 | ||
) | const |
Call the static service of the object with two parameter.
Service of the class is the same as static method in C++.
name | Name of the service (method) to call. |
p1 | The first parameter to pass to service. |
p2 | The second parameter to pass to service. |
MVariant MClass::CallV | ( | const MStdString & | name, |
const MVariant::VariantVector & | params | ||
) | const |
Call the static service of the object with vector of parameter.
Service of the class is the same as static method in C++.
name | Name of the service (method) to call. |
params | The vector of parameters to pass to service. |
|
static |
Return the list of all publicly available classes.
While this property is declared in MClass, it really belongs to global environment of the application. The list composes all classes from all shared libraries or executables available at the time of the call. If a library is loaded dynamically at run time, and it has reflected classes, this list will grow.
MStdStringVector MClass::GetAllPersistentPropertyNames | ( | ) | const |
Return the list of publicly available persistent properties of this class and all parents of this class.
Persistent properties of this class and all parents of this class are returned.
MStdStringVector MClass::GetAllPropertyNames | ( | ) | const |
Return the whole list of publicly available properties of this class and parents.
Persistent and not persistent properties of this class and all parents of this class are returned.
MStdStringVector MClass::GetAllServiceNames | ( | ) | const |
The collection of all publicly available reflection enabled services.
The list of services includes services of parent class. If the service has copies with different number of parameters, still only one copy of the service name will be present.
|
static |
Find an MClass of a class with the name given.
All reflected classes existing in the application are enumerated to find a class.
name | Class name to search for |
|
static |
Find an existing MClass of a class with the name given.
All reflected classes existing in the application are enumerated to find a class.
name | Class name to search for. Such class should exist, or an exception is thrown. |
|
inline |
Access the name of the MClass.
This will be a string representation of a particular class, like "Table" would be the one to represent class MTable.
MStdStringVector MClass::GetOwnPropertyNames | ( | ) | const |
Return the list of publicly available properties owned by this class.
Persistent and not persistent properties of this class are returned.
|
inline |
Return the pointer to the array of objects that represent publicly available services.
This is a C++ only call.
MStdStringVector MClass::GetOwnServiceNames | ( | ) | const |
The collection of publicly available reflection enabled services owned by the class.
The list of services does not include services of parent class. If the service has copies with different number of parameters, still only one copy of the service name will be present.
|
inline |
Get parent of a class, or NULL if the class has no parent.
The only class that has no parent is MObject.
const MClass* MClass::GetParentClass | ( | const MStdString & | name | ) | const |
Get parent class by the name specified.
name | Class name, parent name. |
MVariant MClass::GetPersistentPropertyDefaultValue | ( | const MStdString & | name | ) | const |
Get the default value of persistent property with the name given.
name | Name of the persistent property to fetch default value from. The object should have the property with such name, and this property should have a default value (be persistent). Otherwise an exception is thrown. |
MVariant MClass::GetProperty | ( | const MStdString & | name | ) | const |
Get the static class property value using name of the property.
name | Name of the property of interest. The property with such name should exist, and it should be the property of the class. Otherwise an exception will be thrown. |
|
inline |
Get the existing constant definition of the property with the name specified.
name | The name of the property. The property with the name given should exist, otherwise the service throws an exception. |
const MPropertyDefinition* MClass::GetPropertyDefinitionOrNull | ( | const MStdString & | name | ) | const |
Get the constant definition of the property with the name specified, or NULL if such property does not exist.
name | The name of the property. |
const MServiceDefinition* MClass::GetServiceDefinition | ( | const MStdString & | name, |
int | expectedNumberOfParameters = -1 |
||
) | const |
Get the constant definition of service (method) with the given name, or return NULL if such service does not exist.
This is C++ only. Service, as used in the identifier, is another name for method.
name | Service name to get definition for. If service does not exist, an exception is thrown. |
expectedNumberOfParameters | Expected number of parameters. If specified, and not -1, shall denote the valid expected number of parameters. This parameter will need to be specified only for services that allow overloading. |
const MServiceDefinition* MClass::GetServiceDefinitionOrNull | ( | const MStdString & | name, |
int | expectedNumberOfParameters = -1 |
||
) | const |
Get the constant definition of service (method) with the given name, or return NULL if such service does not exist.
This is C++ only. Service, as used in the identifier, is another name for method.
name | Service name to get definition for. If service does not exist, NULL will be returned. |
expectedNumberOfParameters | Expected number of parameters. If specified, and not -1, shall denote the valid expected number of parameters. This parameter will need to be specified only for services that allow overloading. |
|
inline |
Access the type name of the class.
Type of the class is in majority of cases the same as the class name. The differences exist only in MCOM classes, those derived from MCOMObject, such as MProtocol and MChannel.
bool MClass::IsKindOf | ( | const MClass * | ) | const |
Tell about the relationship between this class and a given class.
|
inline |
Tell if the property with the given name exists.
name | The property name for which to check the existence |
|
inline |
Tell if the service (method) with the given name exists in the class.
name | Name of the service to check. |
bool MClass::MatchesClassOrTypeName | ( | const MStdString & | name | ) | const |
Whether the given string is either class name or type name.
This method is a convenience when a string has to match either class or type of this Class.
name | Name of the presumed class or type. |
void MClass::SetProperty | ( | const MStdString & | name, |
const MVariant & | value | ||
) | const |
Set the static class property value using name of the property.
name | Name of the property of interest. The property with such name should exist, it should not be read-only, and it should be the property of the class. Otherwise an exception will be thrown. |
value | Value to assign to the property. |
Static version that tells if a given object is of a given class, or it is its child.
Different from IsKindOf, this version checks of the given object is null.
Static version that tells if a given object is of a given class, or it is its child.
Different from IsKindOf, this version checks of the given object is null.