summaryrefslogtreecommitdiff
path: root/maximus/system/src/SystemManager.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'maximus/system/src/SystemManager.cpp')
-rw-r--r--maximus/system/src/SystemManager.cpp77
1 files changed, 72 insertions, 5 deletions
diff --git a/maximus/system/src/SystemManager.cpp b/maximus/system/src/SystemManager.cpp
index db89b8bfdd..76d0171998 100644
--- a/maximus/system/src/SystemManager.cpp
+++ b/maximus/system/src/SystemManager.cpp
@@ -68,14 +68,32 @@ void SystemManager::initAttributes ( )
if (NULL != mpSciServer)
{
mpSciServer->registerSpecializedSciMsg(MAXIMUS_SCI_MSG_TYPE_SYSTEM, new SystemSciMsg( ));
+ mpSciServer->setStationsList(&mListOfStations);
}
}
SystemManager::~SystemManager ( )
{
- delete (mpSciServer);
- mpSciServer = NULL;
+ cout << "SystemManager::~SystemManager" << endl;
+
+ if (NULL != mpSciServer)
+ {
+ delete (mpSciServer);
+ mpSciServer = NULL;
+ }
+
+ if (!mListOfStations.empty())
+ {
+ for (StationsList::const_iterator it = mListOfStations.begin(); it != mListOfStations.end(); ++it)
+ {
+ if (NULL != *it)
+ {
+ delete (*it);
+ }
+ }
+ mListOfStations.clear();
+ }
}
@@ -94,21 +112,52 @@ SystemManager::~SystemManager ( )
Station * SystemManager::createStation ( )
{
+ cout << "SystemManager::createStation" << endl;
Station * createdStation = new Station ();
-
+ mListOfStations.push_back(createdStation);
+ displayListOfStations();
return createdStation;
}
bool SystemManager::removeStation ( Station * station )
{
- return false;
+ cout << "SystemManager::removeStation" << endl;
+ bool bRemove = false;
+
+ if (NULL != station)
+ {
+ mListOfStations.remove(station);
+ delete (station);
+ station = NULL;
+ displayListOfStations();
+ bRemove = true;
+ }
+
+ return bRemove;
}
bool SystemManager::areAllActiveStationsIdle ( ) const
{
- return true;
+ cout << "SystemManager::areAllActiveStationsIdle" << endl;
+ bool bActive = true;
+
+ if (!mListOfStations.empty())
+ {
+ for (StationsList::const_iterator it = mListOfStations.begin(); it != mListOfStations.end(); ++it)
+ {
+ const Station * station = *it;
+ if (MAXIMUS_STATION_STATUS_IDLE != station->getStationStatus())
+ {
+ bActive = false;
+ it = mListOfStations.end();
+ --it;
+ }
+ }
+ }
+
+ return bActive;
}
@@ -116,6 +165,24 @@ bool SystemManager::areAllActiveStationsIdle ( ) const
//
+void SystemManager::displayListOfStations ( ) const
+{
+ if (!mListOfStations.empty())
+ {
+ cout << "Elements in mListOfStations = " << endl;
+ for (StationsList::const_iterator it = mListOfStations.begin(); it != mListOfStations.end(); ++it)
+ {
+ const Station * station = *it;
+ station->display();
+ }
+ }
+ else
+ {
+ cout << "List is empty!" << endl;
+ }
+}
+
+
// protected methods
//