Renamed Dictionary::{Set,Get}Property -> Dictionary::{Set,Get}

This commit is contained in:
Gunnar Beutner 2012-07-09 16:19:56 +02:00
parent 8d27f66b83
commit 777f39c1ef
23 changed files with 139 additions and 139 deletions

View File

@ -52,62 +52,62 @@ Dictionary::Ptr ConfigObject::GetTags(void) const
string ConfigObject::GetType(void) const string ConfigObject::GetType(void) const
{ {
string type; string type;
GetProperties()->GetProperty("__type", &type); GetProperties()->Get("__type", &type);
return type; return type;
} }
string ConfigObject::GetName(void) const string ConfigObject::GetName(void) const
{ {
string name; string name;
GetProperties()->GetProperty("__name", &name); GetProperties()->Get("__name", &name);
return name; return name;
} }
void ConfigObject::SetLocal(bool value) void ConfigObject::SetLocal(bool value)
{ {
GetProperties()->SetProperty("__local", value ? 1 : 0); GetProperties()->Set("__local", value ? 1 : 0);
} }
bool ConfigObject::IsLocal(void) const bool ConfigObject::IsLocal(void) const
{ {
bool value = false; bool value = false;
GetProperties()->GetProperty("__local", &value); GetProperties()->Get("__local", &value);
return value; return value;
} }
void ConfigObject::SetAbstract(bool value) void ConfigObject::SetAbstract(bool value)
{ {
GetProperties()->SetProperty("__abstract", value ? 1 : 0); GetProperties()->Set("__abstract", value ? 1 : 0);
} }
bool ConfigObject::IsAbstract(void) const bool ConfigObject::IsAbstract(void) const
{ {
bool value = false; bool value = false;
GetProperties()->GetProperty("__abstract", &value); GetProperties()->Get("__abstract", &value);
return value; return value;
} }
void ConfigObject::SetSource(const string& value) void ConfigObject::SetSource(const string& value)
{ {
GetProperties()->SetProperty("__source", value); GetProperties()->Set("__source", value);
} }
string ConfigObject::GetSource(void) const string ConfigObject::GetSource(void) const
{ {
string value; string value;
GetProperties()->GetProperty("__source", &value); GetProperties()->Get("__source", &value);
return value; return value;
} }
void ConfigObject::SetCommitTimestamp(time_t ts) 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 time_t ConfigObject::GetCommitTimestamp(void) const
{ {
long value = false; long value = false;
GetProperties()->GetProperty("__tx", &value); GetProperties()->Get("__tx", &value);
return value; return value;
} }

View File

@ -47,13 +47,13 @@ public:
template<typename T> template<typename T>
void SetProperty(const string& key, const T& value) void SetProperty(const string& key, const T& value)
{ {
GetProperties()->SetProperty(key, value); GetProperties()->Set(key, value);
} }
template<typename T> template<typename T>
bool GetProperty(const string& key, T *value) const bool GetProperty(const string& key, T *value) const
{ {
return GetProperties()->GetProperty(key, value); return GetProperties()->Get(key, value);
} }
Dictionary::Ptr GetTags(void) const; Dictionary::Ptr GetTags(void) const;
@ -61,13 +61,13 @@ public:
template<typename T> template<typename T>
void SetTag(const string& key, const T& value) void SetTag(const string& key, const T& value)
{ {
GetTags()->SetProperty(key, value); GetTags()->Set(key, value);
} }
template<typename T> template<typename T>
bool GetTag(const string& key, T *value) const bool GetTag(const string& key, T *value) const
{ {
return GetTags()->GetProperty(key, value); return GetTags()->Get(key, value);
} }
string GetType(void) const; string GetType(void) const;

View File

