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

core.h

Go to the documentation of this file.
00001 /* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*-
00002 
00003    this file is part of rcssserver3D
00004    Fri May 9 2003
00005    Copyright (C) 2002,2003 Koblenz University
00006    Copyright (C) 2003 RoboCup Soccer Server 3D Maintenance Group
00007    $Id: core.h,v 1.8 2005/12/04 17:50:36 rollmark Exp $
00008 
00009    This program is free software; you can redistribute it and/or modify
00010    it under the terms of the GNU General Public License as published by
00011    the Free Software Foundation; version 2 of the License.
00012 
00013    This program is distributed in the hope that it will be useful,
00014    but WITHOUT ANY WARRANTY; without even the implied warranty of
00015    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00016    GNU General Public License for more details.
00017 
00018    You should have received a copy of the GNU General Public License
00019    along with this program; if not, write to the Free Software
00020    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00021 */
00022 #ifndef ZEITGEIST_CORE_H
00023 #define ZEITGEIST_CORE_H
00024 
00025 #include <string>
00026 #include <list>
00027 #include <map>
00028 #include <boost/shared_ptr.hpp>
00029 #include <boost/weak_ptr.hpp>
00030 
00031 namespace salt
00032 {
00033 class SharedLibrary;
00034 }
00035 
00036 namespace zeitgeist
00037 {
00038 
00039 class Class;
00040 class Leaf;
00041 class Node;
00042 class FileServer;
00043 class LogServer;
00044 class ScriptServer;
00045 class CoreContext;
00046 class Object;
00047 class RandomServer;
00048 
00055 class Core
00056 {
00057 protected:
00058     //
00059     // types
00060     //
00061 
00065     struct CacheKey
00066     {
00067     public:
00069         boost::weak_ptr<Leaf> root;
00070 
00072         std::string path;
00073 
00074     public:
00075         CacheKey(boost::weak_ptr<Leaf> r, const std::string& p) : root(r), path(p) {};
00076         bool operator == (const CacheKey& key) const;
00077         bool operator < (const CacheKey& key) const;
00078     };
00079 
00083     typedef std::map<CacheKey, boost::weak_ptr<Leaf> > TPathCache;
00084 
00085     //
00086     // functions
00087     //
00088 public:
00089     Core();
00090     ~Core();
00091 
00096     void Construct(const boost::weak_ptr<Core>& self);
00097 
00100     void Desctruct();
00101 
00103     boost::shared_ptr<CoreContext> CreateContext();
00104 
00106     boost::shared_ptr<Object> New(const std::string& className);
00107 
00109     bool ExistsClass(const std::string& className);
00110 
00116     bool RegisterClassObject(const boost::shared_ptr<Class> &classObject, const std::string &subDir);
00117 
00123     bool RegisterClassObject(Class *classObject, const std::string &subDir);
00124 
00129     bool ImportBundle(const std::string& bundleName);
00130 
00132     const boost::shared_ptr<FileServer>& GetFileServer() const;
00133 
00135     const boost::shared_ptr<LogServer>& GetLogServer() const;
00136 
00138     const boost::shared_ptr<ScriptServer>& GetScriptServer() const;
00139 
00141     boost::shared_ptr<Leaf> GetRoot() const { return mRoot;  }
00142 
00144     boost::shared_ptr<Leaf> Get(const std::string &pathStr);
00145 
00149     boost::shared_ptr<Leaf> Get(const std::string &pathStr,
00150                                 const boost::shared_ptr<Leaf>& base);
00151 
00155     bool Test(const std::string &pathStr,
00156               const boost::shared_ptr<Leaf>& base);
00157 
00161     bool Test(const std::string &pathStr);
00162 
00166     boost::shared_ptr<Leaf> GetChild(const boost::shared_ptr<Leaf> &parent,
00167                                      const std::string &childName);
00168 
00170     void BindClass(const boost::shared_ptr<Class> &newClass) const;
00171 
00174     void GarbageCollectBundles();
00175 
00176 protected:
00180     boost::shared_ptr<Leaf> GetInternal(const std::string &pathStr,
00181                                         const boost::shared_ptr<Leaf>& base);
00182 
00183     //
00184     // members
00185     //
00186 private:
00187 
00189     boost::shared_ptr<Leaf>                 mRoot;
00190 
00192     boost::shared_ptr<Class>                mNodeClass;
00193 
00195     boost::shared_ptr<Class>                mClassClass;
00196 
00198     boost::shared_ptr<FileServer>   mFileServer;
00199 
00201     boost::shared_ptr<LogServer>    mLogServer;
00202 
00204     boost::shared_ptr<ScriptServer> mScriptServer;
00205 
00207     boost::shared_ptr<RandomServer> mRandomServer;
00208 
00210     boost::weak_ptr<Core>                   mSelf;
00211 
00238     std::list<boost::shared_ptr<salt::SharedLibrary> >      mBundles;
00239 
00241     TPathCache mPathCache;
00242 };
00243 
00244 } //namespace zeitgeist
00245 
00246 #endif //ZEITGEIST_CORE_H

Generated on Thu Apr 6 15:25:37 2006 for rcssserver3d by  doxygen 1.4.4