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 "types.h"
23 : #include "visitorResult.h" // enum
24 : #include <eq/server/api.h>
25 :
26 : #include <co/commandQueue.h> // member
27 : #include <co/localNode.h> // base class
28 : #include <eq/fabric/server.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 46 : co::CommandQueue* getMainThreadQueue() { return &_mainThreadQueue; }
64 : /** @return the global time in milliseconds. */
65 4 : int64_t getTime() const { return _clock.getTime64(); }
66 : protected:
67 : virtual ~Server();
68 :
69 : private:
70 : /** The receiver->main command queue. */
71 : co::CommandQueue _mainThreadQueue;
72 :
73 : /** The global clock. */
74 : lunchbox::Clock _clock;
75 :
76 : co::Nodes _admins; //!< connected admin clients
77 :
78 : /** The current state. */
79 : bool _running;
80 :
81 : struct Private;
82 : Private* _private; // placeholder for binary-compatible changes
83 :
84 : friend class fabric::Config<Server, Config, Observer, Layout, Canvas,
85 : server::Node, ConfigVisitor>;
86 :
87 : /** The command functions. */
88 : bool _cmdChooseConfig(co::ICommand& command);
89 : bool _cmdReleaseConfig(co::ICommand& command);
90 : bool _cmdDestroyConfigReply(co::ICommand& command);
91 : bool _cmdShutdown(co::ICommand& command);
92 : bool _cmdMap(co::ICommand& command);
93 : bool _cmdUnmap(co::ICommand& command);
94 : };
95 : }
96 : }
97 : #endif // EQSERVER_SERVER_H
|