Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members

zeitgeist::Core Class Reference

The Core is the hierarchy, i.e. More...

#include <core.h>

List of all members.

Public Member Functions

 Core ()
 Create the fundamental classes needed for the hierarchy to operate.
 ~Core ()
void Construct (const boost::weak_ptr< Core > &self)
 Constructs the core, i.e.
void Desctruct ()
 Destructs the core, i.e.
boost::shared_ptr< CoreContextCreateContext ()
 creates a context for this Core
boost::shared_ptr< ObjectNew (const std::string &className)
 creates an instance of the class 'className'
bool ExistsClass (const std::string &className)
 returns true iff the given class exists
bool RegisterClassObject (const boost::shared_ptr< Class > &classObject, const std::string &subDir)
 registers a class object
bool RegisterClassObject (Class *classObject, const std::string &subDir)
 registers a class object
bool ImportBundle (const std::string &bundleName)
 imports a bundle, i.e.
const boost::shared_ptr< FileServer > & GetFileServer () const
 returns a reference to the FileServer
const boost::shared_ptr< LogServer > & GetLogServer () const
 returns a reference to the LogServer
const boost::shared_ptr< ScriptServer > & GetScriptServer () const
 returns a reference to the ScriptServer
boost::shared_ptr< LeafGetRoot () const
 returns a reference to the root node
boost::shared_ptr< LeafGet (const std::string &pathStr)
 returns a reference to the object denoted by the path expression 'pathStr'.
boost::shared_ptr< LeafGet (const std::string &pathStr, const boost::shared_ptr< Leaf > &base)
 returns a reference to the object denoted by the path expression 'pathStr', relative to the node base.
bool Test (const std::string &pathStr, const boost::shared_ptr< Leaf > &base)
 returns true iff the object denoted by the path expression 'pathStr', relative to the node base exists
bool Test (const std::string &pathStr)
 returns true iff the object denoted by the path expression 'pathStr' exists.
boost::shared_ptr< LeafGetChild (const boost::shared_ptr< Leaf > &parent, const std::string &childName)
 returns a reference to a child node of 'parent' with the name 'childName'
void BindClass (const boost::shared_ptr< Class > &newClass) const
 attaches the class 'newClass' to this core
void GarbageCollectBundles ()
 releases all unused bundles, i.e.

Protected Types

typedef std::map< CacheKey,
boost::weak_ptr< Leaf > > 
TPathCache
 TPathCache defines a mapping from a CacheKey to a weak reference of the corresponding Leaf.

Protected Member Functions

boost::shared_ptr< LeafGetInternal (const std::string &pathStr, const boost::shared_ptr< Leaf > &base)
 returns a reference to the object denoted by the path expression 'pathStr', relative to the node base.

Private Attributes

boost::shared_ptr< LeafmRoot
 a reference to the root node
boost::shared_ptr< ClassmNodeClass
 a reference to the class object of the node class
boost::shared_ptr< ClassmClassClass
 a reference to the class object of the 'class' class
boost::shared_ptr< FileServermFileServer
 a reference to the file server
boost::shared_ptr< LogServermLogServer
 a reference to the logserver
boost::shared_ptr< ScriptServermScriptServer
 a reference to the scriptserver
boost::shared_ptr< RandomServermRandomServer
 a reference to the randomserver
boost::weak_ptr< CoremSelf
 a reference to the core, a smart this pointer
std::list< boost::shared_ptr<
salt::SharedLibrary > > 
mBundles
 a list of all registered bundles.
TPathCache mPathCache
 the internal node lookup cache

Classes

struct  CacheKey
 CacheKey is a struct used as the key for the internal node lookup cache. More...


Detailed Description

The Core is the hierarchy, i.e.

it creates the root node, some basic class objects and installs fundamental server classes needed to run zeitgeist system. Further it provides a mechanism to import bundles- plugins containg new classes, that can be registered to the framework at runtime.

Definition at line 55 of file core.h.


Member Typedef Documentation

typedef std::map<CacheKey, boost::weak_ptr<Leaf> > zeitgeist::Core::TPathCache [protected]
 

TPathCache defines a mapping from a CacheKey to a weak reference of the corresponding Leaf.

Definition at line 83 of file core.h.


Constructor & Destructor Documentation

Core::Core  ) 
 

Create the fundamental classes needed for the hierarchy to operate.

Definition at line 90 of file core.cpp.

References CLASS, and mClassClass.

Core::~Core  ) 
 

Definition at line 96 of file core.cpp.

