Line data Source code
1 :
2 : /* Copyright (c) 2007-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_OBJECTDATAISTREAM_H
22 : #define CO_OBJECTDATAISTREAM_H
23 :
24 : #include <co/dataIStream.h> // base class
25 : #include <co/iCommand.h> // member
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 533 : uint128_t getVersion() const override { return _version.get(); }
48 : uint128_t getPendingVersion() const;
49 :
50 6 : void waitReady() const { _version.waitNE(VERSION_INVALID); }
51 557206 : bool isReady() const { return _version != VERSION_INVALID; }
52 116 : size_t nRemainingBuffers() const override { return _commands.size(); }
53 : void reset() override;
54 :
55 : bool hasInstanceData() const;
56 :
57 : CO_API NodePtr getRemoteNode() const override;
58 : CO_API LocalNodePtr getLocalNode() const override;
59 :
60 : protected:
61 : bool getNextBuffer(CompressorInfo& compressor, uint32_t& nChunks,
62 : const void*& chunkData, uint64_t& size) override;
63 :
64 : private:
65 : typedef std::deque<ICommand> CommandDeque;
66 :
67 : /** All data commands for this istream. */
68 : CommandDeque _commands;
69 :
70 : ICommand _usedCommand; //!< Currently used buffer
71 :
72 : /** The object version associated with this input stream. */
73 : lunchbox::Monitor<uint128_t> _version;
74 :
75 185779 : void _setReady() { _version = getPendingVersion(); }
76 : void _reset();
77 :
78 371558 : LB_TS_VAR(_thread);
79 : };
80 : }
81 : #endif // CO_OBJECTDATAISTREAM_H
|