all cstdout uses wrapped in preprocessor defines
This commit is contained in:
@ -18,13 +18,18 @@ ObjectManager::~ObjectManager() {
|
||||
ReturnValue_t ObjectManager::insert( object_id_t id, SystemObjectIF* object) {
|
||||
auto returnPair = objectList.emplace(id, object);
|
||||
if (returnPair.second) {
|
||||
#if CPP_OSTREAM_ENABLED == 1
|
||||
// sif::debug << "ObjectManager::insert: Object " << std::hex
|
||||
// << (int)id << std::dec << " inserted." << std::endl;
|
||||
#endif
|
||||
return this->RETURN_OK;
|
||||
} else {
|
||||
#if CPP_OSTREAM_ENABLED == 1
|
||||
sif::error << "ObjectManager::insert: Object id " << std::hex
|
||||
<< (int)id << std::dec << " is already in use!" << std::endl;
|
||||
<< static_cast<uint32_t> id << std::dec
|
||||
<< " is already in use!" << std::endl;
|
||||
sif::error << "Terminating program." << std::endl;
|
||||
#endif
|
||||
//This is very severe and difficult to handle in other places.
|
||||
std::exit(INSERTION_FAILED);
|
||||
}
|
||||
@ -33,12 +38,16 @@ ReturnValue_t ObjectManager::insert( object_id_t id, SystemObjectIF* object) {
|
||||
ReturnValue_t ObjectManager::remove( object_id_t id ) {
|
||||
if ( this->getSystemObject(id) != NULL ) {
|
||||
this->objectList.erase( id );
|
||||
#if CPP_OSTREAM_ENABLED == 1
|
||||
//sif::debug << "ObjectManager::removeObject: Object " << std::hex
|
||||
// << (int)id << std::dec << " removed." << std::endl;
|
||||
#endif
|
||||
return RETURN_OK;
|
||||
} else {
|
||||
#if CPP_OSTREAM_ENABLED == 1
|
||||
sif::error << "ObjectManager::removeObject: Requested object "
|
||||
<< std::hex << (int)id << std::dec << " not found." << std::endl;
|
||||
#endif
|
||||
return NOT_FOUND;
|
||||
}
|
||||
}
|
||||
@ -60,8 +69,10 @@ ObjectManager::ObjectManager() : produceObjects(nullptr) {
|
||||
|
||||
void ObjectManager::initialize() {
|
||||
if(produceObjects == nullptr) {
|
||||
#if CPP_OSTREAM_ENABLED == 1
|
||||
sif::error << "ObjectManager::initialize: Passed produceObjects "
|
||||
"functions is nullptr!" << std::endl;
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
this->produceObjects();
|
||||
@ -71,37 +82,48 @@ void ObjectManager::initialize() {
|
||||
result = it.second->initialize();
|
||||
if ( result != RETURN_OK ) {
|
||||
object_id_t var = it.first;
|
||||
#if CPP_OSTREAM_ENABLED == 1
|
||||
sif::error << "ObjectManager::initialize: Object 0x" << std::hex <<
|
||||
std::setw(8) << std::setfill('0')<< var << " failed to "
|
||||
"initialize with code 0x" << result << std::dec <<
|
||||
std::setfill(' ') << std::endl;
|
||||
#endif
|
||||
errorCount++;
|
||||
}
|
||||
}
|
||||
if (errorCount > 0) {
|
||||
#if CPP_OSTREAM_ENABLED == 1
|
||||
sif::error << "ObjectManager::ObjectManager: Counted " << errorCount
|
||||
<< " failed initializations." << std::endl;
|
||||
#endif
|
||||
}
|
||||
//Init was successful. Now check successful interconnections.
|
||||
errorCount = 0;
|
||||
for (auto const& it : objectList) {
|
||||
result = it.second->checkObjectConnections();
|
||||
if ( result != RETURN_OK ) {
|
||||
#if CPP_OSTREAM_ENABLED == 1
|
||||
sif::error << "ObjectManager::ObjectManager: Object " << std::hex <<
|
||||
(int) it.first << " connection check failed with code 0x"
|
||||
<< result << std::dec << std::endl;
|
||||
#endif
|
||||
errorCount++;
|
||||
}
|
||||
}
|
||||
if (errorCount > 0) {
|
||||
#if CPP_OSTREAM_ENABLED == 1
|
||||
sif::error << "ObjectManager::ObjectManager: Counted " << errorCount
|
||||
<< " failed connection checks." << std::endl;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
void ObjectManager::printList() {
|
||||
#if CPP_OSTREAM_ENABLED == 1
|
||||
sif::debug << "ObjectManager: Object List contains:" << std::endl;
|
||||
for (auto const& it : objectList) {
|
||||
sif::debug << std::hex << it.first << " | " << it.second << std::endl;
|
||||
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
@ -86,8 +86,10 @@ extern ObjectManagerIF *objectManager;
|
||||
template <typename T>
|
||||
T* ObjectManagerIF::get( object_id_t id ) {
|
||||
if(objectManager == nullptr) {
|
||||
#if CPP_OSTREAM_ENABLED == 1
|
||||
sif::error << "ObjectManagerIF: Global object manager has not "
|
||||
"been initialized yet!" << std::endl;
|
||||
#endif
|
||||
}
|
||||
SystemObjectIF* temp = this->getSystemObject(id);
|
||||
return dynamic_cast<T*>(temp);
|
||||
|
Reference in New Issue
Block a user