Commit 5fc82613 authored by Franck Cecillon's avatar Franck Cecillon
parents aca9232e 6f0717ef
......@@ -29,6 +29,24 @@ using namespace std;
using namespace boost;
using namespace command;
PropertyManager::UnknownProperty::UnknownProperty(const std::string& name) {
_message = "Unknown property ";
_message += name;
}
const char* PropertyManager::UnknownProperty::what() const noexcept {
return _message.c_str();
}
PropertyManager::CannotSetValue::CannotSetValue(const std::string& name) {
_message = "Cannot set value of property ";
_message += name;
}
const char* PropertyManager::CannotSetValue::what() const noexcept {
return _message.c_str();
}
PropertyManager::PropertyManager(const std::string& name) :
_name(name),
_servantID(0),
......@@ -195,7 +213,7 @@ AnyProperty* PropertyManager::getProperty(const string& propertyName) const thro
map<string, AnyProperty*>::const_iterator p = _propertiesMap.find(propertyName);
if (p == _propertiesMap.end()) {
throw UnknownProperty();
throw UnknownProperty(propertyName);
}
return p->second;
......@@ -207,7 +225,7 @@ const string& PropertyManager::getType(const string& propertyName) const throw (
map<string, AnyProperty*>::const_iterator p = _propertiesMap.find(propertyName);
if (p == _propertiesMap.end()) {
throw UnknownProperty();
throw UnknownProperty(propertyName);
}
return p->second->getType();
......@@ -224,7 +242,7 @@ boost::any PropertyManager::getValue(const std::string& propertyName) throw (Unk
map<string, AnyProperty*>::const_iterator p = _propertiesMap.find(propertyName);
if (p == _propertiesMap.end()) {
throw UnknownProperty();
throw UnknownProperty(propertyName);
}
return p->second->getValue();
......@@ -236,13 +254,13 @@ void PropertyManager::setValue(const std::string& propertyName, const boost::any
map<string, AnyProperty*>::iterator p = _propertiesMap.find(propertyName);
if (p == _propertiesMap.end()) {
throw UnknownProperty();
throw UnknownProperty(propertyName);
}
try {
p->second->setValue(value);
} catch (AnyProperty::CannotSetValue& e) {
throw CannotSetValue();
throw CannotSetValue(propertyName);
}
}
......@@ -252,13 +270,13 @@ void PropertyManager::setValueAndFormattedValue(const std::string& propertyName,
map<string, AnyProperty*>::iterator p = _propertiesMap.find(propertyName);
if (p == _propertiesMap.end()) {
throw UnknownProperty();
throw UnknownProperty(propertyName);
}
try {
p->second->setValueAndFormattedValue(value, formattedValue);
} catch (AnyProperty::CannotSetValue& e) {
throw CannotSetValue();
throw CannotSetValue(propertyName);
}
}
......@@ -268,7 +286,7 @@ int32 PropertyManager::getSize(const std::string& propertyName) const throw (Unk
map<string, AnyProperty*>::const_iterator p = _propertiesMap.find(propertyName);
if (p == _propertiesMap.end()) {
throw UnknownProperty();
throw UnknownProperty(propertyName);
}
return p->second->getSize();
......@@ -280,7 +298,7 @@ void PropertyManager::setSize(const std::string& propertyName, int32 value) thro
map<string, AnyProperty*>::iterator p = _propertiesMap.find(propertyName);
if (p == _propertiesMap.end()) {
throw UnknownProperty();
throw UnknownProperty(propertyName);
}
p->second->setSize(value);
......@@ -292,7 +310,7 @@ int32 PropertyManager::getExtraSize(const std::string& propertyName) const throw
map<string, AnyProperty*>::const_iterator p = _propertiesMap.find(propertyName);
if (p == _propertiesMap.end()) {
throw UnknownProperty();
throw UnknownProperty(propertyName);
}
return p->second->getExtraSize();
......@@ -304,7 +322,7 @@ void PropertyManager::setExtraSize(const std::string& propertyName, int32 value)
map<string, AnyProperty*>::iterator p = _propertiesMap.find(propertyName);
if (p == _propertiesMap.end()) {
throw UnknownProperty();
throw UnknownProperty(propertyName);
}
p->second->setExtraSize(value);
......@@ -571,7 +589,7 @@ std::string PropertyManager::getPropertyName(uint32 propertyID) const {
}
}
throw UnknownProperty();
throw UnknownProperty("?");
}
uint32 PropertyManager::getServantID() const {
......
......@@ -43,13 +43,26 @@ class PropertyManager {
friend class PropertyUpdater;
public:
class UnknownProperty {
};
class UnknownProperty : public std::exception {
public:
UnknownProperty(const std::string& name);
virtual const char* what() const noexcept;
class BadTypeProperty {
private:
std::string _message;
};
class CannotSetValue {
class BadTypeProperty {};
class CannotSetValue : public std::exception {
public:
CannotSetValue(const std::string& name);
virtual const char* what() const noexcept;
private:
std::string _message;
};
PropertyManager(const std::string& name);
......
......@@ -22,6 +22,12 @@ namespace controller {
Read::Read(ExperimentController * controller) : Command(controller, "read", &Read::read, this) {}
Read::Read() : Command() {}
void Read::init(ExperimentController * controller) {
Command::init(controller, "read", &Read::read, this);
}
void Read::readCommand(bool logging) {
// second parameter indicates that AgentPolicy is used to block the call
// i.e. the call never blocks
......
......@@ -27,7 +27,9 @@ class Read : private Command {
public:
Read(ExperimentController * controller);
Read();
void init(ExperimentController * controller);
virtual void read() = 0;
void readCommand(bool logging = false);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment