Collage  1.6.0
High-performance C++ library for developing object-oriented distributed applications.
iCommand.h
1 
2 /* Copyright (c) 2006-2016, Stefan Eilemann <eile@equalizergraphics.com>
3  * Daniel Nachbaur <danielnachbaur@gmail.com>
4  *
5  * This file is part of Collage <https://github.com/Eyescale/Collage>
6  *
7  * This library is free software; you can redistribute it and/or modify it under
8  * the terms of the GNU Lesser General Public License version 2.1 as published
9  * by the Free Software Foundation.
10  *
11  * This library is distributed in the hope that it will be useful, but WITHOUT
12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13  * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
14  * details.
15  *
16  * You should have received a copy of the GNU Lesser General Public License
17  * along with this library; if not, write to the Free Software Foundation, Inc.,
18  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19  */
20 
21 #ifndef CO_ICOMMAND_H
22 #define CO_ICOMMAND_H
23 
24 #include <co/api.h>
25 #include <co/commands.h> // for enum CommandType
26 #include <co/dataIStream.h> // base class
27 
28 
29 namespace co
30 {
31 namespace detail { class ICommand; }
32 
43 class ICommand : public DataIStream
44 {
45 public:
46  CO_API ICommand();
47  CO_API ICommand( LocalNodePtr local, NodePtr remote,
48  ConstBufferPtr buffer, const bool swap );
49  CO_API ICommand( const ICommand& rhs );
50 
51  CO_API virtual ~ICommand();
52 
53  CO_API ICommand& operator = ( const ICommand& rhs );
54 
55  CO_API void clear();
56 
60  CO_API uint32_t getType() const;
61 
63  CO_API uint32_t getCommand() const;
64 
66  CO_API uint64_t getSize() const;
67 
69  template< typename T > T get() { return read< T >(); }
70 
72  NodePtr getNode() const { return getRemoteNode(); }
73 
75  CO_API NodePtr getRemoteNode() const override;
76 
78  CO_API LocalNodePtr getLocalNode() const override;
79 
81  CO_API bool isValid() const;
82 
84  CO_API ConstBufferPtr getBuffer() const;
86 
90  CO_API void setType( const CommandType type );
91 
93  CO_API void setCommand( const uint32_t cmd );
94 
96  void setDispatchFunction( const Dispatcher::Func& func );
97 
99  CO_API bool operator()();
101 
102 private:
103  detail::ICommand* const _impl;
104 
105  friend CO_API std::ostream& operator << (std::ostream&,const ICommand&);
106 
109  CO_API size_t nRemainingBuffers() const override;
110  CO_API uint128_t getVersion() const override;
111  CO_API bool getNextBuffer( CompressorInfo&, uint32_t&, const void*&,
112  uint64_t& ) override;
114 
115  void _skipHeader();
116 };
117 
118 CO_API std::ostream& operator << ( std::ostream& os, const ICommand& );
119 }
120 #endif // CO_ICOMMAND_H
Defines export visibility macros for library Collage.
lunchbox::RefPtr< LocalNode > LocalNodePtr
A reference pointer for LocalNode pointers.
Definition: types.h:90
lunchbox::RefPtr< Node > NodePtr
A reference pointer for Node pointers.
Definition: types.h:86
Object-oriented network library.
Definition: barrier.h:27
NodePtr getNode() const
Definition: iCommand.h:72
A class managing received commands.
Definition: iCommand.h:43
A wrapper to register a function callback on an object instance.
Definition: commandFunc.h:38
A std::istream-like input data stream for binary data.
Definition: dataIStream.h:41
CommandType
The type of a Command.
Definition: commands.h:33