References mBundles.


Member Function Documentation

void Core::BindClass const boost::shared_ptr< Class > &  newClass  )  const
 

attaches the class 'newClass' to this core

Definition at line 382 of file core.cpp.

References mClassClass, and mSelf.

Referenced by Construct(), and RegisterClassObject().

void Core::Construct const boost::weak_ptr< Core > &  self  ) 
 

Constructs the core, i.e.

sets up the root object, registers some class objects for internal zeitgeist classes and creates servers for the basic services

Definition at line 101 of file core.cpp.

References BindClass(), CLASS, CreateContext(), zeitgeist::LogServer::eError, zeitgeist::LogServer::eNormal, zeitgeist::LogServer::eWarning, mClassClass, mFileServer, mLogServer, mNodeClass, mRandomServer, mRoot, mScriptServer, mSelf, and RegisterClassObject().

Here is the call graph for this function:

boost::shared_ptr< CoreContext > Core::CreateContext  ) 
 

creates a context for this Core

Definition at line 164 of file core.cpp.

References GetRoot(), and mSelf.

Referenced by Construct(), New(), and RegisterClassObject().

Here is the call graph for this function:

void Core::Desctruct  ) 
 

Destructs the core, i.e.

unlinks the hierarchy below the root object

Definition at line 150 of file core.cpp.

References mClassClass, mFileServer, mLogServer, mNodeClass, mRandomServer, mRoot, and mScriptServer.

bool Core::ExistsClass const std::string &  className  ) 
 

returns true iff the given class exists

Definition at line 193 of file core.cpp.

References Test().

Here is the call graph for this function:

void Core::GarbageCollectBundles  ) 
 

releases all unused bundles, i.e.

bundles the core holds the only reference to

Definition at line 397 of file core.cpp.

References mBundles.

boost::shared_ptr< Leaf > Core::Get const std::string &  pathStr,
const boost::shared_ptr< Leaf > &  base
 

returns a reference to the object denoted by the path expression 'pathStr', relative to the node base.

Definition at line 331 of file core.cpp.

References GetInternal(), and mLogServer.

Here is the call graph for this function:

boost::shared_ptr< Leaf > Core::Get const std::string &  pathStr  ) 
 

returns a reference to the object denoted by the path expression 'pathStr'.

Definition at line 326 of file core.cpp.

References mRoot.

boost::shared_ptr< Leaf > Core::GetChild const boost::shared_ptr< Leaf > &  parent,
const std::string &  childName
 

returns a reference to a child node of 'parent' with the name 'childName'

Definition at line 357 of file core.cpp.

References mNodeClass.

const boost::shared_ptr< FileServer > & Core::GetFileServer  )  const
 

returns a reference to the FileServer

Definition at line 257 of file core.cpp.

References mFileServer.

boost::shared_ptr< Leaf > Core::GetInternal const std::string &  pathStr,
const boost::shared_ptr< Leaf > &  base
[protected]
 

returns a reference to the object denoted by the path expression 'pathStr', relative to the node base.

Definition at line 272 of file core.cpp.

References salt::Path::Front(), salt::Path::IsAbsolute(), salt::Path::IsEmpty(), mPathCache, mRoot, and salt::Path::PopFront().

Referenced by Get(), and Test().

Here is the call graph for this function:

const boost::shared_ptr< LogServer > & Core::GetLogServer  )  const
 

returns a reference to the LogServer

Definition at line 262 of file core.cpp.

References mLogServer.

boost::shared_ptr<Leaf> zeitgeist::Core::GetRoot  )  const [inline]
 

returns a reference to the root node

Definition at line 141 of file core.h.

References mRoot.

Referenced by CreateContext().

const boost::shared_ptr< ScriptServer > & Core::GetScriptServer  )  const
 

returns a reference to the ScriptServer

Definition at line 267 of file core.cpp.

References mScriptServer.

bool Core::ImportBundle const std::string &  bundleName  ) 
 

imports a bundle, i.e.

registers classes contained inside a plugin to the framework.

Parameters:
bundleName is the filneName of the bundle

Definition at line 212 of file core.cpp.

References mBundles, mLogServer, and RegisterClassObject().

Here is the call graph for this function:

boost::shared_ptr< Object > Core::New const std::string &  className  ) 
 

creates an instance of the class 'className'

Definition at line 170 of file core.cpp.

References CreateContext(), and mLogServer.

Here is the call graph for this function:

bool Core::RegisterClassObject Class classObject,
const std::string &  subDir
 

