Line data Source code
1 :
2 : /* Copyright (c) 2005-2014, Stefan Eilemann <eile@equalizergraphics.com>
3 : * 2010, Daniel Nachbaur <danielnachbaur@gmail.com>
4 : *
5 : * This library is free software; you can redistribute it and/or modify it under
6 : * the terms of the GNU Lesser General Public License version 2.1 as published
7 : * by the Free Software Foundation.
8 : *
9 : * This library is distributed in the hope that it will be useful, but WITHOUT
10 : * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11 : * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12 : * details.
13 : *
14 : * You should have received a copy of the GNU Lesser General Public License
15 : * along with this library; if not, write to the Free Software Foundation, Inc.,
16 : * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
17 : */
18 :
19 : #ifndef EQSERVER_SERVER_H
20 : #define EQSERVER_SERVER_H
21 :
22 : #include "api.h"
23 : #include "types.h"
24 : #include "visitorResult.h" // enum
25 :
26 : #include <eq/fabric/server.h> // base class
27 : #include <co/commandQueue.h> // member
28 : #include <co/localNode.h> // base class
29 : #include <lunchbox/clock.h> // member
30 :
31 : namespace eq
32 : {
33 : namespace server
34 : {
35 : /** The Equalizer server. */
36 : class Server : public fabric::Server< co::Node, Server, Config, NodeFactory,
37 : co::LocalNode, ServerVisitor >
38 : {
39 : public:
40 : /** Construct a new server. */
41 : EQSERVER_API Server();
42 :
43 : /** Initialize the server. */
44 : EQSERVER_API void init();
45 :
46 : /** De-initialize the server. */
47 : EQSERVER_API void exit();
48 :
49 : /** The actual main loop of server. */
50 : EQSERVER_API void handleCommands();
51 :
52 : /**
53 : * Run the server.
54 : *
55 : * Convenience function for init(), handleCommands() and exit().
56 : */
57 : EQSERVER_API void run();
58 :
59 : /** Delete all configs of this server (exit). */
60 : EQSERVER_API void deleteConfigs();
61 :
62 : /** @return the command queue to the server thread */
63 225 : co::CommandQueue* getMainThreadQueue() { return &_mainThreadQueue; }
64 :
65 : /** @return the global time in milliseconds. */
66 5 : int64_t getTime() const { return _clock.getTime64(); }
67 :
68 : protected:
69 : virtual ~Server();
70 :
71 : private:
72 : /** The receiver->main command queue. */
73 : co::CommandQueue _mainThreadQueue;
74 :
75 : /** The global clock. */
76 : lunchbox::Clock _clock;
77 :
78 : co::Nodes _admins; //!< connected admin clients
79 :
80 : /** The current state. */
81 : bool _running;
82 :
83 : struct Private;
84 : Private* _private; // placeholder for binary-compatible changes
85 :
86 : friend class fabric::Config< Server, Config, Observer, Layout, Canvas,
87 : server::Node, ConfigVisitor >;
88 :
89 : /** The command functions. */
90 : bool _cmdChooseConfig( co::ICommand& command );
91 : bool _cmdReleaseConfig( co::ICommand& command );
92 : bool _cmdDestroyConfigReply( co::ICommand& command );
93 : bool _cmdShutdown( co::ICommand& command );
94 : bool _cmdMap( co::ICommand& command );
95 : bool _cmdUnmap( co::ICommand& command );
96 : };
97 : }
98 : }
99 : #endif // EQSERVER_SERVER_H
|