ServiceTypeDescription.cpp
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030 #include "config.h"
00031
00032 #include "ServiceTypeDescription.hpp"
00033 #include "Service.hpp"
00034 #include "DataFeedDescription.hpp"
00035 #include "ServiceInterfaceDescription.hpp"
00036
00037
00038
00039 #include <Exception.hpp>
00040 #include <XmlElement.hpp>
00041 #include <XmlElementVector.hpp>
00042
00043 #include <sstream>
00044
00045 using namespace mermaid::support::service;
00046 using mermaid::support::errorhandling::Exception;
00047 using boost::shared_ptr;
00048
00049 using mermaid::support::xml::XmlElement;
00050
00051 ServiceTypeDescription::ServiceTypeDescription (std::string serviceTypeName, std::string serviceTypeComment)
00052 {
00053 serviceTypeName_ = serviceTypeName;
00054 serviceTypeComment_ = serviceTypeComment;
00055 };
00056
00057 std::string ServiceTypeDescription::getServiceTypeName()
00058 {
00059 return serviceTypeName_;
00060 };
00061
00062 std::string ServiceTypeDescription::getServiceTypeComment()
00063 {
00064 return serviceTypeComment_;
00065 };
00066
00067
00068 void ServiceTypeDescription::addServiceInterfaceDescription (shared_ptr<ServiceInterfaceDescription> interfaceDescription)
00069 {
00070 std::string interfaceName = interfaceDescription->getServiceInterfaceName();
00071
00072 if (interfaceDescriptionMap_.find (interfaceName) != interfaceDescriptionMap_.end()) {
00073 std::stringstream ss;
00074 ss << "ServiceTypeDescription::addServiceInterfaceDescription : ServiceTypeDescription with serviceTypeName=\"" << serviceTypeName_ << "\" already has a ServiceInterfaceDescription with serviceInterfaceName=\"" << interfaceName << "\"";
00075 throw Exception (ss.str());
00076 }
00077
00078 interfaceDescriptionMap_[interfaceName] = interfaceDescription;
00079 };
00080
00081 shared_ptr<ServiceInterfaceDescription> ServiceTypeDescription::getServiceInterfaceDescription (std::string interfaceName)
00082 {
00083 shared_ptr<ServiceInterfaceDescription> interfaceDescription = interfaceDescriptionMap_[interfaceName];
00084
00085 if (interfaceDescription == false) {
00086 std::stringstream ss;
00087 ss << "ServiceTypeDescription::getServiceInterfaceDescription : ServiceTypeDescription with serviceTypeName=\"" << serviceTypeName_ << "\" does not have a ServiceInterfaceDescription with serviceInterfaceName=\"" << interfaceName << "\"";
00088 throw Exception (ss.str());
00089 }
00090
00091 return interfaceDescription;
00092 };
00093
00094 std::vector<shared_ptr<ServiceInterfaceDescription> > ServiceTypeDescription::getAllServiceInterfaceDescriptions()
00095 {
00096 std::vector<shared_ptr<ServiceInterfaceDescription> > ret;
00097
00098 std::map<std::string, shared_ptr<ServiceInterfaceDescription> >::iterator it;
00099
00100 for (it = interfaceDescriptionMap_.begin(); it != interfaceDescriptionMap_.end(); it++) {
00101 ret.push_back ( (*it).second);
00102 }
00103
00104 return ret;
00105 };
00106
00107 void ServiceTypeDescription::addDataFeedDescription (shared_ptr<DataFeedDescription> dataFeedDescription)
00108 {
00109 std::string dataFeedName = dataFeedDescription->getDataFeedName();
00110
00111 if (dataFeedDescriptionMap_.find (dataFeedName) != dataFeedDescriptionMap_.end()) {
00112 std::stringstream ss;
00113 ss << "ServiceTypeDescription::addDataFeedDescription: ServiceTypeDescription with serviceTypeName=\"" << serviceTypeName_ << "\" already has a DataFeedDescription with dataFeedName=\"" << dataFeedName << "\"";
00114 throw Exception (ss.str());
00115 }
00116
00117 dataFeedDescriptionMap_[dataFeedName] = dataFeedDescription;
00118 };
00119
00120 shared_ptr<DataFeedDescription> ServiceTypeDescription::getDataFeedDescription (std::string dataFeedName)
00121 {
00122 std::map<std::string, shared_ptr<DataFeedDescription> >::iterator it;
00123
00124 it = dataFeedDescriptionMap_.find (dataFeedName);
00125
00126 if (it == dataFeedDescriptionMap_.end()) {
00127 std::stringstream ss;
00128 ss << "ServiceTypeDescription::getDataFeedName: ServiceTypeDescription with serviceTypeName=\"" << serviceTypeName_ << "\" does not have a DataFeedDescription with dataFeedName=\"" << dataFeedName << "\"";
00129 throw Exception (ss.str());
00130 }
00131
00132 return (*it).second;
00133 };
00134
00135 std::vector< shared_ptr<DataFeedDescription> > ServiceTypeDescription::getAllDataFeedDescriptions()
00136 {
00137 std::vector<shared_ptr<DataFeedDescription> > ret;
00138
00139 std::map<std::string, shared_ptr<DataFeedDescription> >::iterator it;
00140
00141 for (it = dataFeedDescriptionMap_.begin(); it != dataFeedDescriptionMap_.end(); it++) {
00142 ret.push_back ( (*it).second);
00143 }
00144
00145 return ret;
00146 };