Line data Source code
1 :
2 : /* Copyright (c) 2012, Daniel Nachbaur <danielnachbaur@gmail.com>
3 : * 2012-2013, Stefan.Eilemann@epfl.ch
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 : #include "objectDataICommand.h"
22 :
23 : #include "buffer.h"
24 : #include <pression/plugins/compressorTypes.h>
25 :
26 : namespace co
27 : {
28 : namespace detail
29 : {
30 :
31 : class ObjectDataICommand
32 : {
33 : public:
34 359059 : ObjectDataICommand()
35 : : version( 0, 0 )
36 : , datasize( 0 )
37 : , sequence( 0 )
38 : , compressor( EQ_COMPRESSOR_NONE )
39 : , chunks( 1 )
40 359059 : , isLast( false )
41 359059 : {}
42 :
43 : uint128_t version;
44 : uint64_t datasize;
45 : uint32_t sequence;
46 : uint32_t compressor;
47 : uint32_t chunks;
48 : bool isLast;
49 : };
50 :
51 : }
52 :
53 359056 : ObjectDataICommand::ObjectDataICommand( const ICommand& command )
54 : : ObjectICommand( command )
55 359056 : , _impl( new detail::ObjectDataICommand )
56 : {
57 359056 : _init();
58 359056 : }
59 :
60 3 : ObjectDataICommand::ObjectDataICommand( LocalNodePtr local, NodePtr remote,
61 : ConstBufferPtr buffer, const bool swap_ )
62 : : ObjectICommand( local, remote, buffer, swap_ )
63 3 : , _impl( new detail::ObjectDataICommand )
64 : {
65 3 : _init();
66 3 : }
67 :
68 :
69 152 : ObjectDataICommand::ObjectDataICommand( const ObjectDataICommand& rhs )
70 : : ObjectICommand( rhs )
71 152 : , _impl( new detail::ObjectDataICommand( *rhs._impl ))
72 : {
73 152 : _init();
74 152 : }
75 :
76 359211 : void ObjectDataICommand::_init()
77 : {
78 359211 : if( isValid( ))
79 359211 : *this >> _impl->version >> _impl->datasize >> _impl->sequence
80 718422 : >> _impl->isLast >> _impl->compressor >> _impl->chunks;
81 359211 : }
82 :
83 718422 : ObjectDataICommand::~ObjectDataICommand()
84 : {
85 359211 : delete _impl;
86 359211 : }
87 :
88 358893 : uint128_t ObjectDataICommand::getVersion() const
89 : {
90 358893 : return _impl->version;
91 : }
92 :
93 179422 : uint32_t ObjectDataICommand::getSequence() const
94 : {
95 179422 : return _impl->sequence;
96 : }
97 :
98 169 : uint64_t ObjectDataICommand::getDataSize() const
99 : {
100 169 : return _impl->datasize;
101 : }
102 :
103 165 : uint32_t ObjectDataICommand::getCompressor() const
104 : {
105 165 : return _impl->compressor;
106 : }
107 :
108 165 : uint32_t ObjectDataICommand::getChunks() const
109 : {
110 165 : return _impl->chunks;
111 : }
112 :
113 179415 : bool ObjectDataICommand::isLast() const
114 : {
115 179415 : return _impl->isLast;
116 : }
117 :
118 0 : std::ostream& operator << ( std::ostream& os, const ObjectDataICommand& command )
119 : {
120 0 : os << static_cast< const ObjectICommand& >( command );
121 0 : if( command.isValid( ))
122 : {
123 0 : os << " v" << command.getVersion() << " size " << command.getDataSize()
124 0 : << " seq " << command.getSequence() << " last " << command.isLast();
125 : }
126 0 : return os;
127 : }
128 :
129 66 : }
|