root/juggler/tags/1.0.5/Kernel/vjKernel.h
| Revision 7539, 8.1 kB (checked in by anonymous, 7 years ago) | |
|---|---|
| |
| Line | |
|---|---|
| 1 | /*************** <auto-copyright.pl BEGIN do not edit this line> ************** * |
| 2 | * VR Juggler is (C) Copyright 1998, 1999, 2000 by Iowa State University |
| 3 | * |
| 4 | * Original Authors: |
| 5 | * Allen Bierbaum, Christopher Just, |
| 6 | * Patrick Hartling, Kevin Meinert, |
| 7 | * Carolina Cruz-Neira, Albert Baker |
| 8 | * |
| 9 | * This library is free software; you can redistribute it and/or |
| 10 | * modify it under the terms of the GNU Library General Public |
| 11 | * License as published by the Free Software Foundation; either |
| 12 | * version 2 of the License, or (at your option) any later version. |
| 13 | * |
| 14 | * This library is distributed in the hope that it will be useful, |
| 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 17 | * Library General Public License for more details. |
| 18 | * |
| 19 | * You should have received a copy of the GNU Library General Public |
| 20 | * License along with this library; if not, write to the |
| 21 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
| 22 | * Boston, MA 02111-1307, USA. |
| 23 | * |
| 24 | * ----------------------------------------------------------------- |
| 25 | * File: $RCSfile$ |
| 26 | * Date modified: $Date$ |
| 27 | * Version: $Revision$ |
| 28 | * ----------------------------------------------------------------- |
| 29 | * |
| 30 | *************** <auto-copyright.pl END do not edit this line> ***************/ |
| 31 | |
| 32 | |
| 33 | #ifndef _VJ_KERNEL_ |
| 34 | #define _VJ_KERNEL_ |
| 35 | //#pragma once |
| 36 | |
| 37 | #include <vjConfig.h> |
| 38 | #include <Kernel/vjApp.h> |
| 39 | class vjApp; |
| 40 | #include <Kernel/vjSystemFactory.h> |
| 41 | //#include <Kernel/vjAPIFactory.h> |
| 42 | #include <Kernel/vjDisplayManager.h> |
| 43 | #include <Kernel/vjDrawManager.h> |
| 44 | #include <Threads/vjThread.h> |
| 45 | #include <Kernel/vjDebug.h> |
| 46 | #include <Input/InputManager/vjInputManager.h> |
| 47 | #include <Kernel/vjSystemData.h> |
| 48 | #include <Performance/vjPerfDataBuffer.h> |
| 49 | #include <Kernel/vjUser.h> |
| 50 | #include <Sound/vjSoundManager.h> |
| 51 | |
| 52 | // Config stuff |
| 53 | //#include <Config/vjConfigChunkDB.h> |
| 54 | //#include <Config/vjChunkDescDB.h> |
| 55 | // #include <Kernel/vjQueuedConfigChunkHandler.h> |
| 56 | #include <Kernel/vjConfigChunkHandler.h> |
| 57 | #include <Utils/vjSingleton.h> |
| 58 | |
| 59 | class vjEnvironmentManager; |
| 60 | |
| 61 | //------------------------------------------------------- |
| 62 | //: Main control class for all vj applications. |
| 63 | // |
| 64 | // Takes care of all initialization and object creation |
| 65 | // for the system. |
| 66 | // This class is the only class that MUST be instantiated |
| 67 | // for all applications. |
| 68 | // |
| 69 | // @author Allen Bierbaum |
| 70 | // |
| 71 | // Date: 9-7-97 |
| 72 | //------------------------------------------------------- |
| 73 | //!PUBLIC_API: |
| 74 | class vjKernel : public vjConfigChunkHandler |
| 75 | { |
| 76 | public: |
| 77 | |
| 78 | //: Start the Kernel running |
| 79 | // Spawn kernel thread |
| 80 | int start(); |
| 81 | |
| 82 | //: Load initial configuration data for the managers |
| 83 | //! POST: InputManager, DisplayManager, and kernel |
| 84 | //+ Config files loaded and handed to configAdd |
| 85 | void initConfig(); |
| 86 | |
| 87 | //: The Kernel loop |
| 88 | void controlLoop(void* nullParam); |
| 89 | |
| 90 | // Set the application object for the Kernel to deal with |
| 91 | // If there is another app active, it has to stop that |
| 92 | // application first then restart all API specific Managers. |
| 93 | //! ARGS: _app - If NULL, stops current application |
| 94 | void setApplication(vjApp* _app); |
| 95 | |
| 96 | //: Load configuration data for Kernel |
| 97 | //! POST: Config data has been read into initial buffer |
| 98 | void loadConfigFile(std::string filename); |
| 99 | |
| 100 | //: Load a chunk description file |
| 101 | //! POST: The chunk factory can now manage chunks with the given types |
| 102 | void loadChunkDescFile(std::string filename); |
| 103 | |
| 104 | |
| 105 | protected: // -- CHUNK HANDLER |
| 106 | //: Can the handler handle the given chunk? |
| 107 | //! RETURNS: true - Can handle it |
| 108 | //+ false - Can't handle it |
| 109 | virtual bool configCanHandle(vjConfigChunk* chunk); |
| 110 | |
| 111 | //: Process any pending reconfiguration that we can deal with |
| 112 | // |
| 113 | // Process pending reconfiguration of the kernel and |
| 114 | // it's dependant managers (basically all of them |
| 115 | // that don't have a control thread) |
| 116 | // |
| 117 | // It just calls process pending for dependant processes |
| 118 | virtual int configProcessPending(bool lockIt = true); |
| 119 | |
| 120 | protected: // -- CHUNK HANDLER |
| 121 | //: Add the chunk to the configuration |
| 122 | //! PRE: configCanHandle(chunk) == true |
| 123 | //! RETURNS: success |
| 124 | virtual bool configAdd(vjConfigChunk* chunk); |
| 125 | |
| 126 | //: Remove the chunk from the current configuration |
| 127 | //! PRE: configCanHandle(chunk) == true |
| 128 | //!RETURNS: success |
| 129 | virtual bool configRemove(vjConfigChunk* chunk); |
| 130 | |
| 131 | protected: // Local config functions |
| 132 | //: Add a vjUser to the system |
| 133 | bool addUser(vjConfigChunk* chunk); |
| 134 | |
| 135 | //: Remove a vjUser from the system |
| 136 | //! NOTE: Currently not implemented |
| 137 | bool removeUser(vjConfigChunk* chunk); |
| 138 | |
| 139 | protected: |
| 140 | //: Updates any data that needs updated once a frame (Trackers, etc.) |
| 141 | //! POST: All tracker data is ready for next frame |
| 142 | void updateFrameData(); |
| 143 | |
| 144 | //: Checks to see if there is reconfiguration to be done |
| 145 | //! POST: Any reconfiguration needed has been completed |
| 146 | //! NOTE: Can only be called by the kernel thread |
| 147 | void checkForReconfig(); |
| 148 | |
| 149 | // Changes the application in use |
| 150 | // If there is another app active, it has to stop that |
| 151 | // application first then restart all API specific Managers. |
| 152 | //! ARGS: _app - If NULL, stops current application |
| 153 | //! NOTE: This can only be called from the kernel thread |
| 154 | void changeApplication(vjApp* _app); |
| 155 | |
| 156 | protected: // --- DRAW MGR ROUTINES --- // |
| 157 | // Starts the draw manager running |
| 158 | // Calls the app callbacks for the draw manager |
| 159 | //! ARGS: newMgr - Is this a new manager, or the same one |
| 160 | void startDrawManager(bool newMgr); |
| 161 | |
| 162 | // Stop the draw manager and close it's resources, then delete it |
| 163 | //! POST: draw mgr resources are closed |
| 164 | //+ draw mgr is deleted, display manger set to NULL draw mgr |
| 165 | void stopDrawManager(); |
| 166 | |
| 167 | public: // Global "get" interface |
| 168 | |
| 169 | //: Get the system Factory |
| 170 | vjSystemFactory* getSysFactory() |
| 171 | { return mSysFactory; } |
| 172 | |
| 173 | //: Get the input manager |
| 174 | vjInputManager* getInputManager() |
| 175 | { return mInputManager; } |
| 176 | |
| 177 | //: Get the Environment Manager |
| 178 | |
| 179 | vjEnvironmentManager* getEnvironmentManager() |
| 180 | { return environmentManager; } |
| 181 | |
| 182 | vjSoundManager* getSoundManager() |
| 183 | { return mSoundManager; } |
| 184 | |
| 185 | //: Get the user associated with given name |
| 186 | //! RETURNS: NULL - Not found |
| 187 | vjUser* getUser(std::string userName); |
| 188 | |
| 189 | //: Get a list of the users back |
| 190 | std::vector<vjUser*> getUsers() |
| 191 | { return mUsers; } |
| 192 | |
| 193 | const vjBaseThread* getThread() |
| 194 | { return mControlThread; } |
| 195 | |
| 196 | private: |
| 197 | vjSystemData data; //: Global system data |
| 198 | |
| 199 | protected: |
| 200 | vjApp* mApp; //: The app object |
| 201 | vjApp* mNewApp; //: New application to set |
| 202 | bool mNewAppSet; //: Flag to notify that a new application should be set |
| 203 | |
| 204 | vjBaseThread* mControlThread; //: The thread in control of me. |
| 205 | |
| 206 | /// Factories and Managers |
| 207 | vjSystemFactory* mSysFactory; //: The current System factory |
| 208 | vjInputManager* mInputManager; //: The input manager for the system |
| 209 | vjDrawManager* mDrawManager; //: The Draw Manager we are currently using |
| 210 | vjDisplayManager* mDisplayManager; //: The Display Manager we are currently using |
| 211 | vjEnvironmentManager* environmentManager; //: The Environment Manager object |
| 212 | vjSoundManager* mSoundManager; |
| 213 | |
| 214 | /// Performance information |
| 215 | vjPerfDataBuffer* perfBuffer; //: store perfdata for kernel main |
| 216 | bool performanceEnabled; |
| 217 | |
| 218 | /// Config Stuff |
| 219 | //**//vjChunkDescDB* mConfigDesc; |
| 220 | //**//vjConfigChunkDB* mChunkDB; //: The current chunk db for the system |
| 221 | //**//vjConfigChunkDB* mInitialChunkDB; //: Initial chunks added to system before it is started |
| 222 | //vjSemaphore mRuntimeConfigSema; //: Protects run-time config. Only when this semaphore |
| 223 | //+ is acquired can run-time config occur |
| 224 | /// Shared Memory stuff |
| 225 | vjMemPool* sharedMemPool; |
| 226 | |
| 227 | /// Multi-user information |
| 228 | std::vector<vjUser*> mUsers; //: A list of user objects in system |
| 229 | |
| 230 | // ----------------------- // |
| 231 | // --- SINGLETON STUFF --- // |
| 232 | // ----------------------- // |
| 233 | protected: |
| 234 | //: Constructor: Hidden, so no instantiation is allowed |
| 235 | vjKernel(); |
| 236 | |
| 237 | virtual ~vjKernel() |
| 238 | {;} |
| 239 | |
| 240 | vjSingletonHeader( vjKernel ); |
| 241 | }; |
| 242 | |
| 243 | |
| 244 | #endif |
Note: See TracBrowser for help on using the browser.
