00001 /* 00002 * This file is part of the "Archon" framework. 00003 * (http://files3d.sourceforge.net) 00004 * 00005 * Copyright © 2002 by Kristian Spangsege and Brian Kristiansen. 00006 * 00007 * Permission to use, copy, modify, and distribute this software and 00008 * its documentation under the terms of the GNU General Public License is 00009 * hereby granted. No representations are made about the suitability of 00010 * this software for any purpose. It is provided "as is" without express 00011 * or implied warranty. See the GNU General Public License 00012 * (http://www.gnu.org/copyleft/gpl.html) for more details. 00013 * 00014 * The characters in this file are ISO8859-1 encoded. 00015 * 00016 * The documentation in this file is in "Doxygen" style 00017 * (http://www.doxygen.org). 00018 */ 00019 00020 #ifndef ARCHON_X3D_SERVER_H 00021 #define ARCHON_X3D_SERVER_H 00022 00023 #include <list> 00024 #include <string> 00025 00026 #include <archon/util/logger.H> 00027 #include <archon/util/mutex.H> 00028 #include <archon/util/web_client.H> 00029 00030 #include <archon/x3d/server/scene.H> 00031 00032 namespace Archon 00033 { 00034 namespace X3D 00035 { 00036 using namespace std; 00037 using namespace Utilities; 00038 00039 // struct FontServer; 00040 00041 struct Server: virtual BackRefObjectBase 00042 { 00043 struct Listener: virtual BackRefObjectBase {}; 00044 00069 static Ref<Server> get(string name, double frameRate, Logger *logger, 00070 bool loadScene, Uri sceneUrl, bool progressiveLoad); 00071 00072 string getName() const; 00073 Logger *getLogger() const; 00074 00075 void setLoader(Ref<Loader>); 00076 Ref<Loader> getLoader() const; 00077 00078 /* 00079 void setFontServer(Ref<FontServer>); 00080 Ref<FontServer> getFontServer() const; 00081 */ 00082 00083 void setListener(Ref<Listener>); 00084 Ref<Listener> getListener() const; 00085 00086 void setRootScene(Ref<Scene>); 00087 Ref<Scene> getRootScene() const; 00088 00089 double getFrameRate() const { return frameRate; } 00090 00091 void print(string m) { logger->log(m); } 00092 00096 Ref<Scene> getRootSceneNoLock() { return rootScene; } 00097 00098 void setProgressiveLoad(bool); 00099 bool getProgressiveLoad() const; 00100 00101 // string dumpScenegraph(); 00102 00103 Time getNextTimeStamp(); 00104 00112 void tick(); 00113 00114 ~Server(); 00115 00158 const Mutex scenegraphMutex; 00159 00160 private: 00161 Server(string name, double frameRate, Logger *); 00162 00163 void refForwardDestroy(); 00164 00165 Mutex mutex; 00166 string name; 00167 Logger *logger; 00168 Ref<Loader> loader; 00169 //Ref<FontServer> fontServer; 00170 Ref<Listener> listener; 00171 Ref<Scene> rootScene; 00172 bool progressiveLoad; 00173 Time previousTimeStamp; 00174 double frameRate; 00175 00176 friend struct ExecutionContext; 00177 00185 Mutex contextsMutex; 00186 00225 list<ExecutionContext *> contexts; 00226 00227 void add(ExecutionContext *); 00228 void remove(ExecutionContext *); 00229 }; 00230 } 00231 } 00232 00233 #endif // ARCHON_X3D_SERVER_H