Main Page   Modules   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

InterfaceProxy Class Reference

Base class for interface proxy classes. More...

#include <InterfaceRegistry.h>

List of all members.

Public Methods

 InterfaceProxy (const char *cname, hasht chash)
 Constructor.

 InterfaceProxy (const char *cname, hasht(*chash)())
virtual ~InterfaceProxy ()
virtual ObjectcreateObject () const
 Create a new instance of the corresponding object.

virtual hasht getClassHash () const
 Get the class hash of the corresponding object.

virtual const char * getClassName () const
 Get the class name of the corresponding object.

const TypeAdapter get (Object *o, std::string const &varname) const
 Get the value of an interface variable.

void set (Object *o, std::string const &varname, const TypeAdapter &v)
 Set the value of an interface variable.

void push_back (Object *o, std::string const &varname, const TypeAdapter &v)
 Append a value to an interface variable list.

void set_enum (Object *o, std::string const &varname, std::string const &v)
 Assign an Enum value to an object member variable.

void clear (Object *o, std::string const &varname)
 Remove all members of an object member variable container.

bool variableExists (std::string const &varname) const
 Test if a member variable is defined in the object interface.

bool variableRequired (std::string const &varname) const
 Test if a member variable in the object interface must be assigned a value in XML Object definitions of the object.

std::string variableType (std::string const &varname) const
 Get a string representation of the type of an interface variable.

std::vector< std::string > getVariableNames () const
 Get the names of all variables in the interface.

std::vector< std::string > getRequiredNames () const
 Get the names of all required variables in the interface.

bool isSubclass (std::string const &cname) const
 Test if this object interface is a subclass of the specified class.

bool isSubclass (hasht const &chash) const
 Test if this object interface is a subclass of the specified class.

virtual bool isStatic () const
 Test if the object class of this interface is static.


Protected Methods

void addInterface (ObjectInterfaceBase *objectinterface, std::string const &classname, hasht const &classhash)
 Add an ObjectInterface.

ObjectInterfaceBasefindInterface (std::string const &varname, bool required) const
 Find the ObjectInterface corresponding to a given variable name.


Detailed Description

Base class for interface proxy classes.

Stores a reference to the actual interface and provides accessor methods to create and manipulate objects dynamically at runtime. See Object Interfaces and Interface Proxies for details.

Author:
Mark Rose <mrose@stm.lbl.gov>


Constructor & Destructor Documentation

InterfaceProxy::InterfaceProxy const char *    cname,
hasht    chash
 

Constructor.

Construct a new interface proxy, and register it with the global interface registry.

Parameters:
cname  the class name
chash  the class hash

NAMESPACE_SIMDATA InterfaceProxy::InterfaceProxy const char *    cname,
hasht(*    chash)()
 

virtual InterfaceProxy::~InterfaceProxy   [inline, virtual]
 


Member Function Documentation

void InterfaceProxy::addInterface ObjectInterfaceBase   objectinterface,
std::string const &    classname,
hasht const &    classhash
[protected]
 

Add an ObjectInterface.

Used internally to register ObjectInterface instances. Each InterfaceProxy constructor creates a ObjectInterface instance for the variables accessible in the corresponding Object subclass. These interfaces are stored in the InterfaceProxy base class and used to access all variables in the Object hierarchy.

Note:
Do not call this method directly.
Parameters:
objectinterface  The ObjectInterface to add.
classname  The name of the Object subclass corresponding to the interface being added.
classhash  The hash of the Object subclass.

void InterfaceProxy::clear Object   o,
std::string const &    varname
[inline]
 

Remove all members of an object member variable container.

Parameters:
o  The object
varname  The name of the member variable container.

Object * InterfaceProxy::createObject   [virtual]
 

Create a new instance of the corresponding object.

ObjectInterfaceBase * InterfaceProxy::findInterface std::string const &    varname,
bool    required
const [protected]
 

Find the ObjectInterface corresponding to a given variable name.

Parameters:
varname  The name of the variable to be accessed.
required  If true, an exception will be thrown if no interface is found for the specified variable name.
Returns:
The interface correcsponding to the specified variable name, or 0 if no interface is found and required is false.

const TypeAdapter InterfaceProxy::get Object   o,
std::string const &    varname
const [inline]
 

Get the value of an interface variable.

hasht InterfaceProxy::getClassHash   [virtual]
 

Get the class hash of the corresponding object.

const char * InterfaceProxy::getClassName   [virtual]
 

Get the class name of the corresponding object.

std::vector<std::string> InterfaceProxy::getRequiredNames   const [inline]
 

Get the names of all required variables in the interface.

std::vector<std::string> InterfaceProxy::getVariableNames   const [inline]
 

Get the names of all variables in the interface.

virtual bool InterfaceProxy::isStatic   const [inline, virtual]
 

Test if the object class of this interface is static.

Instances of static object classes are cached when loaded from a data archive and shared by all users of the object. See Object.h for details.

bool InterfaceProxy::isSubclass hasht const &    chash const
 

Test if this object interface is a subclass of the specified class.

This method is the same as isSubclass(std::string const &), but takes an object class hash instead of the class name.

Parameters:
chash  The class hash of an object class.
Returns:
True if the object class is a superclass.

bool InterfaceProxy::isSubclass std::string const &    cname const
 

Test if this object interface is a subclass of the specified class.

This method only checks the interface hierarchy of the object classes in question, not the full class hierarchy of the object. Non-object base classes will not test true, nor will object classes that do not extend the interface.

Parameters:
cname  The name of an object class.
Returns:
True if the object class is a superclass.

void InterfaceProxy::push_back Object   o,
std::string const &    varname,
const TypeAdapter   v
[inline]
 

Append a value to an interface variable list.

void InterfaceProxy::set Object   o,
std::string const &    varname,
const TypeAdapter   v
[inline]
 

Set the value of an interface variable.

void InterfaceProxy::set_enum Object   o,
std::string const &    varname,
std::string const &    v
[inline]
 

Assign an Enum value to an object member variable.

Parameters:
o  The object
varname  The name of the member variable.
v  The (string) value of the Enum.

bool InterfaceProxy::variableExists std::string const &    varname const [inline]
 

Test if a member variable is defined in the object interface.

bool InterfaceProxy::variableRequired std::string const &    varname const [inline]
 

Test if a member variable in the object interface must be assigned a value in XML Object definitions of the object.

std::string InterfaceProxy::variableType std::string const &    varname const [inline]
 

Get a string representation of the type of an interface variable.


The documentation for this class was generated from the following files:
SimData version pre-0.4.0. For more information on SimData, visit the SimData Homepage.

Generated on Tue Oct 14 12:06:41 2003, using Doxygen 1.2.18.

[SF.net]