00001 #ifndef __INSTANTIO_ROOT_H
00002 #define __INSTANTIO_ROOT_H
00003
00004 #ifdef _MSC_VER
00005 # pragma once
00006 #endif
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #include "InstantIODef.h"
00027 #include "Namespace.h"
00028 #include <iostream>
00029 #include <vector>
00030 #include <cstdlib>
00031 namespace Medusa
00032 {
00033
00034 class Mutex;
00035 class DynamicLibrary;
00036 }
00037 #ifdef _MSC_VER
00038 # pragma warning (push)
00039 # pragma warning (disable: 4251)
00040 #endif
00041
00042
00043 namespace InstantIO
00044 {
00045
00046
00071 class INSTANTIO_DLLMAPPING Root: public Namespace
00072 {
00073 friend class NodeType;
00074
00075 public:
00076
00081 class INSTANTIO_DLLMAPPING ReadLock
00082 {
00083 public:
00084
00088 inline ReadLock()
00089 { Root::the().readLock(); }
00090
00094 inline ~ReadLock()
00095 { Root::the().unlock(); }
00096
00097 private:
00098
00100 ReadLock(const ReadLock &);
00101
00103 const ReadLock &operator=(const ReadLock &);
00104 };
00105
00110 class INSTANTIO_DLLMAPPING WriteLock
00111 {
00112 public:
00113
00117 inline WriteLock()
00118 { Root::the().writeLock(); }
00119
00123 inline ~WriteLock()
00124 { Root::the().unlock(); }
00125
00126 private:
00127
00129 WriteLock(const WriteLock &);
00130
00132 const WriteLock &operator=(const WriteLock &);
00133 };
00134
00138 virtual ~Root();
00139
00144 static inline Root &the()
00145 {
00146 if (initialized_ == false) {
00147 std::cerr << "FATAL: Accessed InstantIO::Root that is not initialized!" << std::endl;
00148 abort();
00149 }
00150 return the_;
00151 }
00152
00154 void readLock();
00155
00157 void writeLock();
00158
00160 void unlock();
00161
00171 Namespace *getNamespaceFromPath(const std::string &ns)
00172 ;
00173
00174 protected:
00175
00177 Root();
00178
00179 private:
00180
00182 Root(const Root &);
00183
00185 const Root &operator=(const Root &);
00186
00188 static bool initialized_;
00189
00191 static Root the_;
00192
00194
00195 Medusa::Mutex *mutex_;
00196
00198 typedef std::vector<Medusa::DynamicLibrary*> PluginVector;
00199
00201 PluginVector plugins_;
00202 };
00203
00204
00205 }
00206
00207
00208 #ifdef _MSC_VER
00209 # pragma warning (pop)
00210 #endif
00211
00212 #endif // __INSTANTIO_ROOT_H