string ConfigObject::GetType(void) const
{
string type;
- GetProperties()->GetProperty("__type", &type);
+ GetProperties()->Get("__type", &type);
return type;
}
string ConfigObject::GetName(void) const
{
string name;
- GetProperties()->GetProperty("__name", &name);
+ GetProperties()->Get("__name", &name);
return name;
}
void ConfigObject::SetLocal(bool value)
{
- GetProperties()->SetProperty("__local", value ? 1 : 0);
+ GetProperties()->Set("__local", value ? 1 : 0);
}
bool ConfigObject::IsLocal(void) const
{
bool value = false;
- GetProperties()->GetProperty("__local", &value);
+ GetProperties()->Get("__local", &value);
return value;
}
void ConfigObject::SetAbstract(bool value)
{
- GetProperties()->SetProperty("__abstract", value ? 1 : 0);
+ GetProperties()->Set("__abstract", value ? 1 : 0);
}
bool ConfigObject::IsAbstract(void) const
{
bool value = false;
- GetProperties()->GetProperty("__abstract", &value);
+ GetProperties()->Get("__abstract", &value);
return value;
}
void ConfigObject::SetSource(const string& value)
{
- GetProperties()->SetProperty("__source", value);
+ GetProperties()->Set("__source", value);
}
string ConfigObject::GetSource(void) const
{
string value;
- GetProperties()->GetProperty("__source", &value);
+ GetProperties()->Get("__source", &value);
return value;
}
void ConfigObject::SetCommitTimestamp(time_t ts)
{
- GetProperties()->SetProperty("__tx", static_cast<long>(ts));
+ GetProperties()->Set("__tx", static_cast<long>(ts));
}
time_t ConfigObject::GetCommitTimestamp(void) const
{
long value = false;
- GetProperties()->GetProperty("__tx", &value);
+ GetProperties()->Get("__tx", &value);
return value;
}
template<typename T>
void SetProperty(const string& key, const T& value)
{
- GetProperties()->SetProperty(key, value);
+ GetProperties()->Set(key, value);
}
template<typename T>
bool GetProperty(const string& key, T *value) const
{
- return GetProperties()->GetProperty(key, value);
+ return GetProperties()->Get(key, value);
}
Dictionary::Ptr GetTags(void) const;
template<typename T>
void SetTag(const string& key, const T& value)
{
- GetTags()->SetProperty(key, value);
+ GetTags()->Set(key, value);
}
template<typename T>
bool GetTag(const string& key, T *value) const
{
- return GetTags()->GetProperty(key, value);
+ return GetTags()->Get(key, value);
}
string GetType(void) const;
*
* @param key The key.
*/
-void Dictionary::RemoveProperty(const string& key)
+void Dictionary::Remove(const string& key)
{
Dictionary::Iterator it;
it = m_Data.find(key);
* @returns true if the value was retrieved, false otherwise.
*/
template<typename T>
- bool GetProperty(const string& key, T *value) const
+ bool Get(const string& key, T *value) const
{
ConstIterator i = m_Data.find(key);
* @param[out] value Pointer to the value.
* @returns true if the value was retrieved, false otherwise.
*/
- bool GetProperty(const string& key, Dictionary::Ptr *value)
+ bool Get(const string& key, Dictionary::Ptr *value)
{
Object::Ptr object;
- if (!GetProperty(key, &object))
+ if (!Get(key, &object))
return false;
*value = dynamic_pointer_cast<Dictionary>(object);
* @param value The value.
*/
template<typename T>
- void SetProperty(const string& key, const T& value)
+ void Set(const string& key, const T& value)
{
pair<typename map<string, Variant>::iterator, bool> ret;
ret = m_Data.insert(make_pair(key, value));
* @param value The value.
*/
template<typename T>
- void AddUnnamedProperty(const T& value)
+ void Add(const T& value)
{
Iterator it;
string key;
it = m_Data.find(key);
} while (it != m_Data.end());
- SetProperty(key, value);
+ Set(key, value);
}
bool Contains(const string& key) const;
long GetLength(void) const;
- void RemoveProperty(const string& key);
+ void Remove(const string& key);
private:
map<string, Variant> m_Data;
void CheckResult::SetScheduleStart(time_t ts)
{
- SetProperty("schedule_start", static_cast<long>(ts));
+ Set("schedule_start", static_cast<long>(ts));
}
time_t CheckResult::GetScheduleStart(void) const
{
long value = 0;
- GetProperty("schedule_start", &value);
+ Get("schedule_start", &value);
return static_cast<time_t>(value);
}
void CheckResult::SetScheduleEnd(time_t ts)
{
- SetProperty("schedule_end", static_cast<long>(ts));
+ Set("schedule_end", static_cast<long>(ts));
}
time_t CheckResult::GetScheduleEnd(void) const
{
long value = 0;
- GetProperty("schedule_end", &value);
+ Get("schedule_end", &value);
return static_cast<time_t>(value);
}
void CheckResult::SetExecutionStart(time_t ts)
{
- SetProperty("execution_start", static_cast<long>(ts));
+ Set("execution_start", static_cast<long>(ts));
}
time_t CheckResult::GetExecutionStart(void) const
{
long value = 0;
- GetProperty("execution_start", &value);
+ Get("execution_start", &value);
return static_cast<time_t>(value);
}
void CheckResult::SetExecutionEnd(time_t ts)
{
- SetProperty("execution_end", static_cast<long>(ts));
+ Set("execution_end", static_cast<long>(ts));
}
time_t CheckResult::GetExecutionEnd(void) const
{
long value = 0;
- GetProperty("execution_end", &value);
+ Get("execution_end", &value);
return value;
}
void CheckResult::SetState(ServiceState state)
{
- SetProperty("state", static_cast<long>(state));
+ Set("state", static_cast<long>(state));
}
ServiceState CheckResult::GetState(void) const
{
long value = StateUnknown;
- GetProperty("state", &value);
+ Get("state", &value);
return static_cast<ServiceState>(value);
}
void CheckResult::SetOutput(string output)
{
- SetProperty("output", output);
+ Set("output", output);
}
string CheckResult::GetOutput(void) const
{
string value;
- GetProperty("output", &value);
+ Get("output", &value);
return value;
}
void CheckResult::SetPerformanceDataRaw(const string& pd)
{
- SetProperty("performance_data_raw", pd);
+ Set("performance_data_raw", pd);
}
string CheckResult::GetPerformanceDataRaw(void) const
{
string value;
- GetProperty("performance_data_raw", &value);
+ Get("performance_data_raw", &value);
return value;
}
void CheckResult::SetPerformanceData(const Dictionary::Ptr& pd)
{
- SetProperty("performance_data", pd);
+ Set("performance_data", pd);
}
Dictionary::Ptr CheckResult::GetPerformanceData(void) const
{
Dictionary::Ptr value;
- GetProperty("performance_data", &value);
+ Get("performance_data", &value);
return value;
}
string name = result.substr(pos_first + 1, pos_second - pos_first - 1);
string value;
- if (!macros || !macros->GetProperty(name, &value))
+ if (!macros || !macros->Get(name, &value))
throw runtime_error("Macro '" + name + "' is not defined.");
result.replace(pos_first, pos_second - pos_first + 1, value);
if (result->Contains(it->second))
continue;
- result->SetProperty(it->second, it->second);
+ result->Set(it->second, it->second);
Service service = Service::GetByName(it->second);
service.GetDependenciesRecursive(result);
else
name = it->first;
- result->SetProperty(name, name);
+ result->Set(name, name);
}
return result;
bool ServiceStatusMessage::GetService(string *service) const
{
- return GetProperty("service", service);
+ return Get("service", service);
}
void ServiceStatusMessage::SetService(const string& service)
{
- SetProperty("service", service);
+ Set("service", service);
}
bool ServiceStatusMessage::GetState(ServiceState *state) const
{
long value;
- if (GetProperty("state", &value)) {
+ if (Get("state", &value)) {
*state = static_cast<ServiceState>(value);
return true;
}
void ServiceStatusMessage::SetState(ServiceState state)
{
- SetProperty("state", static_cast<long>(state));
+ Set("state", static_cast<long>(state));
}
bool ServiceStatusMessage::GetStateType(ServiceStateType *type) const
{
long value;
- if (GetProperty("state_type", &value)) {
+ if (Get("state_type", &value)) {
*type = static_cast<ServiceStateType>(value);
return true;
}
void ServiceStatusMessage::SetStateType(ServiceStateType type)
{
- SetProperty("state_type", static_cast<long>(type));
+ Set("state_type", static_cast<long>(type));
}
bool ServiceStatusMessage::GetCurrentCheckAttempt(long *attempt) const
{
- return GetProperty("current_attempt", attempt);
+ return Get("current_attempt", attempt);
}
void ServiceStatusMessage::SetCurrentCheckAttempt(long attempt)
{
- SetProperty("current_attempt", attempt);
+ Set("current_attempt", attempt);
}
bool ServiceStatusMessage::GetNextCheck(time_t *ts) const
{
long value;
- if (GetProperty("next_check", &value)) {
+ if (Get("next_check", &value)) {
*ts = value;
return true;
}
void ServiceStatusMessage::SetNextCheck(time_t ts)
{
- SetProperty("next_check", static_cast<long>(ts));
+ Set("next_check", static_cast<long>(ts));
}
bool ServiceStatusMessage::GetCheckResult(CheckResult *cr) const
{
Dictionary::Ptr obj;
- if (GetProperty("result", &obj)) {
+ if (Get("result", &obj)) {
*cr = CheckResult(MessagePart(obj));
return true;
}
void ServiceStatusMessage::SetCheckResult(CheckResult cr)
{
- SetProperty("result", cr.GetDictionary());
-}
\ No newline at end of file
+ Set("result", cr.GetDictionary());
+}
return;
MessagePart serviceMsg;
- if (!params.GetProperty("service", &serviceMsg))
+ if (!params.Get("service", &serviceMsg))
return;
ConfigObject::Ptr object = boost::make_shared<ConfigObject>(serviceMsg.GetDictionary());
MessagePart params;
msg.SetParams(params);
- params.SetProperty("name", object->GetName());
- params.SetProperty("type", object->GetType());
+ params.Set("name", object->GetName());
+ params.Set("type", object->GetType());
if (includeProperties)
- params.SetProperty("properties", object->GetProperties());
+ params.Set("properties", object->GetProperties());
return msg;
}
return;
string name;
- if (!params.GetProperty("name", &name))
+ if (!params.Get("name", &name))
return;
string type;
- if (!params.GetProperty("type", &type))
+ if (!params.Get("type", &type))
return;
MessagePart properties;
- if (!params.GetProperty("properties", &properties))
+ if (!params.Get("properties", &properties))
return;
ConfigObject::Ptr object = ConfigObject::GetObject(type, name);
return;
string name;
- if (!params.GetProperty("name", &name))
+ if (!params.Get("name", &name))
return;
string type;
- if (!params.GetProperty("type", &type))
+ if (!params.Get("type", &type))
return;
ConfigObject::Ptr object = ConfigObject::GetObject(type, name);
void ConvenienceComponent::CopyServiceAttributes(const ConfigObject::Ptr& host, const Dictionary::Ptr& service, const ConfigItemBuilder::Ptr& builder)
{
Dictionary::Ptr macros;
- if (service->GetProperty("macros", ¯os))
+ if (service->Get("macros", ¯os))
builder->AddExpression("macros", OperatorPlus, macros);
long checkInterval;
- if (service->GetProperty("check_interval", &checkInterval))
+ if (service->Get("check_interval", &checkInterval))
builder->AddExpression("check_interval", OperatorSet, checkInterval);
long retryInterval;
- if (service->GetProperty("retry_interval", &retryInterval))
+ if (service->Get("retry_interval", &retryInterval))
builder->AddExpression("retry_interval", OperatorSet, retryInterval);
Dictionary::Ptr sgroups;
- if (service->GetProperty("servicegroups", &sgroups))
+ if (service->Get("servicegroups", &sgroups))
builder->AddExpression("servicegroups", OperatorPlus, sgroups);
Dictionary::Ptr checkers;
- if (service->GetProperty("checkers", &checkers))
+ if (service->Get("checkers", &checkers))
builder->AddExpression("checkers", OperatorSet, checkers);
Dictionary::Ptr dependencies;
- if (service->GetProperty("dependencies", &dependencies))
+ if (service->Get("dependencies", &dependencies))
builder->AddExpression("dependencies", OperatorPlus,
Service::ResolveDependencies(host, dependencies));
Dictionary::Ptr hostchecks;
- if (service->GetProperty("hostchecks", &hostchecks))
+ if (service->Get("hostchecks", &hostchecks))
builder->AddExpression("dependencies", OperatorPlus,
Service::ResolveDependencies(host, hostchecks));
}
throw invalid_argument("Service description invalid.");
string parent;
- if (!service->GetProperty("service", &parent))
+ if (!service->Get("service", &parent))
parent = svcname;
builder->AddParent(parent);
ConfigItem::Ptr serviceItem = builder->Compile();
serviceItem->Commit();
- newServices->SetProperty(name, serviceItem);
+ newServices->Set(name, serviceItem);
}
}
request.SetMethod("checker::AssignService");
MessagePart params;
- params.SetProperty("service", service.GetConfigObject()->GetProperties());
+ params.Set("service", service.GetConfigObject()->GetProperties());
request.SetParams(params);
Application::Log(LogDebug, "delegation", "Trying to delegate service '" + service.GetName() + "'");
set<string>::iterator i;
MessagePart subscriptions;
for (i = info->Subscriptions.begin(); i != info->Subscriptions.end(); i++)
- subscriptions.AddUnnamedProperty(*i);
+ subscriptions.Add(*i);
params.SetSubscriptions(subscriptions);
MessagePart publications;
for (i = info->Publications.begin(); i != info->Publications.end(); i++)
- publications.AddUnnamedProperty(*i);
+ publications.Add(*i);
params.SetPublications(publications);
bool DiscoveryMessage::GetIdentity(string *value) const
{
- return GetProperty("identity", value);
+ return Get("identity", value);
}
void DiscoveryMessage::SetIdentity(const string& value)
{
- SetProperty("identity", value);
+ Set("identity", value);
}
bool DiscoveryMessage::GetNode(string *value) const
{
- return GetProperty("node", value);
+ return Get("node", value);
}
void DiscoveryMessage::SetNode(const string& value)
{
- SetProperty("node", value);
+ Set("node", value);
}
bool DiscoveryMessage::GetService(string *value) const
{
- return GetProperty("service", value);
+ return Get("service", value);
}
void DiscoveryMessage::SetService(const string& value)
{
- SetProperty("service", value);
+ Set("service", value);
}
bool DiscoveryMessage::GetSubscriptions(MessagePart *value) const
{
- return GetProperty("subscriptions", value);
+ return Get("subscriptions", value);
}
void DiscoveryMessage::SetSubscriptions(MessagePart value)
{
- SetProperty("subscriptions", value);
+ Set("subscriptions", value);
}
bool DiscoveryMessage::GetPublications(MessagePart *value) const
{
- return GetProperty("publications", value);
+ return Get("publications", value);
}
void DiscoveryMessage::SetPublications(MessagePart value)
{
- SetProperty("publications", value);
-}
\ No newline at end of file
+ Set("publications", value);
+}
/* Line 1806 of yacc.c */
#line 259 "config_parser.yy"
{
- m_Array->AddUnnamedProperty(*(yyvsp[(1) - (1)].variant));
+ m_Array->Add(*(yyvsp[(1) - (1)].variant));
delete (yyvsp[(1) - (1)].variant);
}
break;
tupleitem: simplevalue
{
- m_Array->AddUnnamedProperty(*$1);
+ m_Array->Add(*$1);
delete $1;
}
break;
case OperatorPlus:
- dictionary->GetProperty(m_Key, &oldValue);
+ dictionary->Get(m_Key, &oldValue);
if (oldValue.GetType() == VariantObject)
dict = dynamic_pointer_cast<Dictionary>(oldValue.GetObject());
} else if (valueDict) {
Dictionary::Iterator it;
for (it = valueDict->Begin(); it != valueDict->End(); it++) {
- dict->SetProperty(it->first, it->second);
+ dict->Set(it->first, it->second);
}
} else {
stringstream message;
throw runtime_error("Not yet implemented.");
}
- dictionary->SetProperty(m_Key, newValue);
+ dictionary->Set(m_Key, newValue);
}
return;
}
+ RequestMessage request = message;
+
string method;
- if (!message.GetProperty("method", &method))
+ if (!request.GetMethod(&method))
return;
if (!HasPublication(method))
return;
- RequestMessage request = message;
-
string id;
if (request.GetID(&id))
GetEndpointManager()->SendAnycastMessage(sender, request);
for (cJSON *i = json->child; i != NULL; i = i->next) {
switch (i->type) {
case cJSON_Number:
- dictionary->SetProperty(i->string, i->valueint);
+ dictionary->Set(i->string, i->valueint);
break;
case cJSON_String:
- dictionary->SetProperty(i->string, i->valuestring);
+ dictionary->Set(i->string, i->valuestring);
break;
case cJSON_Object:
- dictionary->SetProperty(i->string, GetDictionaryFromJson(i));
+ dictionary->Set(i->string, GetDictionaryFromJson(i));
break;
default:
break;
* @param[out] The value.
* @returns true if the value was retrieved, false otherwise.
*/
-bool MessagePart::GetProperty(string key, MessagePart *value) const
+bool MessagePart::Get(string key, MessagePart *value) const
{
Object::Ptr object;
- if (!GetDictionary()->GetProperty(key, &object))
+ if (!GetDictionary()->Get(key, &object))
return false;
Dictionary::Ptr dictionary = dynamic_pointer_cast<Dictionary>(object);
* @param key The name of the property.
* @param value The value.
*/
-void MessagePart::SetProperty(string key, const MessagePart& value)
+void MessagePart::Set(string key, const MessagePart& value)
{
- GetDictionary()->SetProperty(key, value.GetDictionary());
+ GetDictionary()->Set(key, value.GetDictionary());
}
/**
*
* @param value The value.
*/
-void MessagePart::AddUnnamedProperty(const MessagePart& value)
+void MessagePart::Add(const MessagePart& value)
{
- GetDictionary()->AddUnnamedProperty(value.GetDictionary());
+ GetDictionary()->Add(value.GetDictionary());
}
/**
* @returns true if the value was retrieved, false otherwise.
*/
template<typename T>
- bool GetProperty(string key, T *value) const
+ bool Get(string key, T *value) const
{
- return GetDictionary()->GetProperty(key, value);
+ return GetDictionary()->Get(key, value);
}
/**
* @param value The value.
*/
template<typename T>
- void SetProperty(string key, const T& value)
+ void Set(string key, const T& value)
{
- GetDictionary()->SetProperty(key, value);
+ GetDictionary()->Set(key, value);
}
- bool GetProperty(string key, MessagePart *value) const;
- void SetProperty(string key, const MessagePart& value);
+ bool Get(string key, MessagePart *value) const;
+ void Set(string key, const MessagePart& value);
/**
* Adds an item to the message using an automatically generated property name.
* @param value The value.
*/
template<typename T>
- void AddUnnamedProperty(const T& value)
+ void Add(const T& value)
{
- GetDictionary()->AddUnnamedProperty(value);
+ GetDictionary()->Add(value);
}
- void AddUnnamedProperty(const MessagePart& value);
+ void Add(const MessagePart& value);
bool Contains(const string& key) const;
*/
inline bool GetVersion(string *value) const
{
- return GetProperty("jsonrpc", value);
+ return Get("jsonrpc", value);
}
/**
*/
inline void SetVersion(const string& value)
{
- SetProperty("jsonrpc", value);
+ Set("jsonrpc", value);
}
/**
*/
inline bool GetMethod(string *value) const
{
- return GetProperty("method", value);
+ return Get("method", value);
}
/**
*/
inline void SetMethod(const string& value)
{
- SetProperty("method", value);
+ Set("method", value);
}
/**
*/
inline bool GetParams(MessagePart *value) const
{
- return GetProperty("params", value);
+ return Get("params", value);
}
/**
*/
inline void SetParams(const MessagePart& value)
{
- SetProperty("params", value);
+ Set("params", value);
}
/**
*/
inline bool GetID(string *value) const
{
- return GetProperty("id", value);
+ return Get("id", value);
}
/**
*/
inline void SetID(const string& value)
{
- SetProperty("id", value);
+ Set("id", value);
}
};
*/
inline bool GetVersion(string *value) const
{
- return GetProperty("jsonrpc", value);
+ return Get("jsonrpc", value);
}
/**
*/
inline void SetVersion(const string& value)
{
- SetProperty("jsonrpc", value);
+ Set("jsonrpc", value);
}
/**
*/
bool GetResult(MessagePart *value) const
{
- return GetProperty("result", value);
+ return Get("result", value);
}
/**
*/
void SetResult(const MessagePart& value)
{
- SetProperty("result", value);
+ Set("result", value);
}
/**
*/
bool GetError(string *value) const
{
- return GetProperty("error", value);
+ return Get("error", value);
}
/**
*/
void SetError(const string& value)
{
- SetProperty("error", value);
+ Set("error", value);
}
/**
*/
bool GetID(string *value) const
{
- return GetProperty("id", value);
+ return Get("id", value);
}
/**
*/
void SetID(const string& value)
{
- SetProperty("id", value);
+ Set("id", value);
}
/**
BOOST_AUTO_TEST_CASE(getproperty)
{
Dictionary::Ptr dictionary = make_shared<Dictionary>();
- dictionary->SetProperty("test1", 7);
- dictionary->SetProperty("test2", "hello world");
+ dictionary->Set("test1", 7);
+ dictionary->Set("test2", "hello world");
long test1;
- BOOST_REQUIRE(dictionary->GetProperty("test1", &test1));
+ BOOST_REQUIRE(dictionary->Get("test1", &test1));
BOOST_REQUIRE(test1 == 7);
string test2;
- BOOST_REQUIRE(dictionary->GetProperty("test2", &test2));
+ BOOST_REQUIRE(dictionary->Get("test2", &test2));
BOOST_REQUIRE(test2 == "hello world");
long test3;
- BOOST_REQUIRE(!dictionary->GetProperty("test3", &test3));
+ BOOST_REQUIRE(!dictionary->Get("test3", &test3));
}
BOOST_AUTO_TEST_CASE(getproperty_dict)
Dictionary::Ptr dictionary = make_shared<Dictionary>();
Dictionary::Ptr other = make_shared<Dictionary>();
- dictionary->SetProperty("test1", other);
+ dictionary->Set("test1", other);
Dictionary::Ptr test1;
- BOOST_REQUIRE(dictionary->GetProperty("test1", &test1));
+ BOOST_REQUIRE(dictionary->Get("test1", &test1));
BOOST_REQUIRE(other == test1);
Dictionary::Ptr test2;
- BOOST_REQUIRE(!dictionary->GetProperty("test2", &test2));
+ BOOST_REQUIRE(!dictionary->Get("test2", &test2));
}
BOOST_AUTO_TEST_CASE(unnamed)
{
Dictionary::Ptr dictionary = make_shared<Dictionary>();
- dictionary->AddUnnamedProperty("test1");
- dictionary->AddUnnamedProperty("test2");
- dictionary->AddUnnamedProperty("test3");
+ dictionary->Add("test1");
+ dictionary->Add("test2");
+ dictionary->Add("test3");
BOOST_REQUIRE(distance(dictionary->Begin(), dictionary->End()) == 3);
}