22 #include <boost/unordered_map.hpp> 45 messageDataType(messageDataType) {
66 if (!dataType.isValid()) {
69 std::vector<MessageType> messageTypes;
70 boost::unordered_map<std::string, size_t> definedTypes;
71 boost::unordered_map<size_t, std::set<size_t> > requiredTypes;
76 for (
size_t i = 0; i < messageTypes.size(); ++i)
77 definedTypes[messageTypes[i].getDataType()] = i;
79 for (
size_t i = 0; i < messageTypes.size(); ++i) {
86 std::istringstream stream(messageTypes[i].getDefinition());
89 while (std::getline(stream, line)) {
90 std::string memberName, memberType;
96 std::string memberPackage, plainMemberType;
102 if (memberPackage.empty()) {
103 if (plainMemberType ==
"Header")
104 memberPackage =
"std_msgs";
106 memberPackage = package;
108 memberType = memberPackage+
"/"+plainMemberType;
111 boost::unordered_map<std::string, size_t>::iterator it =
112 definedTypes.find(memberType);
114 if (it != definedTypes.end())
115 requiredTypes[i].insert(it->second);
120 std::list<size_t> typesToBeDefined;
121 typesToBeDefined.push_back(definedTypes[messageType.
getDataType()]);
123 while (!typesToBeDefined.empty()) {
124 size_t i = typesToBeDefined.back();
125 const std::set<size_t>& currentRequiredTypes = requiredTypes[i];
126 bool allRequiredTypesDefined =
true;
128 for (std::set<size_t>::const_iterator it = currentRequiredTypes.
129 begin(); it != currentRequiredTypes.end(); ++it) {
130 if (!registry.
getDataType(messageTypes[*it].getDataType()).
132 typesToBeDefined.push_back(*it);
133 allRequiredTypesDefined =
false;
139 if (allRequiredTypesDefined) {
141 messageTypes[i].getDefinition());
142 typesToBeDefined.pop_back();
173 messageType.
load(messageDataType);
185 for (
size_t i = 0; i < currentDataType.
getNumMembers(); ++i) {
187 currentDataType[i].getType());
189 if (currentDataType[i].getType().isMessage())
190 fill(currentDataType[i].getType(), currentCollection[i]);
204 messageDefinition.
write(stream);
Header file providing the MessageDefinition class interface.
variant_topic_tools::MessageDefinition messageDefinition
std::string getName(void *handle)
Header file providing the MessageDefinitionParser class interface.
Header file defining exceptions for the variant topic tools.
Header file providing the DataTypeRegistry class interface.
Header file providing the MessageDataType class interface.
Header file providing the MessageTypeParser class interface.
variant_topic_tools::MessageType messageType