diff --git a/include/fastrtps/xmlparser/XMLProfileManager.h b/include/fastrtps/xmlparser/XMLProfileManager.h index 5b30b97bf16..6cceb810d24 100644 --- a/include/fastrtps/xmlparser/XMLProfileManager.h +++ b/include/fastrtps/xmlparser/XMLProfileManager.h @@ -28,22 +28,20 @@ #include #include - - -namespace eprosima{ -namespace fastrtps{ -namespace xmlparser{ - -typedef std::map participant_map_t; -typedef participant_map_t::iterator part_map_iterator_t; -typedef std::map publisher_map_t; -typedef publisher_map_t::iterator publ_map_iterator_t; -typedef std::map subscriber_map_t; -typedef subscriber_map_t::iterator subs_map_iterator_t; -typedef std::map topic_map_t; -typedef topic_map_t::iterator topic_map_iterator_t; -typedef std::map xmlfiles_map_t; -typedef xmlfiles_map_t::iterator xmlfile_map_iterator_t; +namespace eprosima { +namespace fastrtps { +namespace xmlparser { + +using participant_map_t = std::map; +using part_map_iterator_t = participant_map_t::iterator; +using publisher_map_t = std::map; +using publ_map_iterator_t = publisher_map_t::iterator; +using subscriber_map_t = std::map; +using subs_map_iterator_t = subscriber_map_t::iterator; +using topic_map_t = std::map; +using topic_map_iterator_t = topic_map_t::iterator; +using xmlfiles_map_t = std::map; +using xmlfile_map_iterator_t = xmlfiles_map_t::iterator; /** @@ -52,193 +50,212 @@ typedef xmlfiles_map_t::iterator xmlfile_map_iterator_t; */ class XMLProfileManager { - public: - /** - * Load the default profiles XML file. - * @return XMLP_ret::XML_OK on success, XMLP_ret::XML_ERROR in other case. - */ - RTPS_DllAPI static void loadDefaultXMLFile(); - - /** - * Load a profiles XML file. - * @param filename Name for the file to be loaded. - * @return XMLP_ret::XML_OK on success, XMLP_ret::XML_ERROR in other case. - */ - RTPS_DllAPI static XMLP_ret loadXMLFile(const std::string& filename); - - /** - * Load a profiles XML node. - * @param doc Node to be loaded. - * @return XMLP_ret::XML_OK on success, XMLP_ret::XML_ERROR in other case. - */ - RTPS_DllAPI static XMLP_ret loadXMLNode(tinyxml2::XMLDocument& doc); - - /** - * Load a profiles XML node. - * @param profiles Node to be loaded. - * @return XMLP_ret::XML_OK on success, XMLP_ret::XML_ERROR in other case. - */ - RTPS_DllAPI static XMLP_ret loadXMLProfiles(tinyxml2::XMLElement& profiles); - - /** - * Load a dynamic types XML node. - * @param types Node to be loaded. - * @return XMLP_ret::XML_OK on success, XMLP_ret::XML_ERROR in other case. - */ - RTPS_DllAPI static XMLP_ret loadXMLDynamicTypes(tinyxml2::XMLElement& types); - - /** - * Search for the profile specified and fill the structure. - * @param profile_name Name for the profile to be used to fill the structure. - * @param atts Structure to be filled. - * @return XMLP_ret::XML_OK on success, XMLP_ret::XML_ERROR in other case. - */ - RTPS_DllAPI static XMLP_ret fillParticipantAttributes( - const std::string& profile_name, - ParticipantAttributes& atts); - - //!Fills participant_attributes with the default values. - RTPS_DllAPI static void getDefaultParticipantAttributes(ParticipantAttributes& participant_attributes); - - /** - * Search for the profile specified and fill the structure. - * @param profile_name Name for the profile to be used to fill the structure. - * @param atts Structure to be filled. - * @return XMLP_ret::XML_OK on success, XMLP_ret::XML_ERROR in other case. - */ - RTPS_DllAPI static XMLP_ret fillPublisherAttributes( - const std::string& profile_name, - PublisherAttributes& atts); - - //!Fills publisher_attributes with the default values. - RTPS_DllAPI static void getDefaultPublisherAttributes(PublisherAttributes& publisher_attributes); - - /** - * Search for the profile specified and fill the structure. - * @param profile_name Name for the profile to be used to fill the structure. - * @param atts Structure to be filled. - * @return XMLP_ret::XML_OK on success, XMLP_ret::XML_ERROR in other case. - */ - RTPS_DllAPI static XMLP_ret fillSubscriberAttributes( - const std::string &profile_name, - SubscriberAttributes &atts); - - //!Fills subscriber_attributes with the default values. - RTPS_DllAPI static void getDefaultSubscriberAttributes(SubscriberAttributes& subscriber_attributes); - - //!Add a new transport instance along with its id. - RTPS_DllAPI static bool insertTransportById( - const std::string& sId, - sp_transport_t transport); - - //!Retrieves a transport instance by its id. - RTPS_DllAPI static sp_transport_t getTransportById(const std::string& sId); - - /** - * Search for the profile specified and fill the structure. - * @param profile_name Name for the profile to be used to fill the structure. - * @param atts Structure to be filled. - * @return XMLP_ret::XML_OK on success, XMLP_ret::XML_ERROR in other case. - */ - RTPS_DllAPI static XMLP_ret fillTopicAttributes( - const std::string& profile_name, - TopicAttributes& atts); - - //!Fills topic_attributes with the default values. - RTPS_DllAPI static void getDefaultTopicAttributes(TopicAttributes& topic_attributes); - - //!Add a new dynamic type instance along with its name. - RTPS_DllAPI static bool insertDynamicTypeByName( - const std::string& sName, - p_dynamictypebuilder_t type); - - //!Retrieves a transport instance by its name. - RTPS_DllAPI static p_dynamictypebuilder_t getDynamicTypeByName(const std::string& sName); - - /** - * Deletes the XMLProsileManager instance. - * FastRTPS's Domain calls this method automatically on its destructor, but - * if using XMLProfileManager outside of FastRTPS, it should be called manually. - */ - RTPS_DllAPI static void DeleteInstance() - { - m_participant_profiles.clear(); - m_publisher_profiles.clear(); - m_subscriber_profiles.clear(); - m_xml_files.clear(); - m_transport_profiles.clear(); - - for (auto pair : m_dynamictypes) - { - types::DynamicTypeBuilderFactory::get_instance()->delete_builder(pair.second); - } - m_dynamictypes.clear(); - } +public: + + /** + * Load the default profiles XML file. + * @return XMLP_ret::XML_OK on success, XMLP_ret::XML_ERROR in other case. + */ + RTPS_DllAPI static void loadDefaultXMLFile(); + + /** + * Load a profiles XML file. + * @param filename Name for the file to be loaded. + * @return XMLP_ret::XML_OK on success, XMLP_ret::XML_ERROR in other case. + */ + RTPS_DllAPI static XMLP_ret loadXMLFile( + const std::string& filename); - /** - * Retrieves a DynamicPubSubType for the given dynamic type name. - * Any instance retrieve by calling this method must be deleted calling the - * XMLProfileManager::DeleteDynamicPubSubType method. - */ - RTPS_DllAPI static types::DynamicPubSubType* CreateDynamicPubSubType(const std::string& typeName) + /** + * Load a profiles XML node. + * @param doc Node to be loaded. + * @return XMLP_ret::XML_OK on success, XMLP_ret::XML_ERROR in other case. + */ + RTPS_DllAPI static XMLP_ret loadXMLNode( + tinyxml2::XMLDocument& doc); + + /** + * Load a profiles XML node. + * @param profiles Node to be loaded. + * @return XMLP_ret::XML_OK on success, XMLP_ret::XML_ERROR in other case. + */ + RTPS_DllAPI static XMLP_ret loadXMLProfiles( + tinyxml2::XMLElement& profiles); + + /** + * Load a dynamic types XML node. + * @param types Node to be loaded. + * @return XMLP_ret::XML_OK on success, XMLP_ret::XML_ERROR in other case. + */ + RTPS_DllAPI static XMLP_ret loadXMLDynamicTypes( + tinyxml2::XMLElement& types); + + /** + * Search for the profile specified and fill the structure. + * @param profile_name Name for the profile to be used to fill the structure. + * @param atts Structure to be filled. + * @param log_error Flag to log an error if the profile_name is not found. Defaults true. + * @return XMLP_ret::XML_OK on success, XMLP_ret::XML_ERROR in other case. + */ + RTPS_DllAPI static XMLP_ret fillParticipantAttributes( + const std::string& profile_name, + ParticipantAttributes& atts, + bool log_error = true); + + //!Fills participant_attributes with the default values. + RTPS_DllAPI static void getDefaultParticipantAttributes( + ParticipantAttributes& participant_attributes); + + /** + * Search for the profile specified and fill the structure. + * @param profile_name Name for the profile to be used to fill the structure. + * @param atts Structure to be filled. + * @param log_error Flag to log an error if the profile_name is not found. Defaults true. + * @return XMLP_ret::XML_OK on success, XMLP_ret::XML_ERROR in other case. + */ + RTPS_DllAPI static XMLP_ret fillPublisherAttributes( + const std::string& profile_name, + PublisherAttributes& atts, + bool log_error = true); + + //!Fills publisher_attributes with the default values. + RTPS_DllAPI static void getDefaultPublisherAttributes( + PublisherAttributes& publisher_attributes); + + /** + * Search for the profile specified and fill the structure. + * @param profile_name Name for the profile to be used to fill the structure. + * @param atts Structure to be filled. + * @param log_error Flag to log an error if the profile_name is not found. Defaults true. + * @return XMLP_ret::XML_OK on success, XMLP_ret::XML_ERROR in other case. + */ + RTPS_DllAPI static XMLP_ret fillSubscriberAttributes( + const std::string& profile_name, + SubscriberAttributes& atts, + bool log_error = true); + + //!Fills subscriber_attributes with the default values. + RTPS_DllAPI static void getDefaultSubscriberAttributes( + SubscriberAttributes& subscriber_attributes); + + //!Add a new transport instance along with its id. + RTPS_DllAPI static bool insertTransportById( + const std::string& transport_id, + sp_transport_t transport); + + //!Retrieves a transport instance by its id. + RTPS_DllAPI static sp_transport_t getTransportById( + const std::string& transport_id); + + /** + * Search for the profile specified and fill the structure. + * @param profile_name Name for the profile to be used to fill the structure. + * @param atts Structure to be filled. + * @return XMLP_ret::XML_OK on success, XMLP_ret::XML_ERROR in other case. + */ + RTPS_DllAPI static XMLP_ret fillTopicAttributes( + const std::string& profile_name, + TopicAttributes& atts); + + //!Fills topic_attributes with the default values. + RTPS_DllAPI static void getDefaultTopicAttributes( + TopicAttributes& topic_attributes); + + //!Add a new dynamic type instance along with its name. + RTPS_DllAPI static bool insertDynamicTypeByName( + const std::string& type_name, + p_dynamictypebuilder_t type); + + //!Retrieves a transport instance by its name. + RTPS_DllAPI static p_dynamictypebuilder_t getDynamicTypeByName( + const std::string& type_name); + + /** + * Deletes the XMLProsileManager instance. + * FastRTPS's Domain calls this method automatically on its destructor, but + * if using XMLProfileManager outside of FastRTPS, it should be called manually. + */ + RTPS_DllAPI static void DeleteInstance() + { + participant_profiles_.clear(); + publisher_profiles_.clear(); + subscriber_profiles_.clear(); + xml_files_.clear(); + transport_profiles_.clear(); + + for (auto pair : dynamic_types_) { - if (m_dynamictypes.find(typeName) != m_dynamictypes.end()) - { - return new types::DynamicPubSubType(m_dynamictypes[typeName]->build()); - } - return nullptr; + types::DynamicTypeBuilderFactory::get_instance()->delete_builder(pair.second); } - - /** - * Deletes the given DynamicPubSubType previously created by calling - * XMLProfileManager::CreateDynamicPubSubType method. - */ - RTPS_DllAPI static void DeleteDynamicPubSubType(types::DynamicPubSubType *type) + dynamic_types_.clear(); + } + + /** + * Retrieves a DynamicPubSubType for the given dynamic type name. + * Any instance retrieve by calling this method must be deleted calling the + * XMLProfileManager::DeleteDynamicPubSubType method. + */ + RTPS_DllAPI static types::DynamicPubSubType* CreateDynamicPubSubType( + const std::string& type_name) + { + if (dynamic_types_.find(type_name) != dynamic_types_.end()) { - delete type; + return new types::DynamicPubSubType(dynamic_types_[type_name]->build()); } + return nullptr; + } + + /** + * Deletes the given DynamicPubSubType previously created by calling + * XMLProfileManager::CreateDynamicPubSubType method. + */ + RTPS_DllAPI static void DeleteDynamicPubSubType( + types::DynamicPubSubType* type) + { + delete type; + } + +private: + + RTPS_DllAPI static XMLP_ret extractDynamicTypes( + up_base_node_t properties, + const std::string& filename); - private: - RTPS_DllAPI static XMLP_ret extractDynamicTypes( - up_base_node_t properties, - const std::string& filename); - - RTPS_DllAPI static XMLP_ret extractProfiles( - up_base_node_t properties, - const std::string& filename); + RTPS_DllAPI static XMLP_ret extractProfiles( + up_base_node_t properties, + const std::string& filename); - RTPS_DllAPI static XMLP_ret extractParticipantProfile( + RTPS_DllAPI static XMLP_ret extractParticipantProfile( up_base_node_t& profile, const std::string& filename); - RTPS_DllAPI static XMLP_ret extractPublisherProfile( + RTPS_DllAPI static XMLP_ret extractPublisherProfile( up_base_node_t& profile, const std::string& filename); - RTPS_DllAPI static XMLP_ret extractSubscriberProfile( + RTPS_DllAPI static XMLP_ret extractSubscriberProfile( up_base_node_t& profile, const std::string& filename); - RTPS_DllAPI static XMLP_ret extractTopicProfile( + RTPS_DllAPI static XMLP_ret extractTopicProfile( up_base_node_t& profile, const std::string& filename); + static BaseNode* root; - static BaseNode* root; - - static participant_map_t m_participant_profiles; + static participant_map_t participant_profiles_; - static publisher_map_t m_publisher_profiles; + static publisher_map_t publisher_profiles_; - static subscriber_map_t m_subscriber_profiles; + static subscriber_map_t subscriber_profiles_; - static topic_map_t m_topic_profiles; + static topic_map_t topic_profiles_; - static xmlfiles_map_t m_xml_files; + static xmlfiles_map_t xml_files_; - static sp_transport_map_t m_transport_profiles; + static sp_transport_map_t transport_profiles_; - static p_dynamictype_map_t m_dynamictypes; + static p_dynamictype_map_t dynamic_types_; }; } /* xmlparser */ diff --git a/src/cpp/xmlparser/XMLProfileManager.cpp b/src/cpp/xmlparser/XMLProfileManager.cpp index 7e0e10d7dec..fcb0519f553 100644 --- a/src/cpp/xmlparser/XMLProfileManager.cpp +++ b/src/cpp/xmlparser/XMLProfileManager.cpp @@ -25,60 +25,79 @@ using namespace eprosima::fastrtps; using namespace ::xmlparser; -std::map XMLProfileManager::m_participant_profiles; +std::map XMLProfileManager::participant_profiles_; ParticipantAttributes default_participant_attributes; -std::map XMLProfileManager::m_publisher_profiles; +std::map XMLProfileManager::publisher_profiles_; PublisherAttributes default_publisher_attributes; -std::map XMLProfileManager::m_subscriber_profiles; +std::map XMLProfileManager::subscriber_profiles_; SubscriberAttributes default_subscriber_attributes; -std::map XMLProfileManager::m_topic_profiles; +std::map XMLProfileManager::topic_profiles_; TopicAttributes default_topic_attributes; -std::map XMLProfileManager::m_xml_files; -sp_transport_map_t XMLProfileManager::m_transport_profiles; -p_dynamictype_map_t XMLProfileManager::m_dynamictypes; - +std::map XMLProfileManager::xml_files_; +sp_transport_map_t XMLProfileManager::transport_profiles_; +p_dynamictype_map_t XMLProfileManager::dynamic_types_; BaseNode* XMLProfileManager::root = nullptr; -XMLP_ret XMLProfileManager::fillParticipantAttributes(const std::string &profile_name, ParticipantAttributes &atts) +XMLP_ret XMLProfileManager::fillParticipantAttributes( + const std::string& profile_name, + ParticipantAttributes& atts, + bool log_error) { - part_map_iterator_t it = m_participant_profiles.find(profile_name); - if (it == m_participant_profiles.end()) + part_map_iterator_t it = participant_profiles_.find(profile_name); + if (it == participant_profiles_.end()) { - logError(XMLPARSER, "Profile '" << profile_name << "' not found '"); + if (log_error) + { + logError(XMLPARSER, "Profile '" << profile_name << "' not found '"); + } return XMLP_ret::XML_ERROR; } atts = *(it->second); return XMLP_ret::XML_OK; } -XMLP_ret XMLProfileManager::fillPublisherAttributes(const std::string &profile_name, PublisherAttributes &atts) +XMLP_ret XMLProfileManager::fillPublisherAttributes( + const std::string& profile_name, + PublisherAttributes& atts, + bool log_error) { - publ_map_iterator_t it = m_publisher_profiles.find(profile_name); - if (it == m_publisher_profiles.end()) + publ_map_iterator_t it = publisher_profiles_.find(profile_name); + if (it == publisher_profiles_.end()) { - logError(XMLPARSER, "Profile '" << profile_name << "' not found '"); + if (log_error) + { + logError(XMLPARSER, "Profile '" << profile_name << "' not found '"); + } return XMLP_ret::XML_ERROR; } atts = *(it->second); return XMLP_ret::XML_OK; } -XMLP_ret XMLProfileManager::fillSubscriberAttributes(const std::string &profile_name, SubscriberAttributes &atts) +XMLP_ret XMLProfileManager::fillSubscriberAttributes( + const std::string& profile_name, + SubscriberAttributes& atts, + bool log_error) { - subs_map_iterator_t it = m_subscriber_profiles.find(profile_name); - if (it == m_subscriber_profiles.end()) + subs_map_iterator_t it = subscriber_profiles_.find(profile_name); + if (it == subscriber_profiles_.end()) { - logError(XMLPARSER, "Profile '" << profile_name << "' not found"); + if (log_error) + { + logError(XMLPARSER, "Profile '" << profile_name << "' not found"); + } return XMLP_ret::XML_ERROR; } atts = *(it->second); return XMLP_ret::XML_OK; } -XMLP_ret XMLProfileManager::fillTopicAttributes(const std::string& profile_name, TopicAttributes& atts) +XMLP_ret XMLProfileManager::fillTopicAttributes( + const std::string& profile_name, + TopicAttributes& atts) { - topic_map_iterator_t it = m_topic_profiles.find(profile_name); - if (it == m_topic_profiles.end()) + topic_map_iterator_t it = topic_profiles_.find(profile_name); + if (it == topic_profiles_.end()) { logError(XMLPARSER, "Profile '" << profile_name << "' not found"); return XMLP_ret::XML_ERROR; @@ -87,22 +106,26 @@ XMLP_ret XMLProfileManager::fillTopicAttributes(const std::string& profile_name, return XMLP_ret::XML_OK; } -void XMLProfileManager::getDefaultParticipantAttributes(ParticipantAttributes& participant_attributes) +void XMLProfileManager::getDefaultParticipantAttributes( + ParticipantAttributes& participant_attributes) { participant_attributes = default_participant_attributes; } -void XMLProfileManager::getDefaultPublisherAttributes(PublisherAttributes& publisher_attributes) +void XMLProfileManager::getDefaultPublisherAttributes( + PublisherAttributes& publisher_attributes) { publisher_attributes = default_publisher_attributes; } -void XMLProfileManager::getDefaultSubscriberAttributes(SubscriberAttributes& subscriber_attributes) +void XMLProfileManager::getDefaultSubscriberAttributes( + SubscriberAttributes& subscriber_attributes) { subscriber_attributes = default_subscriber_attributes; } -void XMLProfileManager::getDefaultTopicAttributes(TopicAttributes& topic_attributes) +void XMLProfileManager::getDefaultTopicAttributes( + TopicAttributes& topic_attributes) { topic_attributes = default_topic_attributes; } @@ -128,7 +151,8 @@ void XMLProfileManager::loadDefaultXMLFile() loadXMLFile(DEFAULT_FASTRTPS_PROFILES); } -XMLP_ret XMLProfileManager::loadXMLProfiles(tinyxml2::XMLElement& profiles) +XMLP_ret XMLProfileManager::loadXMLProfiles( + tinyxml2::XMLElement& profiles) { up_base_node_t root_node; XMLParser::loadXMLProfiles(profiles, root_node); @@ -160,12 +184,14 @@ XMLP_ret XMLProfileManager::loadXMLProfiles(tinyxml2::XMLElement& profiles) return XMLP_ret::XML_ERROR; } -XMLP_ret XMLProfileManager::loadXMLDynamicTypes(tinyxml2::XMLElement& types) +XMLP_ret XMLProfileManager::loadXMLDynamicTypes( + tinyxml2::XMLElement& types) { return XMLParser::loadXMLDynamicTypes(types); } -XMLP_ret XMLProfileManager::loadXMLNode(tinyxml2::XMLDocument& doc) +XMLP_ret XMLProfileManager::loadXMLNode( + tinyxml2::XMLDocument& doc) { up_base_node_t root_node; XMLParser::loadXML(doc, root_node); @@ -197,7 +223,8 @@ XMLP_ret XMLProfileManager::loadXMLNode(tinyxml2::XMLDocument& doc) return XMLP_ret::XML_ERROR; } -XMLP_ret XMLProfileManager::loadXMLFile(const std::string& filename) +XMLP_ret XMLProfileManager::loadXMLFile( + const std::string& filename) { if (filename.empty()) { @@ -205,22 +232,22 @@ XMLP_ret XMLProfileManager::loadXMLFile(const std::string& filename) return XMLP_ret::XML_ERROR; } - xmlfile_map_iterator_t it = m_xml_files.find(filename); - if (it != m_xml_files.end() && XMLP_ret::XML_OK == it->second) + xmlfile_map_iterator_t it = xml_files_.find(filename); + if (it != xml_files_.end() && XMLP_ret::XML_OK == it->second) { logInfo(XMLPARSER, "XML file '" << filename << "' already parsed"); return XMLP_ret::XML_OK; } up_base_node_t root_node; - XMLP_ret loadedRet = XMLParser::loadXML(filename, root_node); - if (!root_node || loadedRet != XMLP_ret::XML_OK) + XMLP_ret loaded_ret = XMLParser::loadXML(filename, root_node); + if (!root_node || loaded_ret != XMLP_ret::XML_OK) { if (filename != std::string(DEFAULT_FASTRTPS_PROFILES)) { logError(XMLPARSER, "Error parsing '" << filename << "'"); } - m_xml_files.emplace(filename, XMLP_ret::XML_ERROR); + xml_files_.emplace(filename, XMLP_ret::XML_ERROR); return XMLP_ret::XML_ERROR; } @@ -233,7 +260,7 @@ XMLP_ret XMLProfileManager::loadXMLFile(const std::string& filename) if (NodeType::TYPES == root_node->getType()) { - return loadedRet; + return loaded_ret; } if (NodeType::ROOT == root_node->getType()) @@ -250,7 +277,9 @@ XMLP_ret XMLProfileManager::loadXMLFile(const std::string& filename) return XMLP_ret::XML_ERROR; } -XMLP_ret XMLProfileManager::extractDynamicTypes(up_base_node_t profiles, const std::string& filename) +XMLP_ret XMLProfileManager::extractDynamicTypes( + up_base_node_t profiles, + const std::string& filename) { if (nullptr == profiles) { @@ -258,16 +287,16 @@ XMLP_ret XMLProfileManager::extractDynamicTypes(up_base_node_t profiles, const s return XMLP_ret::XML_ERROR; } - unsigned int profileCount = 0u; + unsigned int profile_count = 0u; for (auto&& profile: profiles->getChildren()) { if (NodeType::TYPE == profile->getType()) { - tinyxml2::XMLElement* p_node = dynamic_cast(profile.get()); - if (XMLP_ret::XML_OK == XMLParser::loadXMLDynamicTypes(*p_node)) + tinyxml2::XMLElement* node = dynamic_cast(profile.get()); + if (XMLP_ret::XML_OK == XMLParser::loadXMLDynamicTypes(*node)) { - ++profileCount; + ++profile_count; } } else @@ -276,19 +305,21 @@ XMLP_ret XMLProfileManager::extractDynamicTypes(up_base_node_t profiles, const s } } - if (0 == profileCount) + if (0 == profile_count) { - m_xml_files.emplace(filename, XMLP_ret::XML_ERROR); + xml_files_.emplace(filename, XMLP_ret::XML_ERROR); logError(XMLPARSER, "Error, file '" << filename << "' bad content"); return XMLP_ret::XML_ERROR; } - m_xml_files.emplace(filename, XMLP_ret::XML_OK); + xml_files_.emplace(filename, XMLP_ret::XML_OK); return XMLP_ret::XML_OK; } -XMLP_ret XMLProfileManager::extractProfiles(up_base_node_t profiles, const std::string& filename) +XMLP_ret XMLProfileManager::extractProfiles( + up_base_node_t profiles, + const std::string& filename) { if (nullptr == profiles) { @@ -296,7 +327,7 @@ XMLP_ret XMLProfileManager::extractProfiles(up_base_node_t profiles, const std:: return XMLP_ret::XML_ERROR; } - unsigned int profileCount = 0u; + unsigned int profile_count = 0u; for (auto&& profile: profiles->getChildren()) { @@ -304,28 +335,28 @@ XMLP_ret XMLProfileManager::extractProfiles(up_base_node_t profiles, const std:: { if (XMLP_ret::XML_OK == extractParticipantProfile(profile, filename)) { - ++profileCount; + ++profile_count; } } else if (NodeType::PUBLISHER == profile.get()->getType()) { if (XMLP_ret::XML_OK == extractPublisherProfile(profile, filename)) { - ++profileCount; + ++profile_count; } } else if (NodeType::SUBSCRIBER == profile.get()->getType()) { if (XMLP_ret::XML_OK == extractSubscriberProfile(profile, filename)) { - ++profileCount; + ++profile_count; } } else if (NodeType::TOPIC == profile.get()->getType()) { if (XMLP_ret::XML_OK == extractTopicProfile(profile, filename)) { - ++profileCount; + ++profile_count; } } else @@ -334,28 +365,30 @@ XMLP_ret XMLProfileManager::extractProfiles(up_base_node_t profiles, const std:: } } - profileCount += static_cast(m_transport_profiles.size()); // Count transport profiles + profile_count += static_cast(transport_profiles_.size()); // Count transport profiles - if (0 == profileCount) + if (0 == profile_count) { - m_xml_files.emplace(filename, XMLP_ret::XML_ERROR); + xml_files_.emplace(filename, XMLP_ret::XML_ERROR); logError(XMLPARSER, "Error, file '" << filename << "' bad content"); return XMLP_ret::XML_ERROR; } - m_xml_files.emplace(filename, XMLP_ret::XML_OK); + xml_files_.emplace(filename, XMLP_ret::XML_OK); return XMLP_ret::XML_OK; } -XMLP_ret XMLProfileManager::extractParticipantProfile(up_base_node_t& profile, const std::string& filename) +XMLP_ret XMLProfileManager::extractParticipantProfile( + up_base_node_t& profile, + const std::string& filename) { (void)(filename); std::string profile_name = ""; - p_node_participant_t p_node_part = dynamic_cast(profile.get()); - node_att_map_cit_t it = p_node_part->getAttributes().find(PROFILE_NAME); - if (it == p_node_part->getAttributes().end() || it->second.empty()) + p_node_participant_t node_part = dynamic_cast(profile.get()); + node_att_map_cit_t it = node_part->getAttributes().find(PROFILE_NAME); + if (it == node_part->getAttributes().end() || it->second.empty()) { logError(XMLPARSER, "Error adding profile from file '" << filename << "': no name found"); return XMLP_ret::XML_ERROR; @@ -363,15 +396,15 @@ XMLP_ret XMLProfileManager::extractParticipantProfile(up_base_node_t& profile, c profile_name = it->second; - std::pair emplace = m_participant_profiles.emplace(profile_name, p_node_part->getData()); + std::pair emplace = participant_profiles_.emplace(profile_name, node_part->getData()); if (false == emplace.second) { logError(XMLPARSER, "Error adding profile '" << profile_name << "' from file '" << filename << "'"); return XMLP_ret::XML_ERROR; } - it = p_node_part->getAttributes().find(DEFAULT_PROF); - if (it != p_node_part->getAttributes().end() && it->second == "true") // Set as default profile + it = node_part->getAttributes().find(DEFAULT_PROF); + if (it != node_part->getAttributes().end() && it->second == "true") // Set as default profile { // +V+ TODO: LOG ERROR IN SECOND ATTEMPT default_participant_attributes = *(emplace.first->second.get() ); @@ -379,14 +412,16 @@ XMLP_ret XMLProfileManager::extractParticipantProfile(up_base_node_t& profile, c return XMLP_ret::XML_OK; } -XMLP_ret XMLProfileManager::extractPublisherProfile(up_base_node_t& profile, const std::string& filename) +XMLP_ret XMLProfileManager::extractPublisherProfile( + up_base_node_t& profile, + const std::string& filename) { (void)(filename); std::string profile_name = ""; - p_node_publisher_t p_node_part = dynamic_cast(profile.get()); - node_att_map_cit_t it = p_node_part->getAttributes().find(PROFILE_NAME); - if (it == p_node_part->getAttributes().end() || it->second.empty()) + p_node_publisher_t node_part = dynamic_cast(profile.get()); + node_att_map_cit_t it = node_part->getAttributes().find(PROFILE_NAME); + if (it == node_part->getAttributes().end() || it->second.empty()) { logError(XMLPARSER, "Error adding profile from file '" << filename << "': no name found"); return XMLP_ret::XML_ERROR; @@ -394,15 +429,15 @@ XMLP_ret XMLProfileManager::extractPublisherProfile(up_base_node_t& profile, con profile_name = it->second; - std::pair emplace = m_publisher_profiles.emplace(profile_name, p_node_part->getData()); + std::pair emplace = publisher_profiles_.emplace(profile_name, node_part->getData()); if (false == emplace.second) { logError(XMLPARSER, "Error adding profile '" << profile_name << "' from file '" << filename << "'"); return XMLP_ret::XML_ERROR; } - it = p_node_part->getAttributes().find(DEFAULT_PROF); - if (it != p_node_part->getAttributes().end() && it->second == "true") // Set as default profile + it = node_part->getAttributes().find(DEFAULT_PROF); + if (it != node_part->getAttributes().end() && it->second == "true") // Set as default profile { // +V+ TODO: LOG ERROR IN SECOND ATTEMPT default_publisher_attributes = *(emplace.first->second.get() ); @@ -410,14 +445,16 @@ XMLP_ret XMLProfileManager::extractPublisherProfile(up_base_node_t& profile, con return XMLP_ret::XML_OK; } -XMLP_ret XMLProfileManager::extractSubscriberProfile(up_base_node_t& profile, const std::string& filename) +XMLP_ret XMLProfileManager::extractSubscriberProfile( + up_base_node_t& profile, + const std::string& filename) { (void)(filename); std::string profile_name = ""; - p_node_subscriber_t p_node_part = dynamic_cast(profile.get()); - node_att_map_cit_t it = p_node_part->getAttributes().find(PROFILE_NAME); - if (it == p_node_part->getAttributes().end() || it->second.empty()) + p_node_subscriber_t node_part = dynamic_cast(profile.get()); + node_att_map_cit_t it = node_part->getAttributes().find(PROFILE_NAME); + if (it == node_part->getAttributes().end() || it->second.empty()) { logError(XMLPARSER, "Error adding profile from file '" << filename << "': no name found"); return XMLP_ret::XML_ERROR; @@ -425,15 +462,15 @@ XMLP_ret XMLProfileManager::extractSubscriberProfile(up_base_node_t& profile, co profile_name = it->second; - std::pair emplace = m_subscriber_profiles.emplace(profile_name, p_node_part->getData()); + std::pair emplace = subscriber_profiles_.emplace(profile_name, node_part->getData()); if (false == emplace.second) { logError(XMLPARSER, "Error adding profile '" << profile_name << "' from file '" << filename << "'"); return XMLP_ret::XML_ERROR; } - it = p_node_part->getAttributes().find(DEFAULT_PROF); - if (it != p_node_part->getAttributes().end() && it->second == "true") // Set as default profile + it = node_part->getAttributes().find(DEFAULT_PROF); + if (it != node_part->getAttributes().end() && it->second == "true") // Set as default profile { // +V+ TODO: LOG ERROR IN SECOND ATTEMPT default_subscriber_attributes = *(emplace.first->second.get() ); @@ -441,54 +478,62 @@ XMLP_ret XMLProfileManager::extractSubscriberProfile(up_base_node_t& profile, co return XMLP_ret::XML_OK; } -bool XMLProfileManager::insertTransportById(const std::string& sId, sp_transport_t transport) +bool XMLProfileManager::insertTransportById( + const std::string& transport_id, + sp_transport_t transport) { - if (m_transport_profiles.find(sId) == m_transport_profiles.end()) + if (transport_profiles_.find(transport_id) == transport_profiles_.end()) { - m_transport_profiles[sId] = transport; + transport_profiles_[transport_id] = transport; return true; } - logError(XMLPARSER, "Error adding the transport " << sId << ". There is other transport with the same id"); + logError(XMLPARSER, "Error adding the transport " << transport_id << ". There is other transport with the same id"); return false; } -sp_transport_t XMLProfileManager::getTransportById(const std::string& sId) +sp_transport_t XMLProfileManager::getTransportById( + const std::string& transport_id) { - if (m_transport_profiles.find(sId) != m_transport_profiles.end()) + if (transport_profiles_.find(transport_id) != transport_profiles_.end()) { - return m_transport_profiles[sId]; + return transport_profiles_[transport_id]; } return nullptr; } -bool XMLProfileManager::insertDynamicTypeByName(const std::string& sName, p_dynamictypebuilder_t type) +bool XMLProfileManager::insertDynamicTypeByName( + const std::string& type_name, + p_dynamictypebuilder_t type) { - if (m_dynamictypes.find(sName) == m_dynamictypes.end()) + if (dynamic_types_.find(type_name) == dynamic_types_.end()) { - m_dynamictypes[sName] = type; + dynamic_types_[type_name] = type; return true; } - logError(XMLPARSER, "Error adding the type " << sName << ". There is other type with the same name."); + logError(XMLPARSER, "Error adding the type " << type_name << ". There is other type with the same name."); return false; } -p_dynamictypebuilder_t XMLProfileManager::getDynamicTypeByName(const std::string& sName) +p_dynamictypebuilder_t XMLProfileManager::getDynamicTypeByName( + const std::string& type_name) { - if (m_dynamictypes.find(sName) != m_dynamictypes.end()) + if (dynamic_types_.find(type_name) != dynamic_types_.end()) { - return m_dynamictypes[sName]; + return dynamic_types_[type_name]; } return nullptr; } -XMLP_ret XMLProfileManager::extractTopicProfile(up_base_node_t& profile, const std::string& filename) +XMLP_ret XMLProfileManager::extractTopicProfile( + up_base_node_t& profile, + const std::string& filename) { (void)(filename); std::string profile_name = ""; - p_node_topic_t p_node_topic = dynamic_cast(profile.get()); - node_att_map_cit_t it = p_node_topic->getAttributes().find(PROFILE_NAME); - if (it == p_node_topic->getAttributes().end() || it->second.empty()) + p_node_topic_t node_topic = dynamic_cast(profile.get()); + node_att_map_cit_t it = node_topic->getAttributes().find(PROFILE_NAME); + if (it == node_topic->getAttributes().end() || it->second.empty()) { logError(XMLPARSER, "Error adding profile from file '" << filename << "': no name found"); return XMLP_ret::XML_ERROR; @@ -496,14 +541,14 @@ XMLP_ret XMLProfileManager::extractTopicProfile(up_base_node_t& profile, const s profile_name = it->second; - std::pair emplace = m_topic_profiles.emplace(profile_name, p_node_topic->getData()); + std::pair emplace = topic_profiles_.emplace(profile_name, node_topic->getData()); if (false == emplace.second) { logError(XMLPARSER, "Error adding profile '" << profile_name << "' from file '" << filename << "'"); return XMLP_ret::XML_ERROR; } - it = p_node_topic->getAttributes().find(DEFAULT_PROF); + it = node_topic->getAttributes().find(DEFAULT_PROF); if (false == emplace.second) { // +V+ TODO: LOG ERROR IN SECOND ATTEMPT