helper getters and setters for c++ native types.

This commit is contained in:
Mathieu Lacage
2008-02-15 02:08:55 +01:00
parent 88c9b123ee
commit de438d035b
2 changed files with 61 additions and 0 deletions

View File

@@ -23,6 +23,10 @@
#include "singleton.h"
#include "trace-resolver.h"
#include "value.h"
#include "uint-value.h"
#include "int-value.h"
#include "fp-value.h"
#include "enum-value.h"
#include "log.h"
#include <vector>
#include <sstream>
@@ -929,6 +933,27 @@ Object::Set (std::string name, PValue value)
}
return DoSet (info.spec, value);
}
bool
Object::SetUint (std::string name, uint64_t value)
{
return Set (name, UintValue (value));
}
bool
Object::SetInt (std::string name, int64_t value)
{
return Set (name, IntValue (value));
}
bool
Object::SetFp (std::string name, double value)
{
return Set (name, FpValue (value));
}
bool
Object::SetEnum (std::string name, int value)
{
return Set (name, EnumValue (value));
}
bool
Object::Get (std::string name, std::string &value) const
{
@@ -970,6 +995,31 @@ Object::Get (std::string name) const
}
return value;
}
uint64_t
Object::GetUint (std::string name) const
{
UintValue value = Get (name);
return value.Get ();
}
int64_t
Object::GetInt (std::string name) const
{
IntValue value = Get (name);
return value.Get ();
}
double
Object::GetFp (std::string name) const
{
FpValue value = Get (name);
return value.Get ();
}
int
Object::GetEnum (std::string name) const
{
EnumValue value = Get (name);
return value.Get ();
}
Ptr<Object>
Object::DoGetObject (TypeId tid) const

View File

@@ -350,6 +350,12 @@ public:
* Set a single parameter.
*/
bool Set (std::string name, PValue value);
bool SetUint (std::string name, uint64_t value);
bool SetInt (std::string name, int64_t value);
bool SetFp (std::string name, double value);
bool SetEnum (std::string name, int value);
/**
* \param name the name of the parameter to read
* \param value a reference to the string where the value of the
@@ -365,6 +371,11 @@ public:
*/
PValue Get (std::string name) const;
uint64_t GetUint (std::string name) const;
int64_t GetInt (std::string name) const;
double GetFp (std::string name) const;
int GetEnum (std::string name) const;
/**
* Increment the reference count. This method should not be called
* by user code. Object instances are expected to be used in conjunction