@ -67,7 +67,7 @@ bool Dictionary::Contains(const string& key) const
* *
* @param key The key. * @param key The key.
*/ */
void Dictionary::RemoveProperty(const string& key) void Dictionary::Remove(const string& key)
{ {
Dictionary::Iterator it; Dictionary::Iterator it;
it = m_Data.find(key); it = m_Data.find(key);

View File

@ -45,7 +45,7 @@ public:
* @returns true if the value was retrieved, false otherwise. * @returns true if the value was retrieved, false otherwise.
*/ */
template<typename T> 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); ConstIterator i = m_Data.find(key);
@ -64,11 +64,11 @@ public:
* @param[out] value Pointer to the value. * @param[out] value Pointer to the value.
* @returns true if the value was retrieved, false otherwise. * @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; Object::Ptr object;
if (!GetProperty(key, &object)) if (!Get(key, &object))
return false; return false;
*value = dynamic_pointer_cast<Dictionary>(object); *value = dynamic_pointer_cast<Dictionary>(object);
@ -85,7 +85,7 @@ public:
* @param value The value. * @param value The value.
*/ */
template<typename T> 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; pair<typename map<string, Variant>::iterator, bool> ret;
ret = m_Data.insert(make_pair(key, value)); ret = m_Data.insert(make_pair(key, value));
@ -99,7 +99,7 @@ public:
* @param value The value. * @param value The value.
*/ */
template<typename T> template<typename T>
void AddUnnamedProperty(const T& value) void Add(const T& value)
{ {
Iterator it; Iterator it;
string key; string key;
@ -113,7 +113,7 @@ public:
it = m_Data.find(key); it = m_Data.find(key);
} while (it != m_Data.end()); } while (it != m_Data.end());
SetProperty(key, value); Set(key, value);
} }
bool Contains(const string& key) const; bool Contains(const string& key) const;
@ -123,7 +123,7 @@ public:
long GetLength(void) const; long GetLength(void) const;
void RemoveProperty(const string& key); void Remove(const string& key);
private: private:
map<string, Variant> m_Data; map<string, Variant> m_Data;

View File

@ -12,96 +12,96 @@ CheckResult::CheckResult(const MessagePart& message)
void CheckResult::SetScheduleStart(time_t ts) 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 time_t CheckResult::GetScheduleStart(void) const
{ {
long value = 0; long value = 0;
GetProperty("schedule_start", &value); Get("schedule_start", &value);
return static_cast<time_t>(value); return static_cast<time_t>(value);
} }
void CheckResult::SetScheduleEnd(time_t ts) 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 time_t CheckResult::GetScheduleEnd(void) const
{ {
long value = 0; long value = 0;
GetProperty("schedule_end", &value); Get("schedule_end", &value);
return static_cast<time_t>(value); return static_cast<time_t>(value);
} }
void CheckResult::SetExecutionStart(time_t ts) 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 time_t CheckResult::GetExecutionStart(void) const
{ {
long value = 0; long value = 0;
GetProperty("execution_start", &value); Get("execution_start", &value);
return static_cast<time_t>(value); return static_cast<time_t>(value);
} }
void CheckResult::SetExecutionEnd(time_t ts) 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 time_t CheckResult::GetExecutionEnd(void) const
{ {
long value = 0; long value = 0;
GetProperty("execution_end", &value); Get("execution_end", &value);
return value; return value;
} }
void CheckResult::SetState(ServiceState state) void CheckResult::SetState(ServiceState state)
{ {
SetProperty("state", static_cast<long>(state)); Set("state", static_cast<long>(state));
} }
ServiceState CheckResult::GetState(void) const ServiceState CheckResult::GetState(void) const
{ {
long value = StateUnknown; long value = StateUnknown;
GetProperty("state", &value); Get("state", &value);
return static_cast<ServiceState>(value); return static_cast<ServiceState>(value);
} }
void CheckResult::SetOutput(string output) void CheckResult::SetOutput(string output)
{ {
SetProperty("output", output); Set("output", output);
} }
string CheckResult::GetOutput(void) const string CheckResult::GetOutput(void) const
{ {
string value; string value;
GetProperty("output", &value); Get("output", &value);
return value; return value;
} }
void CheckResult::SetPerformanceDataRaw(const string& pd) void CheckResult::SetPerformanceDataRaw(const string& pd)
{ {
SetProperty("performance_data_raw", pd); Set("performance_data_raw", pd);
} }
string CheckResult::GetPerformanceDataRaw(void) const string CheckResult::GetPerformanceDataRaw(void) const
{ {
string value; string value;
GetProperty("performance_data_raw", &value); Get("performance_data_raw", &value);
return value; return value;
} }
void CheckResult::SetPerformanceData(const Dictionary::Ptr& pd) void CheckResult::SetPerformanceData(const Dictionary::Ptr& pd)
{ {
SetProperty("performance_data", pd); Set("performance_data", pd);
} }
Dictionary::Ptr CheckResult::GetPerformanceData(void) const Dictionary::Ptr CheckResult::GetPerformanceData(void) const
{ {
Dictionary::Ptr value; Dictionary::Ptr value;
GetProperty("performance_data", &value); Get("performance_data", &value);
return value; return value;
} }

