client-cpp  0.0.1-SNAPSHOT
RemovedItemsDeltaType.hpp
Go to the documentation of this file.
1 /*
2  * Copyright 2014 CyberVision, Inc.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef REMOVEDITEMSDELTATYPE_HPP_
18 #define REMOVEDITEMSDELTATYPE_HPP_
19 
20 #include <list>
21 #include <sstream>
22 
25 
26 namespace kaa {
27 
29 public:
34 
39  : removedItemsStorage_(type.removedItemsStorage_) {}
40 
46  : removedItemsStorage_(items) {}
47 
54  virtual const RemovedItems& getRemovedItems() {
55  return removedItemsStorage_;
56  }
57 
62  virtual std::string toString() const;
63 
67  void addHandlerId(const DeltaHandlerId& item) {
68  removedItemsStorage_.push_back(item);
69  }
70 
71 private:
72  RemovedItems removedItemsStorage_;
73 };
74 
75 inline std::string RemovedItemsDeltaType::toString() const {
76  std::stringstream ss;
77  ss << "[ ";
78 
79  for (auto it = removedItemsStorage_.begin(); it != removedItemsStorage_.end();) {
80  ss << it->getHandlerId();
81 
82  if (++it != removedItemsStorage_.end()) {
83  ss << ", ";
84  }
85  }
86 
87  ss << " ]";
88  return ss.str();
89 }
90 
91 } /* namespace kaa */
92 
93 #endif /* REMOVEDITEMSDELTATYPE_HPP_ */
virtual const RemovedItems & getRemovedItems()
void addHandlerId(const DeltaHandlerId &item)
virtual std::string toString() const
RemovedItemsDeltaType(const RemovedItemsDeltaType &type)
std::list< DeltaHandlerId > RemovedItems
Definition: IDeltaType.hpp:38
RemovedItemsDeltaType(const RemovedItems &items)