Line data Source code
1 :
2 : /* Copyright (c) 2012-2015, 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 "objectICommand.h"
22 :
23 : #include "buffer.h"
24 :
25 :
26 : namespace co
27 : {
28 : namespace detail
29 : {
30 :
31 : class ObjectICommand
32 : {
33 : public:
34 360002 : ObjectICommand()
35 360002 : : instanceID( CO_INSTANCE_INVALID )
36 360002 : {}
37 :
38 156 : ObjectICommand( const ObjectICommand& rhs )
39 : : objectID( rhs.objectID )
40 156 : , instanceID( rhs.instanceID )
41 156 : {}
42 :
43 : uint128_t objectID;
44 : uint32_t instanceID;
45 : };
46 : }
47 :
48 4 : ObjectICommand::ObjectICommand( LocalNodePtr local, NodePtr remote,
49 : ConstBufferPtr buffer, const bool swap_ )
50 : : ICommand( local, remote, buffer, swap_ )
51 4 : , _impl( new detail::ObjectICommand )
52 : {
53 4 : _init();
54 4 : }
55 :
56 359998 : ObjectICommand::ObjectICommand( const ICommand& command )
57 : : ICommand( command )
58 359998 : , _impl( new detail::ObjectICommand )
59 : {
60 359998 : _init();
61 359998 : }
62 :
63 156 : ObjectICommand::ObjectICommand( const ObjectICommand& rhs )
64 : : ICommand( rhs )
65 156 : , _impl( new detail::ObjectICommand( *rhs._impl ))
66 : {
67 156 : _init();
68 156 : }
69 :
70 360158 : void ObjectICommand::_init()
71 : {
72 360158 : if( isValid( ))
73 360157 : *this >> _impl->objectID >> _impl->instanceID;
74 360158 : }
75 :
76 720316 : ObjectICommand::~ObjectICommand()
77 : {
78 360158 : delete _impl;
79 360158 : }
80 :
81 612 : const uint128_t& ObjectICommand::getObjectID() const
82 : {
83 612 : return _impl->objectID;
84 : }
85 :
86 612 : uint32_t ObjectICommand::getInstanceID() const
87 : {
88 612 : return _impl->instanceID;
89 : }
90 :
91 0 : std::ostream& operator << ( std::ostream& os, const ObjectICommand& command )
92 : {
93 0 : os << static_cast< const ICommand& >( command );
94 0 : if( command.isValid( ))
95 : {
96 0 : os << " object " << command.getObjectID()
97 0 : << "." << command.getInstanceID();
98 : }
99 0 : return os;
100 : }
101 :
102 66 : }
|