EntityDescription.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 "EntityDescription.hpp"
00034 #include "ServiceInterfaceDescription.hpp"
00035 #include "ServiceTypeDescription.hpp"
00036
00037 #include <Exception.hpp>
00038
00039 #include <sstream>
00040
00041 using namespace mermaid::support::service;
00042 using mermaid::support::errorhandling::Exception;
00043
00044 EntityDescription::EntityDescription (std::string entityName)
00045 {
00046 entityName_ = entityName;
00047 };
00048
00049 std::string EntityDescription::getEntityName()
00050 {
00051 return entityName_;
00052 };
00053
00054
00055 void EntityDescription::addServiceInstanceDescription (shared_ptr<ServiceInstanceDescription> serviceInstanceDescription)
00056 {
00057 std::string serviceInstanceName = serviceInstanceDescription->getServiceInstanceName();
00058
00059 if (serviceMap_.find (serviceInstanceName) != serviceMap_.end()) {
00060 std::stringstream ss;
00061 ss << "EntityDescription::addServiceInstanceDescription : entity with entityName=\"" << entityName_ << "\" already has a service registered with serviceInstanceName=\"" << serviceInstanceName << "\"";
00062 throw Exception (ss.str());
00063 }
00064
00065 serviceMap_[serviceInstanceName] = serviceInstanceDescription;
00066 };
00067
00068 shared_ptr<ServiceInstanceDescription> EntityDescription::getServiceInstanceDescription (std::string serviceInstanceName)
00069 {
00070 shared_ptr<ServiceInstanceDescription> sd = serviceMap_[serviceInstanceName];
00071
00072 if (sd == false) {
00073 std::stringstream ss;
00074 ss << "EntityDescription::getServiceDescription : request for an unknown service instance name: " << serviceInstanceName;
00075 throw Exception (ss.str());
00076 }
00077
00078 return sd;
00079 };
00080
00081 std::vector<shared_ptr<ServiceInstanceDescription> > EntityDescription::getAllServiceInstanceDescriptions()
00082 {
00083
00084 std::vector<shared_ptr<ServiceInstanceDescription> > ret;
00085 std::map<std::string, shared_ptr<ServiceInstanceDescription> >::iterator it;
00086
00087 for (it = serviceMap_.begin(); it != serviceMap_.end(); it++) {
00088
00089 ret.push_back ( (*it).second);
00090 }
00091
00092 return ret;
00093 };