client-cpp  0.6.3
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 "kaa/KaaDefaults.hpp"
21 
22 #ifdef KAA_USE_CONFIGURATION
23 
24 #include <list>
25 #include <sstream>
26 
29 
30 namespace kaa {
31 
32 class RemovedItemsDeltaType : public EmptyDeltaType {
33 public:
37  RemovedItemsDeltaType() {}
38 
42  RemovedItemsDeltaType(const RemovedItemsDeltaType& type)
43  : removedItemsStorage_(type.removedItemsStorage_) {}
44 
49  RemovedItemsDeltaType(const RemovedItems& items)
50  : removedItemsStorage_(items) {}
51 
58  virtual const RemovedItems& getRemovedItems() {
59  return removedItemsStorage_;
60  }
61 
66  virtual std::string toString() const;
67 
71  void addHandlerId(const DeltaHandlerId& item) {
72  removedItemsStorage_.push_back(item);
73  }
74 
75 private:
76  RemovedItems removedItemsStorage_;
77 };
78 
79 inline std::string RemovedItemsDeltaType::toString() const {
80  std::stringstream ss;
81  ss << "[ ";
82 
83  for (auto it = removedItemsStorage_.begin(); it != removedItemsStorage_.end();) {
84  ss << it->getHandlerId();
85 
86  if (++it != removedItemsStorage_.end()) {
87  ss << ", ";
88  }
89  }
90 
91  ss << " ]";
92  return ss.str();
93 }
94 
95 } /* namespace kaa */
96 
97 #endif
98 
99 #endif /* REMOVEDITEMSDELTATYPE_HPP_ */