root/juggler/branches/1.0/Kernel/vjKernel.h

Revision 8789, 8.2 kB (checked in by patrickh, 7 years ago)

Copyright update.

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