Main Page | Modules | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members | Related Pages

IopcClassObjectContainer Class Reference

Container that contains all existing IopcClassObjectImpl-s. More...

#include <iopcClassObjectContainer.h>

List of all members.

Public Member Functions

 IopcClassObjectContainer ()
int initializeUsingMetadataLoader (const char *metadataLocation)
void loadClassIDs (Connection *connection, DatabaseSqlStatements *sqlStatements)
IopcClassObjectImplgetClassObject (const char *className)
IopcProtoBaseAdaptorgetProtoBaseAdaptor (const char *className)
IopcClassObjectImplgetClassObjectFromClassID (int classID)
const char * getProjectName ()

Protected Types

typedef std::map< CStdString,
typedef std::map< const FullClassInfo *,
IopcClassObjectImpl * > 
typedef std::map< int, IopcClassObjectImpl * > ClassIDMap

Static Protected Member Functions

void initializeIopcClassObjectImpl (const FullClassInfo *classInfo, const ClassHierarchy::TableInfoMap &tableInfoMap, const ConversionMap &conversionMap, IopcClassObjectImpl &classObject)
void initializeAttrInfo (const char *attributeName, const AttributeInfo *attribute, bool isInherited, AttrInfo &attrInfo)

Protected Attributes

ClassObjectsMap classObjectsMap
ClassIDMap classIDMap
CStdString projectName
bool initialized

Detailed Description

Container that contains all existing IopcClassObjectImpl-s.

The container is filled using MetadataLoader (initializeUsingMetadataLoader()) and is able to return appropriate IopcClassObjectImpl for given class name or class ID.

There is only one instance of this class in IOPC LIB - iopcClassObjectContainer.

To load metadata other way than from ClassHierarchy (which is now created by MetadataLoader) replace functions initializeUsingMetadataLoader(), initializeIopcClassObjectImpl() and initializeAttrInfo() with functions that will create IopcClassObjectImpl-s from the other source.

Member Typedef Documentation

typedef std::map<CStdString, IopcClassObjectImpl> IopcClassObjectContainer::ClassObjectsMap [protected]

Type of map classObjectsMap. Key = name of the class, value = corresponding IopcClassObjectImpl.

typedef std::map<const FullClassInfo *, IopcClassObjectImpl *> IopcClassObjectContainer::ConversionMap [protected]

Map used to convert FullClassInfo * to IopcClassObjectImpl *. Used in initializeIopcClassObjectImpl() function.

typedef std::map<int, IopcClassObjectImpl *> IopcClassObjectContainer::ClassIDMap [protected]

Class ID "index" on classObjectsMap. Key = class ID, value = pointer to corresponding IopcClassObjectImpl.

Constructor & Destructor Documentation

IopcClassObjectContainer::IopcClassObjectContainer  )  [inline]

Simple constructor.

Member Function Documentation

int IopcClassObjectContainer::initializeUsingMetadataLoader const char *  metadataLocation  ) 

Creates all needed IopcClassObjectImpl-s according to ClassHierarchy loaded by MetadataLoader (MetadataLoader::loadMetadata()). Then calls initializeIopcClassObjectImpl() on each object.

Correctness of the ClassHierarchy is checked and missing values generated (See ClassHierarchy::createInheritanceHierarchy(), ClassHierarchy::checkInheritanceHierarchy(), ClassHierarchy::generateMissingValues() and ClassHierarchy::generateTableInfoMap()).

metadataLocation See IopcLib::initialize() parameters.
0 if OK, non-zero in case of error.

void IopcClassObjectContainer::initializeIopcClassObjectImpl const FullClassInfo classInfo,
const ClassHierarchy::TableInfoMap tableInfoMap,
const ConversionMap conversionMap,
IopcClassObjectImpl classObject
[static, protected]

Initializes IopcClassObjectImpl according to given class information (classInfo and tableInfoMap).

For individual attributes AttrInfo structures are created, initialized by initializeAttrInfo() and added to the IopcClassObjectImpl object.

classInfo The class information.
tableInfoMap Informations about the table associated with the class.
conversionMap Map used to convert FullClassInfo * (used in classInfo) to IopcClassObjectImpl * (used in classObject).
classObject Class object to be initialized.

void IopcClassObjectContainer::initializeAttrInfo const char *  attributeName,
const AttributeInfo attribute,
bool  isInherited,
AttrInfo attrInfo
[static, protected]

Initializes AttrInfo (information about an attribute) using given parameters.

attributeName Name of the attribute.
attribute Information about the attribute from MetadataLoader.
isInherited Was the attribute declared in the class that is represented by the IopcClassObjectImpl object that contains this AttrInfo struct?
attrInfo AttrInfo struct to be initialized.

void IopcClassObjectContainer::loadClassIDs Connection connection,
DatabaseSqlStatements sqlStatements

Loads Class IDs (CIDs) from database.

Class ID is unique (inside one user project) identification of persistent class. These IDs together with names of persistent classes are stored in the database in "class ID table" (<project name>_CIDS). The class IDs are used when retrieving objects of specified type and when saving objects into database.

Therefore IOPC LIB needs to have the class ID for each class. This function loads them, and fills them into IopcClassObjectImpl::classID-s.

The function is called at the end of first Database::Connect() call using Database::afterConnectHandler set in IopcLib::initialize().

classIDMap is not initialized there but in the first getClassObjectFromClassID() call.
connection Correctly initialized Connection.
sqlStatements Object used to generate SQL statements.
0. It tells Database not to run Database::afterConnectHandler when Database::Connect() will be run for the next time.

IopcClassObjectImpl * IopcClassObjectContainer::getClassObject const char *  className  ) 

Returns appropriate IopcClassObjectImpl for given class name, NULL if not found.

IopcProtoBaseAdaptor * IopcClassObjectContainer::getProtoBaseAdaptor const char *  className  ) 

The same as getClassObject() but returns IopcClassObjectImpl::protoBaseAdaptor.

IopcClassObjectImpl * IopcClassObjectContainer::getClassObjectFromClassID int  classID  ) 

Gets IopcClassObjectImpl for given class ID.

Uses classIDMap, if it hasn't been initialized earlier initializes it (traverses classObjectsMap and fills classIDMap).

const char* IopcClassObjectContainer::getProjectName  )  [inline]

Returns name of current user's project.

Member Data Documentation

ClassObjectsMap IopcClassObjectContainer::classObjectsMap [protected]

Map - for given class name returns appropriate IopcClassObjectImpl.

ClassIDMap IopcClassObjectContainer::classIDMap [protected]

Map - for given class ID returns appropriate IopcClassObjectImpl.

See also:

CStdString IopcClassObjectContainer::projectName [protected]

Name of current user's project.

bool IopcClassObjectContainer::initialized [protected]

Has the container been initialized? (I.e. has initializeUsingMetadataLoader() successfully finished?).

The documentation for this class was generated from the following files:
Generated on Wed Aug 11 22:35:33 2004 for IOPC by Doxygen 1.3.6