Line data Source code
1 :
2 : /* Copyright (c) 2010-2013, 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 <eq/fabric/api.h>
22 : #include <eq/fabric/types.h> // basic typedefs
23 : #include <eq/fabric/nodeType.h> // for NODETYPE_EQ_SERVER enum
24 : #include <co/types.h>
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 14359 : ClientPtr getClient() { return _client; }
48 :
49 : /** @return the local client proxy. @version 1.0 */
50 122 : ConstClientPtr getClient() const { return _client; }
51 :
52 : /** @return the vector of configurations. @version 1.0 */
53 1504 : const Configs& getConfigs() const { return _configs; }
54 :
55 : /**
56 : * Traverse this server and all children using a server visitor.
57 : *
58 : * @param visitor the visitor.
59 : * @return the result of the visitor traversal.
60 : * @version 1.0
61 : */
62 : EQFABRIC_INL VisitorResult accept( V& visitor );
63 :
64 : /** Const-version of accept(). @version 1.1.6 */
65 : EQFABRIC_INL VisitorResult accept( V& visitor ) const;
66 :
67 : /** @internal @return the node factory. */
68 1026 : NF* getNodeFactory() { return _nodeFactory; }
69 :
70 : protected:
71 : /** @internal Construct a new server. */
72 : Server( NF* nodeFactory );
73 :
74 : /** @internal Destruct this server. */
75 : virtual ~Server();
76 :
77 : /** @internal Add a new config to this server. */
78 : void _addConfig( CFG* config );
79 :
80 : /** @internal Remove a config from this server. */
81 : bool _removeConfig( CFG* config );
82 :
83 : private:
84 : NF* const _nodeFactory; //!< the factory to create all child instances
85 :
86 : /** The local client connected to the server */
87 : ClientPtr _client;
88 :
89 : /** The list of configurations. */
90 : Configs _configs;
91 :
92 : struct Private;
93 : Private* _private; // placeholder for binary-compatible changes
94 :
95 : template< class, class, class, class, class, class, class >
96 : friend class Config;
97 :
98 : /* The command handler functions. */
99 : bool _cmdCreateConfig( co::ICommand& command );
100 : bool _cmdDestroyConfig( co::ICommand& command );
101 : };
102 :
103 : template< class CL, class S, class CFG, class NF, class N, class V >
104 : EQFABRIC_INL std::ostream&
105 : operator << ( std::ostream&, const Server< CL, S, CFG, NF, N, V >& );
106 : }
107 : }
108 :
109 : #endif // EQFABRIC_SERVER_H
|