Line data Source code
1 :
2 : /* Copyright (c) 2012-2016, Daniel Nachbaur <danielnachbaur@gmail.com>
3 : * 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/data/CompressorInfo.h>
25 : #include <pression/data/Registry.h>
26 :
27 : namespace co
28 : {
29 : namespace detail
30 : {
31 :
32 395443 : class ObjectDataICommand
33 : {
34 : public:
35 395139 : ObjectDataICommand()
36 395139 : : version( 0, 0 )
37 : , datasize( 0 )
38 : , sequence( 0 )
39 : , chunks( 1 )
40 395139 : , isLast( false )
41 395139 : {}
42 :
43 : uint128_t version;
44 : uint64_t datasize;
45 : uint32_t sequence;
46 : std::string compressorName;
47 : uint32_t chunks;
48 : bool isLast;
49 : };
50 :
51 : }
52 :
53 395136 : ObjectDataICommand::ObjectDataICommand( const ICommand& command )
54 : : ObjectICommand( command )
55 395136 : , _impl( new detail::ObjectDataICommand )
56 : {
57 395136 : _init();
58 395136 : }
59 :
60 3 : ObjectDataICommand::ObjectDataICommand( LocalNodePtr local, NodePtr remote,
61 3 : 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 395291 : void ObjectDataICommand::_init()
77 : {
78 395291 : if( isValid( ))
79 395291 : *this >> _impl->version >> _impl->datasize >> _impl->sequence
80 790582 : >> _impl->isLast >> _impl->compressorName >> _impl->chunks;
81 395291 : }
82 :
83 790582 : ObjectDataICommand::~ObjectDataICommand()
84 : {
85 395291 : delete _impl;
86 395291 : }
87 :
88 394973 : uint128_t ObjectDataICommand::getVersion() const
89 : {
90 394973 : return _impl->version;
91 : }
92 :
93 197462 : uint32_t ObjectDataICommand::getSequence() const
94 : {
95 197462 : return _impl->sequence;
96 : }
97 :
98 169 : uint64_t ObjectDataICommand::getDataSize() const
99 : {
100 169 : return _impl->datasize;
101 : }
102 :
103 165 : CompressorInfo ObjectDataICommand::getCompressorInfo() const
104 : {
105 165 : return pression::data::Registry::getInstance().find( _impl->compressorName);
106 : }
107 :
108 165 : uint32_t ObjectDataICommand::getChunks() const
109 : {
110 165 : return _impl->chunks;
111 : }
112 :
113 197455 : bool ObjectDataICommand::isLast() const
114 : {
115 197455 : 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 : }
|