root/juggler/tags/1.0.5/Environment/vjEnvironmentManager.h

Revision 2828, 5.1 kB (checked in by patrickh, 8 years ago)

Updated the copyright to what ISU's lawyers decided they want now.
The vast majority of this was done using Kevin's auto-copyright.pl script
which definitely made this easier. All the copyright blocks now have
begin and end tags so that if and when we have to update the copyright
information again, it will be even simpler.

  • 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 by Iowa State University
4  *
5  * Original Authors:
6  *   Allen Bierbaum, Christopher Just,
7  *   Patrick Hartling, Kevin Meinert,
8  *   Carolina Cruz-Neira, Albert Baker
9  *
10  * This library is free software; you can redistribute it and/or
11  * modify it under the terms of the GNU Library General Public
12  * License as published by the Free Software Foundation; either
13  * version 2 of the License, or (at your option) any later version.
14  *
15  * This library is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
18  * Library General Public License for more details.
19  *
20  * You should have received a copy of the GNU Library General Public
21  * License along with this library; if not, write to the
22  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
23  * Boston, MA 02111-1307, USA.
24  *
25  * -----------------------------------------------------------------
26  * File:          $RCSfile$
27  * Date modified: $Date$
28  * Version:       $Revision$
29  * -----------------------------------------------------------------
30  *
31  *************** <auto-copyright.pl END do not edit this line> ***************/
32
33
34 #ifndef _VJ_ENVIRONMENT_MANAGER_H_
35 #define _VJ_ENVIRONMENT_MANAGER_H_
36
37 #include <vjConfig.h>
38 #include <Kernel/vjConfigChunkHandler.h>
39 #include <Threads/vjThread.h>
40 #include <Environment/vjSocket.h>
41 #include <Sync/vjMutex.h>
42
43 class vjConnect;
44 class vjPerfDataBuffer;
45 class vjConfigChunkDB;
46
47
48 //-------------------------------------
49 //: Communications and configuration agent
50 //
51 //      The Environment Manager handles communications between
52 //      Juggler and UI elements.  This includes data logging and
53 //      interactive connections to the VR Juggler control program,
54 //      vjControl.
55 //      The EM's most important function is to communicate
56 //      configuration information and changes between the GUI and
57 //      the Kernel.  It is also the owner and manager of Juggler
58 //      Performance measurement code.
59 //      A near-future addition will be device status/data monitoring.
60 //
61 //      Which means that its main duties are:
62 //         - handle file and socket connections
63 //         - handle vjPerfDataBuffers
64 //
65 // @author  Christopher Just
66 //
67 // Date 2-27-98
68 //---------------------------------------
69
70 class vjEnvironmentManager: public vjConfigChunkHandler {
71
72 public:
73
74     //: constructor
75     //! PRE: None
76     //! POST: Object is constructed
77     vjEnvironmentManager();
78
79
80
81     virtual ~vjEnvironmentManager();
82
83
84
85     //: is the EM accepting connections across the network?
86     //! RETURNS: true - EM is accepting connections
87     //! RETURNS: false - EM is not accepting connections
88     bool isAccepting();
89
90
91
92     //: registers a buffer containing perf data...
93     void addPerfDataBuffer (vjPerfDataBuffer *v);
94
95
96     //: unregisters a buffer of perf data
97     void removePerfDataBuffer (vjPerfDataBuffer *v);
98
99
100
101     //: tells EM that a connection has died (ie by gui disconnecting)
102     void connectHasDied (vjConnect* con);
103
104
105     //: sends a 'refresh' message to all open connections
106     void sendRefresh();
107
108
109
110     //: ConfigChunkHandler stuff
111     //! PRE: configCanHandle(chunk) == true
112     //! RETURNS: success
113     virtual bool configAdd(vjConfigChunk* chunk);
114
115
116
117     //: Remove the chunk from the current configuration
118     //! PRE: configCanHandle(chunk) == true
119     //!RETURNS: success
120     virtual bool configRemove(vjConfigChunk* chunk);
121
122
123    
124     //: Can the handler handle the given chunk?
125     //! RETURNS: true - Can handle it
126     //+          false - Can't handle it
127     virtual bool configCanHandle(vjConfigChunk* chunk);
128
129
130
131 private:
132     std::string               perf_target_name;
133     std::vector<vjConnect*>   connections;
134     std::vector<vjPerfDataBuffer*> perf_buffers;
135     vjThread*                 listen_thread;
136     int                       Port;
137     vjSocket*                 listen_socket;
138     vjConnect*                perf_target;
139     float                     perf_refresh_time;  // in milliseconds
140     bool                      configured_to_accept;
141     vjConfigChunk*            current_perf_config;
142     vjMutex                   connections_mutex;
143     vjMutex                   perf_buffers_mutex;
144
145     // PRIVATE utility functions
146
147     void controlLoop (void* nullParam);
148
149     void activatePerfBuffers();
150     void deactivatePerfBuffers();
151
152     void setPerformanceTarget (vjConnect* con);
153
154     void removeConnect (vjConnect* con);
155
156     //: returns a pointer to a connection with the given name
157     vjConnect* getConnect (const std::string& _name);
158
159
160     //: allows the Environment Manager to accept connections.
161     //! RETURNS: reflects succesfully grabbing a port and listening.
162     bool acceptConnections();
163
164
165  
166     //: stop listening for client connections
167     //! PRE:  True
168     //! POST: no new connections are accepted. open connections
169     //+       are not changed.
170     bool rejectConnections();
171
172
173     //: Kills all open connections
174     void killConnections();
175
176
177
178 }; // end vjEnvironmentManager
179
180
181
182 #endif
Note: See TracBrowser for help on using the browser.