EntityDescriptionRepository.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 "EntityDescriptionRepository.hpp"
00034 #include "ServiceTypeDescription.hpp"
00035 #include "ServiceInterfaceDescription.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 shared_ptr<EntityDescriptionRepository> EntityDescriptionRepository::instance_ = shared_ptr<EntityDescriptionRepository> (new EntityDescriptionRepository());
00045
00046 EntityDescriptionRepository::EntityDescriptionRepository()
00047 {
00048
00049 };
00050
00051 shared_ptr<EntityDescriptionRepository> EntityDescriptionRepository::getInstance()
00052 {
00053 return instance_;
00054 };
00055
00056 void EntityDescriptionRepository::addEntityDescription (shared_ptr<EntityDescription> entityDescription)
00057 {
00058 std::string entityName = entityDescription->getEntityName();
00059
00060 if (entityDescriptionMap_.find (entityName) != entityDescriptionMap_.end()) {
00061 std::stringstream ss;
00062 ss << "EntityDescriptionRepository::addEntityDescription : EntityDescriptionRepository already has a Entity with entityName=\"" << entityName << "\"";
00063 throw Exception (ss.str());
00064 }
00065
00066 entityDescriptionMap_[entityName] = entityDescription;
00067 };
00068
00069 shared_ptr<EntityDescription> EntityDescriptionRepository::getEntityDescription (std::string entityName)
00070 {
00071
00072
00073 if (entityDescriptionMap_.find (entityName) != entityDescriptionMap_.end()) {
00074 shared_ptr<EntityDescription> ed = entityDescriptionMap_[entityName];
00075 return ed;
00076 }
00077 else {
00078 std::stringstream ss;
00079 ss << "EntityDescriptionRepository::getEntityDescription : EntityDescriptionRepository does not have an Entity with entityName=\"" << entityName << "\"";
00080 throw Exception (ss.str());
00081 }
00082
00083 };
00084
00085 std::vector<shared_ptr<EntityDescription> > EntityDescriptionRepository::getAllEntityDescriptions()
00086 {
00087 std::vector<shared_ptr<EntityDescription> > ret;
00088 std::map<std::string, shared_ptr<EntityDescription> >::iterator it;
00089
00090 for (it = entityDescriptionMap_.begin(); it != entityDescriptionMap_.end(); it++) {
00091 shared_ptr<EntityDescription> ed = (*it).second;
00092
00093 ret.push_back (ed);
00094 }
00095
00096 return ret;
00097 };