View File

@ -17,7 +17,7 @@ string MacroProcessor::ResolveMacros(const string& str, const Dictionary::Ptr& m
string name = result.substr(pos_first + 1, pos_second - pos_first - 1); string name = result.substr(pos_first + 1, pos_second - pos_first - 1);
string value; string value;
if (!macros || !macros->GetProperty(name, &value)) if (!macros || !macros->Get(name, &value))
throw runtime_error("Macro '" + name + "' is not defined."); throw runtime_error("Macro '" + name + "' is not defined.");
result.replace(pos_first, pos_second - pos_first + 1, value); result.replace(pos_first, pos_second - pos_first + 1, value);

View File

@ -106,7 +106,7 @@ void Service::GetDependenciesRecursive(const Dictionary::Ptr& result) const {
if (result->Contains(it->second)) if (result->Contains(it->second))
continue; continue;
result->SetProperty(it->second, it->second); result->Set(it->second, it->second);
Service service = Service::GetByName(it->second); Service service = Service::GetByName(it->second);
service.GetDependenciesRecursive(result); service.GetDependenciesRecursive(result);
@ -383,7 +383,7 @@ Dictionary::Ptr Service::ResolveDependencies(Host host, const Dictionary::Ptr& d
else else
name = it->first; name = it->first;
result->SetProperty(name, name); result->Set(name, name);
} }
return result; return result;

View File

@ -4,18 +4,18 @@ using namespace icinga;
bool ServiceStatusMessage::GetService(string *service) const bool ServiceStatusMessage::GetService(string *service) const
{ {
return GetProperty("service", service); return Get("service", service);
} }
void ServiceStatusMessage::SetService(const string& service) void ServiceStatusMessage::SetService(const string& service)
{ {
SetProperty("service", service); Set("service", service);
} }
bool ServiceStatusMessage::GetState(ServiceState *state) const bool ServiceStatusMessage::GetState(ServiceState *state) const
{ {
long value; long value;
if (GetProperty("state", &value)) { if (Get("state", &value)) {
*state = static_cast<ServiceState>(value); *state = static_cast<ServiceState>(value);
return true; return true;
} }
@ -24,13 +24,13 @@ bool ServiceStatusMessage::GetState(ServiceState *state) const
void ServiceStatusMessage::SetState(ServiceState state) void ServiceStatusMessage::SetState(ServiceState state)
{ {
SetProperty("state", static_cast<long>(state)); Set("state", static_cast<long>(state));
} }
bool ServiceStatusMessage::GetStateType(ServiceStateType *type) const bool ServiceStatusMessage::GetStateType(ServiceStateType *type) const
{ {
long value; long value;
if (GetProperty("state_type", &value)) { if (Get("state_type", &value)) {
*type = static_cast<ServiceStateType>(value); *type = static_cast<ServiceStateType>(value);
return true; return true;
} }
@ -39,23 +39,23 @@ bool ServiceStatusMessage::GetStateType(ServiceStateType *type) const
void ServiceStatusMessage::SetStateType(ServiceStateType type) 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 bool ServiceStatusMessage::GetCurrentCheckAttempt(long *attempt) const
{ {
return GetProperty("current_attempt", attempt); return Get("current_attempt", attempt);
} }
void ServiceStatusMessage::SetCurrentCheckAttempt(long attempt) void ServiceStatusMessage::SetCurrentCheckAttempt(long attempt)
{ {
SetProperty("current_attempt", attempt); Set("current_attempt", attempt);
} }
bool ServiceStatusMessage::GetNextCheck(time_t *ts) const bool ServiceStatusMessage::GetNextCheck(time_t *ts) const
{ {
long value; long value;
if (GetProperty("next_check", &value)) { if (Get("next_check", &value)) {
*ts = value; *ts = value;
return true; return true;
} }
@ -64,13 +64,13 @@ bool ServiceStatusMessage::GetNextCheck(time_t *ts) const
void ServiceStatusMessage::SetNextCheck(time_t ts) 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 bool ServiceStatusMessage::GetCheckResult(CheckResult *cr) const
{ {
Dictionary::Ptr obj; Dictionary::Ptr obj;
if (GetProperty("result", &obj)) { if (Get("result", &obj)) {
*cr = CheckResult(MessagePart(obj)); *cr = CheckResult(MessagePart(obj));
return true; return true;
} }
@ -79,5 +79,5 @@ bool ServiceStatusMessage::GetCheckResult(CheckResult *cr) const
void ServiceStatusMessage::SetCheckResult(CheckResult cr) void ServiceStatusMessage::SetCheckResult(CheckResult cr)
{ {
SetProperty("result", cr.GetDictionary()); Set("result", cr.GetDictionary());
} }

View File

@ -184,7 +184,7 @@ void CheckerComponent::AssignServiceRequestHandler(const Endpoint::Ptr& sender,
return; return;
MessagePart serviceMsg; MessagePart serviceMsg;
if (!params.GetProperty("service", &serviceMsg)) if (!params.Get("service", &serviceMsg))
return; return;
ConfigObject::Ptr object = boost::make_shared<ConfigObject>(serviceMsg.GetDictionary()); ConfigObject::Ptr object = boost::make_shared<ConfigObject>(serviceMsg.GetDictionary());

View File

@ -153,11 +153,11 @@ RequestMessage CIBSyncComponent::MakeObjectMessage(const ConfigObject::Ptr& obje
MessagePart params; MessagePart params;
msg.SetParams(params); msg.SetParams(params);
params.SetProperty("name", object->GetName()); params.Set("name", object->GetName());
params.SetProperty("type", object->GetType()); params.Set("type", object->GetType());
if (includeProperties) if (includeProperties)
params.SetProperty("properties", object->GetProperties()); params.Set("properties", object->GetProperties());
return msg; return msg;
} }
@ -216,15 +216,15 @@ void CIBSyncComponent::RemoteObjectCommittedHandler(const Endpoint::Ptr& sender,
return; return;
string name; string name;
if (!params.GetProperty("name", &name)) if (!params.Get("name", &name))
return; return;
string type; string type;
if (!params.GetProperty("type", &type)) if (!params.Get("type", &type))
return; return;
MessagePart properties; MessagePart properties;
if (!params.GetProperty("properties", &properties)) if (!params.Get("properties", &properties))
return; return;
ConfigObject::Ptr object = ConfigObject::GetObject(type, name); ConfigObject::Ptr object = ConfigObject::GetObject(type, name);
@ -276,11 +276,11 @@ void CIBSyncComponent::RemoteObjectRemovedHandler(const RequestMessage& request)
return; return;
string name; string name;
if (!params.GetProperty("name", &name)) if (!params.Get("name", &name))
return; return;
string type; string type;
if (!params.GetProperty("type", &type)) if (!params.Get("type", &type))
return; return;
ConfigObject::Ptr object = ConfigObject::GetObject(type, name); ConfigObject::Ptr object = ConfigObject::GetObject(type, name);

View File

@ -57,32 +57,32 @@ void ConvenienceComponent::HostAddedHandler(const ConfigItem::Ptr& item)
void ConvenienceComponent::CopyServiceAttributes(const ConfigObject::Ptr& host, const Dictionary::Ptr& service, const ConfigItemBuilder::Ptr& builder) void ConvenienceComponent::CopyServiceAttributes(const ConfigObject::Ptr& host, const Dictionary::Ptr& service, const ConfigItemBuilder::Ptr& builder)
{ {
Dictionary::Ptr macros; Dictionary::Ptr macros;
if (service->GetProperty("macros", &macros)) if (service->Get("macros", &macros))
builder->AddExpression("macros", OperatorPlus, macros); builder->AddExpression("macros", OperatorPlus, macros);
long checkInterval; long checkInterval;
if (service->GetProperty("check_interval", &checkInterval)) if (service->Get("check_interval", &checkInterval))
builder->AddExpression("check_interval", OperatorSet, checkInterval); builder->AddExpression("check_interval", OperatorSet, checkInterval);
long retryInterval; long retryInterval;
if (service->GetProperty("retry_interval", &retryInterval)) if (service->Get("retry_interval", &retryInterval))
builder->AddExpression("retry_interval", OperatorSet, retryInterval); builder->AddExpression("retry_interval", OperatorSet, retryInterval);
Dictionary::Ptr sgroups; Dictionary::Ptr sgroups;
if (service->GetProperty("servicegroups", &sgroups)) if (service->Get("servicegroups", &sgroups))
builder->AddExpression("servicegroups", OperatorPlus, sgroups); builder->AddExpression("servicegroups", OperatorPlus, sgroups);
Dictionary::Ptr checkers; Dictionary::Ptr checkers;
if (service->GetProperty("checkers", &checkers)) if (service->Get("checkers", &checkers))
builder->AddExpression("checkers", OperatorSet, checkers); builder->AddExpression("checkers", OperatorSet, checkers);
Dictionary::Ptr dependencies; Dictionary::Ptr dependencies;
if (service->GetProperty("dependencies", &dependencies)) if (service->Get("dependencies", &dependencies))
builder->AddExpression("dependencies", OperatorPlus, builder->AddExpression("dependencies", OperatorPlus,
Service::ResolveDependencies(host, dependencies)); Service::ResolveDependencies(host, dependencies));
Dictionary::Ptr hostchecks; Dictionary::Ptr hostchecks;
if (service->GetProperty("hostchecks", &hostchecks)) if (service->Get("hostchecks", &hostchecks))
builder->AddExpression("dependencies", OperatorPlus, builder->AddExpression("dependencies", OperatorPlus,
Service::ResolveDependencies(host, hostchecks)); Service::ResolveDependencies(host, hostchecks));
} }
@ -134,7 +134,7 @@ void ConvenienceComponent::HostCommittedHandler(const ConfigItem::Ptr& item)
throw invalid_argument("Service description invalid."); throw invalid_argument("Service description invalid.");
string parent; string parent;
if (!service->GetProperty("service", &parent)) if (!service->Get("service", &parent))
parent = svcname; parent = svcname;
builder->AddParent(parent); builder->AddParent(parent);
@ -147,7 +147,7 @@ void ConvenienceComponent::HostCommittedHandler(const ConfigItem::Ptr& item)
ConfigItem::Ptr serviceItem = builder->Compile(); ConfigItem::Ptr serviceItem = builder->Compile();
serviceItem->Commit(); serviceItem->Commit();
newServices->SetProperty(name, serviceItem); newServices->Set(name, serviceItem);
} }
} }

View File

@ -96,7 +96,7 @@ void DelegationComponent::AssignService(const Endpoint::Ptr& checker, const Serv
request.SetMethod("checker::AssignService"); request.SetMethod("checker::AssignService");
MessagePart params; MessagePart params;
params.SetProperty("service", service.GetConfigObject()->GetProperties()); params.Set("service", service.GetConfigObject()->GetProperties());
request.SetParams(params); request.SetParams(params);
Application::Log(LogDebug, "delegation", "Trying to delegate service '" + service.GetName() + "'"); Application::Log(LogDebug, "delegation", "Trying to delegate service '" + service.GetName() + "'");

View File

@ -301,13 +301,13 @@ void DiscoveryComponent::SendDiscoveryMessage(const string& method, const string
set<string>::iterator i; set<string>::iterator i;
MessagePart subscriptions; MessagePart subscriptions;
for (i = info->Subscriptions.begin(); i != info->Subscriptions.end(); i++) for (i = info->Subscriptions.begin(); i != info->Subscriptions.end(); i++)
subscriptions.AddUnnamedProperty(*i); subscriptions.Add(*i);
params.SetSubscriptions(subscriptions); params.SetSubscriptions(subscriptions);
MessagePart publications; MessagePart publications;
for (i = info->Publications.begin(); i != info->Publications.end(); i++) for (i = info->Publications.begin(); i != info->Publications.end(); i++)
publications.AddUnnamedProperty(*i); publications.Add(*i);
params.SetPublications(publications); params.SetPublications(publications);

View File

@ -12,50 +12,50 @@ DiscoveryMessage::DiscoveryMessage(const MessagePart& message)
bool DiscoveryMessage::GetIdentity(string *value) const bool DiscoveryMessage::GetIdentity(string *value) const
{ {
return GetProperty("identity", value); return Get("identity", value);
} }
void DiscoveryMessage::SetIdentity(const string& value) void DiscoveryMessage::SetIdentity(const string& value)
{ {
SetProperty("identity", value); Set("identity", value);
} }
bool DiscoveryMessage::GetNode(string *value) const bool DiscoveryMessage::GetNode(string *value) const
{ {
return GetProperty("node", value); return Get("node", value);
} }
void DiscoveryMessage::SetNode(const string& value) void DiscoveryMessage::SetNode(const string& value)
{ {
SetProperty("node", value); Set("node", value);
} }
bool DiscoveryMessage::GetService(string *value) const bool DiscoveryMessage::GetService(string *value) const
{ {
return GetProperty("service", value); return Get("service", value);
} }
void DiscoveryMessage::SetService(const string& value) void DiscoveryMessage::SetService(const string& value)
{ {
SetProperty("service", value); Set("service", value);
} }
bool DiscoveryMessage::GetSubscriptions(MessagePart *value) const bool DiscoveryMessage::GetSubscriptions(MessagePart *value) const
{ {
return GetProperty("subscriptions", value); return Get("subscriptions", value);
} }
void DiscoveryMessage::SetSubscriptions(MessagePart value) void DiscoveryMessage::SetSubscriptions(MessagePart value)
{ {
SetProperty("subscriptions", value); Set("subscriptions", value);
} }
bool DiscoveryMessage::GetPublications(MessagePart *value) const bool DiscoveryMessage::GetPublications(MessagePart *value) const
{ {
return GetProperty("publications", value); return Get("publications", value);
} }
void DiscoveryMessage::SetPublications(MessagePart value) void DiscoveryMessage::SetPublications(MessagePart value)
{ {
SetProperty("publications", value); Set("publications", value);
} }

View File

@ -1768,7 +1768,7 @@ yyreduce:
/* Line 1806 of yacc.c */ /* Line 1806 of yacc.c */
#line 259 "config_parser.yy" #line 259 "config_parser.yy"
{ {
m_Array->AddUnnamedProperty(*(yyvsp[(1) - (1)].variant)); m_Array->Add(*(yyvsp[(1) - (1)].variant));
delete (yyvsp[(1) - (1)].variant); delete (yyvsp[(1) - (1)].variant);
} }
break; break;

View File

@ -257,7 +257,7 @@ tuple: '('
tupleitem: simplevalue tupleitem: simplevalue
{ {
m_Array->AddUnnamedProperty(*$1); m_Array->Add(*$1);
delete $1; delete $1;
} }

View File

@ -60,7 +60,7 @@ void Expression::Execute(const Dictionary::Ptr& dictionary) const
break; break;
case OperatorPlus: case OperatorPlus:
dictionary->GetProperty(m_Key, &oldValue); dictionary->Get(m_Key, &oldValue);
if (oldValue.GetType() == VariantObject) if (oldValue.GetType() == VariantObject)
dict = dynamic_pointer_cast<Dictionary>(oldValue.GetObject()); dict = dynamic_pointer_cast<Dictionary>(oldValue.GetObject());
@ -82,7 +82,7 @@ void Expression::Execute(const Dictionary::Ptr& dictionary) const
} else if (valueDict) { } else if (valueDict) {
Dictionary::Iterator it; Dictionary::Iterator it;
for (it = valueDict->Begin(); it != valueDict->End(); it++) { for (it = valueDict->Begin(); it != valueDict->End(); it++) {
dict->SetProperty(it->first, it->second); dict->Set(it->first, it->second);
} }
} else { } else {
stringstream message; stringstream message;
@ -96,5 +96,5 @@ void Expression::Execute(const Dictionary::Ptr& dictionary) const
throw runtime_error("Not yet implemented."); throw runtime_error("Not yet implemented.");
} }
dictionary->SetProperty(m_Key, newValue); dictionary->Set(m_Key, newValue);
} }

View File

@ -91,15 +91,15 @@ void JsonRpcEndpoint::NewMessageHandler(const MessagePart& message)
return; return;
} }
RequestMessage request = message;
string method; string method;
if (!message.GetProperty("method", &method)) if (!request.GetMethod(&method))
return; return;
if (!HasPublication(method)) if (!HasPublication(method))
return; return;
RequestMessage request = message;
string id; string id;
if (request.GetID(&id)) if (request.GetID(&id))
GetEndpointManager()->SendAnycastMessage(sender, request); GetEndpointManager()->SendAnycastMessage(sender, request);

View File

@ -81,13 +81,13 @@ Dictionary::Ptr MessagePart::GetDictionaryFromJson(json_t *json)
for (cJSON *i = json->child; i != NULL; i = i->next) { for (cJSON *i = json->child; i != NULL; i = i->next) {
switch (i->type) { switch (i->type) {
case cJSON_Number: case cJSON_Number:
dictionary->SetProperty(i->string, i->valueint); dictionary->Set(i->string, i->valueint);
break; break;
case cJSON_String: case cJSON_String:
dictionary->SetProperty(i->string, i->valuestring); dictionary->Set(i->string, i->valuestring);
break; break;
case cJSON_Object: case cJSON_Object:
dictionary->SetProperty(i->string, GetDictionaryFromJson(i)); dictionary->Set(i->string, GetDictionaryFromJson(i));
break; break;
default: default:
break; break;
@ -176,10 +176,10 @@ Dictionary::Ptr MessagePart::GetDictionary(void) const
* @param[out] The value. * @param[out] The value.
* @returns true if the value was retrieved, false otherwise. * @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; Object::Ptr object;
if (!GetDictionary()->GetProperty(key, &object)) if (!GetDictionary()->Get(key, &object))
return false; return false;
Dictionary::Ptr dictionary = dynamic_pointer_cast<Dictionary>(object); Dictionary::Ptr dictionary = dynamic_pointer_cast<Dictionary>(object);
@ -196,9 +196,9 @@ bool MessagePart::GetProperty(string key, MessagePart *value) const
* @param key The name of the property. * @param key The name of the property.
* @param value The value. * @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());
} }
/** /**
@ -206,9 +206,9 @@ void MessagePart::SetProperty(string key, const MessagePart& value)
* *
* @param value The value. * @param value The value.
*/ */
void MessagePart::AddUnnamedProperty(const MessagePart& value) void MessagePart::Add(const MessagePart& value)
{ {
GetDictionary()->AddUnnamedProperty(value.GetDictionary()); GetDictionary()->Add(value.GetDictionary());
} }
/** /**

View File

@ -52,9 +52,9 @@ public:
* @returns true if the value was retrieved, false otherwise. * @returns true if the value was retrieved, false otherwise.
*/ */
template<typename T> 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);
} }
/** /**
@ -64,13 +64,13 @@ public:
* @param value The value. * @param value The value.
*/ */
template<typename T> 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; bool Get(string key, MessagePart *value) const;
void SetProperty(string key, const MessagePart& value); void Set(string key, const MessagePart& value);
/** /**
* Adds an item to the message using an automatically generated property name. * Adds an item to the message using an automatically generated property name.
@ -78,12 +78,12 @@ public:
* @param value The value. * @param value The value.
*/ */
template<typename T> 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; bool Contains(const string& key) const;

