Line data Source code
1 :
2 : /* Copyright (c) 2007-2013, Stefan Eilemann <eile@equalizergraphics.com>
3 : * 2012, 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_OBJECTDATAISTREAM_H
22 : #define CO_OBJECTDATAISTREAM_H
23 :
24 : #include <co/iCommand.h> // member
25 : #include <co/dataIStream.h> // base class
26 : #include <co/version.h> // enum
27 : #include <lunchbox/monitor.h> // member
28 : #include <lunchbox/thread.h> // member
29 :
30 : #include <deque>
31 :
32 : namespace co
33 : {
34 : /** The DataIStream for object data. */
35 : class ObjectDataIStream : public DataIStream
36 : {
37 : public:
38 : ObjectDataIStream();
39 : ObjectDataIStream( const ObjectDataIStream& rhs );
40 : virtual ~ObjectDataIStream();
41 :
42 : ObjectDataIStream& operator = ( const ObjectDataIStream& rhs );
43 :
44 : void addDataCommand( ObjectDataICommand command );
45 : size_t getDataSize() const;
46 :
47 539 : uint128_t getVersion() const override { return _version.get(); }
48 : uint128_t getPendingVersion() const;
49 :
50 12 : void waitReady() const { _version.waitNE( VERSION_INVALID ); }
51 538069 : bool isReady() const { return _version != VERSION_INVALID; }
52 :
53 116 : size_t nRemainingBuffers() const override { return _commands.size(); }
54 :
55 : void reset() override;
56 :
57 : bool hasInstanceData() const;
58 :
59 : CO_API NodePtr getRemoteNode() const override;
60 : CO_API LocalNodePtr getLocalNode() const override;
61 :
62 : protected:
63 : bool getNextBuffer( uint32_t& compressor, uint32_t& nChunks,
64 : const void** chunkData, uint64_t& size ) override;
65 :
66 : private:
67 : typedef std::deque< ICommand > CommandDeque;
68 :
69 : /** All data commands for this istream. */
70 : CommandDeque _commands;
71 :
72 : ICommand _usedCommand; //!< Currently used buffer
73 :
74 : /** The object version associated with this input stream. */
75 : lunchbox::Monitor< uint128_t > _version;
76 :
77 179402 : void _setReady() { _version = getPendingVersion(); }
78 : void _reset();
79 :
80 358804 : LB_TS_VAR( _thread );
81 : };
82 : }
83 : #endif //CO_OBJECTDATAISTREAM_H
|