Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F61679990
Supervisor.cpp
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Wed, May 8, 07:06
Size
2 KB
Mime Type
text/x-c
Expires
Fri, May 10, 07:06 (2 d)
Engine
blob
Format
Raw Data
Handle
17544099
Attached To
R6622 liboncilla
Supervisor.cpp
View Options
/*
* Supervisor.cpp
*
* Created on: Jan 21, 2013
* Author: tuleu
*/
#include "Supervisor.h"
#include <liboncilla/utils/OncillaBackend.h>
#include "Oncilla.h"
namespace rci {
namespace oncilla {
Supervisor::Supervisor(OncillaBackend & backend)
: d_l4s(4,SupervisorL4::Ptr())
, d_trunk()
, d_world(){
d_l4s.resize(4);
d_l4Errors.resize(4);
LIBONCILLA_FOREACH_LEG(l) {
SupervisorL4::Ptr res;
try {
res = backend.CreateSupervisorL4(l,
Oncilla::nameOfLeg(l) + " Oncilla Supervised L4");
} catch(const std::exception & e) {
res = SupervisorL4::Ptr();
d_l4Errors[l] = RuntimeErrPtr(new std::runtime_error(e.what()));
}
if(!res) {
d_l4Errors[l] = RuntimeErrPtr(new std::runtime_error("Backend did not create " + Oncilla::nameOfLeg(l) + " SupervisorL4 node nor throw exception."));
}
d_l4s[l] = res;
if(Oncilla::willThrowOnInitialization() && d_l4Errors[l]) {
throw *(d_l4Errors[l]);
}
}
try {
d_trunk = backend.CreateSupervisorTrunk();
} catch(const std::exception & e) {
d_trunk = SupervisorTrunk::Ptr();
d_trunkError = RuntimeErrPtr(new std::runtime_error(e.what()));
}
if(!d_trunk) {
d_trunkError = RuntimeErrPtr(new std::runtime_error("Backend did not created SupervisorTrunk node nor throw exception."));
}
try{
d_world = backend.CreateSupervisorWorld();
} catch (const std::exception & e) {
d_world = SupervisorWorld::Ptr();
d_worldError = RuntimeErrPtr(new std::runtime_error(e.what()));
}
if (!d_world ) {
d_worldError = RuntimeErrPtr(new std::runtime_error("Backend did not created SupervisorWorld node nor throw exception."));
}
if(!Oncilla::willThrowOnInitialization()) {
return;
}
if(d_trunkError) {
throw *d_trunkError;
}
if(d_worldError) {
throw *d_worldError;
}
}
Supervisor::~Supervisor(){
}
const SupervisorTrunk::Ptr & Supervisor::getTrunk(){
if (!d_trunk) {
throw *d_trunkError;
}
return d_trunk;
}
const SupervisorL4::Ptr & Supervisor::getL4(Leg l){
if (l >= NUM_LEGS){
std::ostringstream os;
os << "Leg " << l << "is out of range [0 3].";
throw std::out_of_range(os.str());
}
if(!d_l4s[l]) {
throw *(d_l4Errors[l]);
}
return d_l4s[l];
}
const SupervisorWorld::Ptr & Supervisor::getWorld(){
if(!d_world){
throw * d_worldError;
}
return d_world;
}
} /* namespace oncilla */
} /* namespace rci */
Event Timeline
Log In to Comment