View File

@ -53,7 +53,7 @@ public:
*/ */
inline bool GetVersion(string *value) const inline bool GetVersion(string *value) const
{ {
return GetProperty("jsonrpc", value); return Get("jsonrpc", value);
} }
/** /**
@ -63,7 +63,7 @@ public:
*/ */
inline void SetVersion(const string& value) inline void SetVersion(const string& value)
{ {
SetProperty("jsonrpc", value); Set("jsonrpc", value);
} }
/** /**
@ -74,7 +74,7 @@ public:
*/ */
inline bool GetMethod(string *value) const inline bool GetMethod(string *value) const
{ {
return GetProperty("method", value); return Get("method", value);
} }
/** /**
@ -84,7 +84,7 @@ public:
*/ */
inline void SetMethod(const string& value) inline void SetMethod(const string& value)
{ {
SetProperty("method", value); Set("method", value);
} }
/** /**
@ -95,7 +95,7 @@ public:
*/ */
inline bool GetParams(MessagePart *value) const inline bool GetParams(MessagePart *value) const
{ {
return GetProperty("params", value); return Get("params", value);
} }
/** /**
@ -105,7 +105,7 @@ public:
*/ */
inline void SetParams(const MessagePart& value) inline void SetParams(const MessagePart& value)
{ {
SetProperty("params", value); Set("params", value);
} }
/** /**
@ -116,7 +116,7 @@ public:
*/ */
inline bool GetID(string *value) const inline bool GetID(string *value) const
{ {
return GetProperty("id", value); return Get("id", value);
} }
/** /**
@ -126,7 +126,7 @@ public:
*/ */
inline void SetID(const string& value) inline void SetID(const string& value)
{ {
SetProperty("id", value); Set("id", value);
} }
}; };

