Line data Source code
1 :
2 : /* Copyright (c) 2010-2015, Stefan Eilemann <eile@eyescale.ch>
3 : *
4 : * This library is free software; you can redistribute it and/or modify it under
5 : * the terms of the GNU Lesser General Public License version 2.1 as published
6 : * by the Free Software Foundation.
7 : *
8 : * This library is distributed in the hope that it will be useful, but WITHOUT
9 : * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
10 : * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
11 : * details.
12 : *
13 : * You should have received a copy of the GNU Lesser General Public License
14 : * along with this library; if not, write to the Free Software Foundation, Inc.,
15 : * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
16 : */
17 :
18 : #ifndef EQFABRIC_SERVER_H
19 : #define EQFABRIC_SERVER_H
20 :
21 : #include <co/types.h>
22 : #include <eq/fabric/api.h>
23 : #include <eq/fabric/nodeType.h> // for NODETYPE_EQ_SERVER enum
24 : #include <eq/fabric/types.h> // basic typedefs
25 :
26 : namespace eq
27 : {
28 : namespace fabric
29 : {
30 : /** Base co::Node class for a server. @sa eq::Server */
31 : template <class CL, class S, class CFG, class NF, class N, class V>
32 : class Server : public N
33 : {
34 : public:
35 : /** A reference-counted pointer to the client. */
36 : typedef lunchbox::RefPtr<CL> ClientPtr;
37 : /** A reference-counted const pointer to the client. */
38 : typedef lunchbox::RefPtr<const CL> ConstClientPtr;
39 : /** A vector of config pointers. */
40 : typedef std::vector<CFG*> Configs;
41 : /** The node factory. */
42 : typedef NF NodeFactory;
43 :
44 : virtual void setClient(ClientPtr client); //!< @internal
45 :
46 : /** @return the local client proxy. @version 1.0 */
47 111 : ClientPtr getClient() { return _client; }
48 : /** @return the local client proxy. @version 1.0 */
49 15 : ConstClientPtr getClient() const { return _client; }
50 : /** @return the vector of configurations. @version 1.0 */
51 2438 : const Configs& getConfigs() const { return _configs; }
52 : /**
53 : * Traverse this server and all children using a server visitor.
54 : *
55 : * @param visitor the visitor.
56 : * @return the result of the visitor traversal.
57 : * @version 1.0
58 : */
59 : EQFABRIC_INL VisitorResult accept(V& visitor);
60 :
61 : /** Const-version of accept(). @version 1.1.6 */
62 : EQFABRIC_INL VisitorResult accept(V& visitor) const;
63 :
64 : /** @internal @return the node factory. */
65 1526 : NF* getNodeFactory() { return _nodeFactory; }
66 : protected:
67 : /** @internal Construct a new server. */
68 : explicit Server(NF* nodeFactory);
69 :
70 : /** @internal Destruct this server. */
71 : virtual ~Server();
72 :
73 : /** @internal Add a new config to this server. */
74 : void _addConfig(CFG* config);
75 :
76 : /** @internal Remove a config from this server. */
77 : bool _removeConfig(CFG* config);
78 :
79 : private:
80 : NF* const _nodeFactory; //!< the factory to create all child instances
81 :
82 : /** The local client connected to the server */
83 : ClientPtr _client;
84 :
85 : /** The list of configurations. */
86 : Configs _configs;
87 :
88 : struct Private;
89 : Private* _private; // placeholder for binary-compatible changes
90 :
91 : template <class, class, class, class, class, class, class>
92 : friend class Config;
93 :
94 : /* The command handler functions. */
95 : bool _cmdCreateConfig(co::ICommand& command);
96 : bool _cmdDestroyConfig(co::ICommand& command);
97 : };
98 :
99 : template <class CL, class S, class CFG, class NF, class N, class V>
100 : EQFABRIC_INL std::ostream& operator<<(std::ostream&,
101 : const Server<CL, S, CFG, NF, N, V>&);
102 : }
103 : }
104 :
105 : #endif // EQFABRIC_SERVER_H
|