ServiceInstanceDescription.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
00031 #include "config.h"
00032
00033 #include "ServiceInstanceDescription.hpp"
00034 #include "ServiceInterfaceDescription.hpp"
00035 #include "ServiceTypeDescription.hpp"
00036
00037 #include "EntityDescription.hpp"
00038
00039 #include "Exceptions/UnrecognizedServiceInterfaceException.hpp"
00040
00041 #include <Exception.hpp>
00042
00043
00044
00045 using namespace mermaid::support::service;
00046 using mermaid::support::errorhandling::Exception;
00047 using mermaid::support::service::exceptions::UnrecognizedServiceInterfaceException;
00048
00049 ServiceInstanceDescription::ServiceInstanceDescription (shared_ptr<EntityDescription> entityDescription, std::string serviceInstanceName)
00050 {
00051 entityDescription_ = entityDescription;
00052 serviceInstanceName_ = serviceInstanceName;
00053 };
00054
00055 void ServiceInstanceDescription::addServiceTypeDescription (shared_ptr<ServiceTypeDescription> serviceTypeDescription)
00056 {
00057 std::string typeName = serviceTypeDescription->getServiceTypeName();
00058
00059
00060
00061 if (serviceTypeDescriptions_.find (typeName) == serviceTypeDescriptions_.end()) {
00062 serviceTypeDescriptions_[typeName] = serviceTypeDescription;
00063 }
00064 else {
00065 throw Exception ("ServiceInstanceDescription::addServiceTypeDescription : adding ServiceTypeDescription with an already used Service Type Name : " + typeName);
00066 }
00067 };
00068
00069 shared_ptr<EntityDescription> ServiceInstanceDescription::getEntityDescription()
00070 {
00071 return entityDescription_;
00072 };
00073
00074 std::vector<shared_ptr<ServiceTypeDescription> > ServiceInstanceDescription::getServiceTypeDescriptions()
00075 {
00076 std::vector<shared_ptr<ServiceTypeDescription> > descriptions;
00077
00078 std::map<std::string, shared_ptr<ServiceTypeDescription> >::iterator it;
00079
00080 for (it = serviceTypeDescriptions_.begin(); it != serviceTypeDescriptions_.end(); it++) {
00081 shared_ptr<ServiceTypeDescription> std = (*it).second;
00082
00083 descriptions.push_back (std);
00084 }
00085
00086 return descriptions;
00087 };
00088
00089 shared_ptr<ServiceTypeDescription> ServiceInstanceDescription::getServiceTypeDescriptionWithInterfaceName (std::string interfaceName)
00090 {
00091 std::map<std::string, shared_ptr<ServiceTypeDescription> >::iterator it;
00092
00093 for (it = serviceTypeDescriptions_.begin(); it != serviceTypeDescriptions_.end(); it++) {
00094 shared_ptr<ServiceTypeDescription> typeDescription = (*it).second;
00095
00096 try {
00097 shared_ptr<ServiceInterfaceDescription> sid = typeDescription->getServiceInterfaceDescription (interfaceName);
00098 return typeDescription;
00099 }
00100 catch (Exception e) {
00101
00102 }
00103 }
00104
00105 throw UnrecognizedServiceInterfaceException ("ServiceInstanceDescription::getServiceTypeDescriptionWithInterfaceName : could not find ServiceInstanceDescription containing a Service Interface named " + interfaceName);
00106 };
00107
00108 shared_ptr<ServiceTypeDescription> ServiceInstanceDescription::getServiceTypeDescriptionWithDataFeedName (std::string dataFeedName)
00109 {
00110 std::map<std::string, shared_ptr<ServiceTypeDescription> >::iterator it;
00111
00112 for (it = serviceTypeDescriptions_.begin(); it != serviceTypeDescriptions_.end(); it++) {
00113 shared_ptr<ServiceTypeDescription> typeDescription = (*it).second;
00114
00115 try {
00116 shared_ptr<DataFeedDescription> dfd = typeDescription->getDataFeedDescription (dataFeedName);
00117 return typeDescription;
00118 }
00119 catch (Exception e) {
00120
00121 }
00122 }
00123
00124 throw Exception ("ServiceInstanceDescription::getServiceTypeDescriptionWithDataFeedName : could not find ServiceTypeDescription containing a Data Feed named " + dataFeedName);
00125 }
00126
00127 std::string ServiceInstanceDescription::getServiceInstanceName()
00128 {
00129 return serviceInstanceName_;
00130 };
00131