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);
boost::shared_ptr< Scope > ScopePtr
std::pair< std::string, boost::shared_ptr< void > > AnnotatedData
A combination of data type and the actual data.
An exception indicating a serialization or deserialization problem for data.
void fillEvent(EventPtr event, const protocol::Notification ¬ification, VoidPtr data, const string &dataType)
Basic message that is exchanged between informers and listeners.
virtual ~EventsByScopeMapConverter()
Implementation of this interface perform mappings of one of the followings forms: ...
void fillNotificationId(protocol::Notification ¬ification, const EventPtr &event)
Fills the notification with minimal information required to identify it along several notifications s...
A generic converter for data types based on Protocol Buffer messages.
virtual std::string getWireSchema() const
Returns the name of the wire schema this converter can (de)serialize from/to.
ConverterSelectionStrategy< std::string >::Ptr deserializationConverters
std::map< rsb::Scope, std::vector< rsb::EventPtr > > EventsByScopeMap
AnnotatedData deserialize(const std::string &wireSchema, const std::string &wire)
Deserializes a domain object from a wire type.
std::string serialize(const AnnotatedData &data, std::string &wire)
Serialized the given domain object to the wire.
ConverterSelectionStrategy< std::string >::Ptr serializationConverters
boost::shared_ptr< Converter< WireType > > Ptr
virtual std::string serialize(const AnnotatedData &data, WireType &wire)=0
Serialized the given domain object to the wire.
std::string getClassName() const
virtual std::string getDataType() const
Returns the name of the data type this converter is applicable for.
virtual ConverterPtr getConverter(const std::string &key) const =0
Tries to look up the converter designator by key.
std::string getWireSchema() const
Returns the name of the wire schema this converter can (de)serialize from/to.
boost::shared_ptr< Event > EventPtr
Scope is a descriptor for a hierarchical channel of the unified bus.
Converter< std::string >::Ptr converter
void fillNotificationHeader(protocol::Notification ¬ification, const EventPtr &event, const string &wireSchema)
Fills a protocol::Notification with header contents.