registers a class object

Parameters:
classObject is a reference to instance of the class object
subDir gives the directory below "/classes" where the class object will be installed

Definition at line 207 of file core.cpp.

References RegisterClassObject().

Here is the call graph for this function:

bool Core::RegisterClassObject const boost::shared_ptr< Class > &  classObject,
const std::string &  subDir
 

registers a class object

Parameters:
classObject is a reference to instance of the class object
subDir gives the directory below "/classes" where the class object will be installed

Definition at line 198 of file core.cpp.

References BindClass(), and CreateContext().

Referenced by Construct(), ImportBundle(), and RegisterClassObject().

Here is the call graph for this function:

bool Core::Test const std::string &  pathStr  ) 
 

returns true iff the object denoted by the path expression 'pathStr' exists.

Definition at line 345 of file core.cpp.

References mRoot, and Test().

Here is the call graph for this function:

bool Core::Test const std::string &  pathStr,
const boost::shared_ptr< Leaf > &  base
 

returns true iff the object denoted by the path expression 'pathStr', relative to the node base exists

Definition at line 350 of file core.cpp.

References GetInternal().

Referenced by ExistsClass(), and Test().

Here is the call graph for this function:


Member Data Documentation

std::list<boost::shared_ptr<salt::SharedLibrary> > zeitgeist::Core::mBundles [private]
 

a list of all registered bundles.

Whenever we load a bundle, we add it to this list. This is necessary, because we have to keep the connection to each bundle open, until all the class objects belonging to it are completely destructed.

This workaround is very ugly ... it cost me about 3-4 hours of debugging to get this to work. Somehow, when I destroyed a class belonging to a bundle, it prevented the rest of the hierarchy deletion from working ... ouch. I have no idea, why this happened. Now, when I keep the bundles (DLLs,SOs) open for a while longer, then everything is nice and dandy.

NOTE: I had this first as a member of Core, but I can't control the order in which the members are released and I would have to guarantee that gBundles gets deleted AFTER mRoot. Switching the order the variables are defined would probably take care of that, but sounds quite unportable, so I went with this option (making it global). I have added a 'GarbageCollectBundles' function, which erases 'unique' references.

WARNING: Just making this global is (apparently) not enough.

Definition at line 238 of file core.h.

Referenced by GarbageCollectBundles(), ImportBundle(), and ~Core().

boost::shared_ptr<Class> zeitgeist::Core::mClassClass [private]
 

a reference to the class object of the 'class' class

Definition at line 195 of file core.h.

Referenced by BindClass(), Construct(), Core(), and Desctruct().

boost::shared_ptr<FileServer> zeitgeist::Core::mFileServer [private]
 

a reference to the file server

Definition at line 198 of file core.h.

Referenced by Construct(), Desctruct(), and GetFileServer().

boost::shared_ptr<LogServer> zeitgeist::Core::mLogServer [private]
 

a reference to the logserver

Definition at line 201 of file core.h.

Referenced by Construct(), Desctruct(), Get(), GetLogServer(), ImportBundle(), and New().

boost::shared_ptr<Class> zeitgeist::Core::mNodeClass [private]
 

a reference to the class object of the node class

Definition at line 192 of file core.h.

Referenced by Construct(), Desctruct(), and GetChild().

TPathCache zeitgeist::Core::mPathCache [private]
 

the internal node lookup cache

Definition at line 241 of file core.h.

Referenced by GetInternal().

boost::shared_ptr<RandomServer> zeitgeist::Core::mRandomServer [private]
 

a reference to the randomserver

Definition at line 207 of file core.h.

Referenced by Construct(), and Desctruct().

boost::shared_ptr<Leaf> zeitgeist::Core::mRoot [private]
 

a reference to the root node

Definition at line 189 of file core.h.

Referenced by Construct(), Desctruct(), Get(), GetInternal(), GetRoot(), and Test().

boost::shared_ptr<ScriptServer> zeitgeist::Core::mScriptServer [private]
 

a reference to the scriptserver

Definition at line 204 of file core.h.

Referenced by Construct(), Desctruct(), and GetScriptServer().

boost::weak_ptr<Core> zeitgeist::Core::mSelf [private]
 

a reference to the core, a smart this pointer

Definition at line 210 of file core.h.

Referenced by BindClass(), Construct(), and CreateContext().


The documentation for this class was generated from the following files:
Generated on Thu Apr 6 15:50:02 2006 for rcssserver3d by  doxygen 1.4.4