root/juggler/branches/1.0/Environment/vjEnvironmentManager.h

Revision 8789, 5.1 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_ENVIRONMENT_MANAGER_H_
36 #define _VJ_ENVIRONMENT_MANAGER_H_
37
38 #include <vjConfig.h>
39 #include <Kernel/vjConfigChunkHandler.h>
40 #include <Threads/vjThread.h>
41 #include <Environment/vjSocket.h>
42 #include <Sync/vjMutex.h>
43
44 class vjConnect;
45 class vjPerfDataBuffer;
46 class vjConfigChunkDB;
47
48
49 //-------------------------------------
50 //: Communications and configuration agent
51 //
52 //      The Environment Manager handles communications between
53 //      Juggler and UI elements.  This includes data logging and
54 //      interactive connections to the VR Juggler control program,
55 //      vjControl.
56 //      The EM's most important function is to communicate
57 //      configuration information and changes between the GUI and
58 //      the Kernel.  It is also the owner and manager of Juggler
59 //      Performance measurement code.
60 //      A near-future addition will be device status/data monitoring.
61 //
62 //      Which means that its main duties are:
63 //         - handle file and socket connections
64 //         - handle vjPerfDataBuffers
65 //
66 // @author  Christopher Just
67 //
68 // Date 2-27-98
69 //---------------------------------------
70
71 class vjEnvironmentManager: public vjConfigChunkHandler {
72
73 public:
74
75     //: constructor
76     //! PRE: None
77     //! POST: Object is constructed
78     vjEnvironmentManager();
79
80
81
82     virtual ~vjEnvironmentManager();
83
84
85
86     //: is the EM accepting connections across the network?
87     //! RETURNS: true - EM is accepting connections
88     //! RETURNS: false - EM is not accepting connections
89     bool isAccepting();
90
91
92
93     //: registers a buffer containing perf data...
94     void addPerfDataBuffer (vjPerfDataBuffer *v);
95
96
97     //: unregisters a buffer of perf data
98     void removePerfDataBuffer (vjPerfDataBuffer *v);
99
100
101
102     //: tells EM that a connection has died (ie by gui disconnecting)
103     void connectHasDied (vjConnect* con);
104
105
106     //: sends a 'refresh' message to all open connections
107     void sendRefresh();
108
109
110
111     //: ConfigChunkHandler stuff
112     //! PRE: configCanHandle(chunk) == true
113     //! RETURNS: success
114     virtual bool configAdd(vjConfigChunk* chunk);
115
116
117
118     //: Remove the chunk from the current configuration
119     //! PRE: configCanHandle(chunk) == true
120     //!RETURNS: success
121     virtual bool configRemove(vjConfigChunk* chunk);
122
123
124    
125     //: Can the handler handle the given chunk?
126     //! RETURNS: true - Can handle it
127     //+          false - Can't handle it
128     virtual bool configCanHandle(vjConfigChunk* chunk);
129
130
131
132 private:
133     std::string               perf_target_name;
134     std::vector<vjConnect*>   connections;
135     std::vector<vjPerfDataBuffer*> perf_buffers;
136     vjThread*                 listen_thread;
137     int                       Port;
138     vjSocket*                 listen_socket;
139     vjConnect*                perf_target;
140     float                     perf_refresh_time;  // in milliseconds
141     bool                      configured_to_accept;
142     vjConfigChunk*            current_perf_config;
143     vjMutex                   connections_mutex;
144     vjMutex                   perf_buffers_mutex;
145
146     // PRIVATE utility functions
147
148     void controlLoop (void* nullParam);
149
150     void activatePerfBuffers();
151     void deactivatePerfBuffers();
152
153     void setPerformanceTarget (vjConnect* con);
154
155     void removeConnect (vjConnect* con);
156
157     //: returns a pointer to a connection with the given name
158     vjConnect* getConnect (const std::string& _name);
159
160
161     //: allows the Environment Manager to accept connections.
162     //! RETURNS: reflects succesfully grabbing a port and listening.
163     bool acceptConnections();
164
165
166  
167     //: stop listening for client connections
168     //! PRE:  True
169     //! POST: no new connections are accepted. open connections
170     //+       are not changed.
171     bool rejectConnections();
172
173
174     //: Kills all open connections
175     void killConnections();
176
177
178
179 }; // end vjEnvironmentManager
180
181
182
183 #endif
Note: See TracBrowser for help on using the browser.