33 #include "../EventCollections.h"
35 #include "../protocol/Notification.h"
36 #include "../protocol/collections/EventsByScopeMap.pb.h"
46 EventsByScopeMapConverter::EventsByScopeMapConverter(
50 serializationConverters), deserializationConverters(
51 deserializationConverters), converter(
65 return "EventsByScopeMapConverter";
73 "Called with unsupported data type " + data.first);
76 boost::shared_ptr<EventsByScopeMap> dataMap = boost::static_pointer_cast<
79 boost::shared_ptr<protocol::collections::EventsByScopeMap> syncMap(
83 for (EventsByScopeMap::const_iterator mapIt = dataMap->begin();
84 mapIt != dataMap->end(); ++mapIt) {
86 protocol::collections::EventsByScopeMap::ScopeSet* scopeSet =
88 scopeSet->set_scope(mapIt->first.toString());
91 for (vector<EventPtr>::const_iterator eventIt = mapIt->second.begin();
92 eventIt != mapIt->second.end(); ++eventIt) {
101 make_pair(event->getType(),
event->getData()), wire);
103 protocol::Notification* notification =
104 scopeSet->add_notifications();
107 notification->set_data(wire);
115 rsc::runtime::typeName<
122 const string& wire) {
129 syncMap.ParseFromString(wire);
134 for (
int setCount = 0; setCount < syncMap.sets_size(); ++setCount) {
136 const protocol::collections::EventsByScopeMap::ScopeSet& scopeSet =
137 syncMap.sets(setCount);
141 for (
int notificationIndex = 0;
142 notificationIndex < scopeSet.notifications_size();
143 ++notificationIndex) {
146 const protocol::Notification& notification = scopeSet.notifications(
150 event->setScopePtr(scope);
154 notification.wire_schema(), notification.data());
155 event->setType(annotatedData.first);
156 event->setData(annotatedData.second);
159 annotatedData.first);
161 (*dataMap)[*scope].push_back(event);