ActiveObjectManager.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 <ActiveObjectManager.hpp>
00034
00035 #include <Exception.hpp>
00036
00037 #include <iostream>
00038
00039 using namespace mermaid::support::activeobject;
00040
00041 using mermaid::support::errorhandling::Exception;
00042
00043 ActiveObjectManager::ActiveObjectManager()
00044 {
00045
00046 };
00047
00048 ActiveObjectManager::~ActiveObjectManager()
00049 {
00050
00051 };
00052
00053
00054
00055
00056 void ActiveObjectManager::addActiveObject (shared_ptr<ActiveObject> ao)
00057 {
00058 smartPointerMap[ao.get() ] = ao;
00059 aoVector_.push_back (ao);
00060 set<shared_ptr<ActiveObject> > s = stateMap[ao->getState() ];
00061 s.insert (ao);
00062 stateMap[ao->getState() ] = s;
00063
00064 };
00065
00066
00067
00068
00069 int ActiveObjectManager::getNumberOfActiveObjects()
00070 {
00071 return aoVector_.size();
00072 };
00073
00074
00075
00076 void ActiveObjectManager::notifyActiveObjectStateChange (ActiveObject * aoPtr, ActiveObjectState previousState)
00077 {
00078 shared_ptr<ActiveObject> ao = smartPointerMap[aoPtr];
00079
00080 set<shared_ptr<ActiveObject> > prevStateSet = stateMap[previousState];
00081 set<shared_ptr<ActiveObject> > currStateSet = stateMap[ao->getState() ];
00082
00083 prevStateSet.erase (ao);
00084 currStateSet.insert (ao);
00085
00086 stateMap[previousState] = prevStateSet;
00087 stateMap[ao->getState() ] = currStateSet;
00088
00089 };
00090
00091
00092 vector<shared_ptr<ActiveObject> > ActiveObjectManager::getActiveObjectVector()
00093 {
00094 return vector<shared_ptr<ActiveObject> > (aoVector_);
00095 };
00096
00097
00098
00099 set<shared_ptr<ActiveObject> > ActiveObjectManager::getActiveObjectStateSet (ActiveObjectState s)
00100 {
00101 set<shared_ptr<ActiveObject> > ret = stateMap[s];
00102 return set< shared_ptr<ActiveObject> > (ret);
00103 };