View File

@ -53,7 +53,7 @@ public:
*/ */
inline bool GetVersion(string *value) const inline bool GetVersion(string *value) const
{ {
return GetProperty("jsonrpc", value); return Get("jsonrpc", value);
} }
/** /**
@ -63,7 +63,7 @@ public:
*/ */
inline void SetVersion(const string& value) inline void SetVersion(const string& value)
{ {
SetProperty("jsonrpc", value); Set("jsonrpc", value);
} }
/** /**
@ -74,7 +74,7 @@ public:
*/ */
bool GetResult(MessagePart *value) const bool GetResult(MessagePart *value) const
{ {
return GetProperty("result", value); return Get("result", value);
} }
/** /**
@ -84,7 +84,7 @@ public:
*/ */
void SetResult(const MessagePart& value) void SetResult(const MessagePart& value)
{ {
SetProperty("result", value); Set("result", value);
} }
/** /**
@ -95,7 +95,7 @@ public:
*/ */
bool GetError(string *value) const bool GetError(string *value) const
{ {
return GetProperty("error", value); return Get("error", value);
} }
/** /**
@ -105,7 +105,7 @@ public:
*/ */
void SetError(const string& value) void SetError(const string& value)
{ {
SetProperty("error", value); Set("error", value);
} }
/** /**
@ -116,7 +116,7 @@ public:
*/ */
bool GetID(string *value) const bool GetID(string *value) const
{ {
return GetProperty("id", value); return Get("id", value);
} }
/** /**
@ -126,7 +126,7 @@ public:
*/ */
void SetID(const string& value) void SetID(const string& value)
{ {
SetProperty("id", value); Set("id", value);
} }
/** /**

View File

@ -14,19 +14,19 @@ BOOST_AUTO_TEST_CASE(construct)
BOOST_AUTO_TEST_CASE(getproperty) BOOST_AUTO_TEST_CASE(getproperty)
{ {
Dictionary::Ptr dictionary = make_shared<Dictionary>(); Dictionary::Ptr dictionary = make_shared<Dictionary>();
dictionary->SetProperty("test1", 7); dictionary->Set("test1", 7);
dictionary->SetProperty("test2", "hello world"); dictionary->Set("test2", "hello world");
long test1; long test1;
BOOST_REQUIRE(dictionary->GetProperty("test1", &test1)); BOOST_REQUIRE(dictionary->Get("test1", &test1));
BOOST_REQUIRE(test1 == 7); BOOST_REQUIRE(test1 == 7);
string test2; string test2;
BOOST_REQUIRE(dictionary->GetProperty("test2", &test2)); BOOST_REQUIRE(dictionary->Get("test2", &test2));
BOOST_REQUIRE(test2 == "hello world"); BOOST_REQUIRE(test2 == "hello world");
long test3; long test3;
BOOST_REQUIRE(!dictionary->GetProperty("test3", &test3)); BOOST_REQUIRE(!dictionary->Get("test3", &test3));
} }
BOOST_AUTO_TEST_CASE(getproperty_dict) BOOST_AUTO_TEST_CASE(getproperty_dict)
@ -34,22 +34,22 @@ BOOST_AUTO_TEST_CASE(getproperty_dict)
Dictionary::Ptr dictionary = make_shared<Dictionary>(); Dictionary::Ptr dictionary = make_shared<Dictionary>();
Dictionary::Ptr other = make_shared<Dictionary>(); Dictionary::Ptr other = make_shared<Dictionary>();
dictionary->SetProperty("test1", other); dictionary->Set("test1", other);
Dictionary::Ptr test1; Dictionary::Ptr test1;
BOOST_REQUIRE(dictionary->GetProperty("test1", &test1)); BOOST_REQUIRE(dictionary->Get("test1", &test1));
BOOST_REQUIRE(other == test1); BOOST_REQUIRE(other == test1);
Dictionary::Ptr test2; Dictionary::Ptr test2;
BOOST_REQUIRE(!dictionary->GetProperty("test2", &test2)); BOOST_REQUIRE(!dictionary->Get("test2", &test2));
} }
BOOST_AUTO_TEST_CASE(unnamed) BOOST_AUTO_TEST_CASE(unnamed)
{ {
Dictionary::Ptr dictionary = make_shared<Dictionary>(); Dictionary::Ptr dictionary = make_shared<Dictionary>();
dictionary->AddUnnamedProperty("test1"); dictionary->Add("test1");
dictionary->AddUnnamedProperty("test2"); dictionary->Add("test2");
dictionary->AddUnnamedProperty("test3"); dictionary->Add("test3");
BOOST_REQUIRE(distance(dictionary->Begin(), dictionary->End()) == 3); BOOST_REQUIRE(distance(dictionary->Begin(), dictionary->End()) == 3);
} }