Entity.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 "Service.hpp"
00033 #include "Entity.hpp"
00034 #include "EntityDescription.hpp"
00035 #include "ServiceInterfaceDescription.hpp"
00036
00037
00038 #include <Exception.hpp>
00039
00040 #include <sstream>
00041
00042 using namespace mermaid::support::service;
00043 using mermaid::support::errorhandling::Exception;
00044
00045 Entity::Entity (shared_ptr<EntityDescription> entityDescription)
00046 {
00047 entityDescription_ = entityDescription;
00048 };
00049
00050 shared_ptr<EntityDescription> Entity::getEntityDescription()
00051 {
00052 return entityDescription_;
00053 };
00054
00055 void Entity::addService (shared_ptr<Service> s)
00056 {
00057 std::string serviceInstanceName = s->getServiceInstanceDescription()->getServiceInstanceName();
00058
00059 if (serviceMap.find (serviceInstanceName) != serviceMap.end()) {
00060 std::stringstream ss;
00061 ss << "Entity::addService : entity with name \"" << entityDescription_->getEntityName() << "\" already has a service registered with name \"" << serviceInstanceName << "\"";
00062 throw Exception (ss.str());
00063 }
00064
00065 serviceMap[serviceInstanceName] = s;
00066 };
00067
00068 shared_ptr<Service> Entity::getService (std::string serviceInstanceName)
00069 {
00070 if (serviceMap.find (serviceInstanceName) == serviceMap.end()) {
00071 std::stringstream ss;
00072 ss << "Entity::getService : entity with name \"" << entityDescription_->getEntityName() << "\" does not have a service registered with name \"" << serviceInstanceName << "\"";
00073 throw Exception (ss.str());
00074 }
00075
00076 return serviceMap[serviceInstanceName];
00077 };