Collage  1.7.0
High-performance C++ library for developing object-oriented distributed applications.
iCommand.h
1 
2 /* Copyright (c) 2006-2017, 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 namespace co
29 {
30 namespace detail
31 {
32 class ICommand;
33 }
34 
45 class ICommand : public DataIStream
46 {
47 public:
48  CO_API ICommand();
49  CO_API ICommand(LocalNodePtr local, NodePtr remote,
50  ConstBufferPtr buffer);
51  CO_API ICommand(const ICommand& rhs);
52 
53  CO_API virtual ~ICommand();
54 
55  CO_API ICommand& operator=(const ICommand& rhs);
56 
57  CO_API void clear();
58 
62  CO_API uint32_t getType() const;
63 
65  CO_API uint32_t getCommand() const;
66 
68  CO_API uint64_t getSize() const;
69 
71  template <typename T>
72  T get()
73  {
74  return read<T>();
75  }
76 
78  NodePtr getNode() const { return getRemoteNode(); }
80  CO_API NodePtr getRemoteNode() const override;
81 
83  CO_API LocalNodePtr getLocalNode() const override;
84 
86  CO_API bool isValid() const;
87 
89  CO_API ConstBufferPtr getBuffer() const;
91 
95  CO_API void setType(const CommandType type);
96 
98  CO_API void setCommand(const uint32_t cmd);
99 
101  void setDispatchFunction(const Dispatcher::Func& func);
102 
104  CO_API bool operator()();
106 
107 private:
108  detail::ICommand* const _impl;
109 
110  friend CO_API std::ostream& operator<<(std::ostream&, const ICommand&);
111 
114  CO_API size_t nRemainingBuffers() const override;
115  CO_API uint128_t getVersion() const override;
116  CO_API bool getNextBuffer(CompressorInfo&, uint32_t&, const void*&,
117  uint64_t&) override;
119 
120  void _skipHeader();
121 };
122 
123 CO_API std::ostream& operator<<(std::ostream& os, const ICommand&);
124 }
125 #endif // CO_ICOMMAND_H
Defines export visibility macros for library Collage.
lunchbox::RefPtr< LocalNode > LocalNodePtr
A reference pointer for LocalNode pointers.
Definition: types.h:89
Object-oriented network library.
Definition: barrier.h:27
NodePtr getNode() const
Definition: iCommand.h:78
A class managing received commands.
Definition: iCommand.h:45
A wrapper to register a function callback on an object instance.
Definition: commandFunc.h:39
A std::istream-like input data stream for binary data.
Definition: dataIStream.h:45
CommandType
The type of a Command.
Definition: commands.h:32
lunchbox::RefPtr< Node > NodePtr
A reference pointer for Node pointers.
Definition: types.h:85