Files
xahaud/src/cpp/ripple/ParameterTable.h
Vinnie Falco ee49051e1c Downgrade access specification from protected to private in most places
Conflicts:
	src/cpp/ripple/FeatureTable.h
	src/cpp/ripple/HashedObject.h
	src/cpp/ripple/NetworkOPs.h
2013-06-06 20:44:58 -07:00

71 lines
1.9 KiB
C++

#ifndef PARAMETER_TABLE__H
#define PARAMETER_TABLE__H
#include <string>
#include <map>
#include <boost/shared_ptr.hpp>
#include <boost/enable_shared_from_this.hpp>
class Parameter : public boost::enable_shared_from_this<Parameter>
{ // abstract base class parameters are derived from
public:
typedef boost::shared_ptr<Parameter> pointer;
typedef const boost::shared_ptr<Parameter>& ref;
public:
Parameter(Parameter::ref parent, const std::string& name) : mParent(parent), mName(name) { ; }
virtual ~Parameter() { ; }
const std::string& getName() const { return mName; }
virtual Json::Value getValue(int) const = 0;
virtual bool setValue(const Json::Value& value, Json::Value& error) = 0;
Parameter::pointer getShared() { return shared_from_this(); }
private:
pointer mParent;
std::string mName;
};
class ParameterNode : public Parameter
{
public:
ParameterNode(Parameter::ref parent, const std::string& name) : Parameter(parent, name) { ; }
bool addChildNode(Parameter::ref node);
bool setValue(const std::string& name, const Json::Value& value, Json::Value& error);
bool addNode(const std::string& name, Parameter::ref node);
virtual Json::Value getValue(int) const;
virtual bool setValue(const Json::Value& value, Json::Value& error);
private:
std::map<std::string, Parameter::pointer> mChildren;
};
class ParameterString : public Parameter
{
public:
ParameterString(Parameter::ref parent, const std::string& name, const std::string& value);
virtual Json::Value getValue(int) const;
virtual bool setValue(const Json::Value& value, Json::Value& error);
private:
std::string mValue;
};
class ParameterInt : public Parameter
{
public:
ParameterInt(Parameter::ref parent, const std::string& name, int value);
virtual Json::Value getValue(int) const;
virtual bool setValue(const Json::Value& value, Json::Value& error);
private:
int mValue;
};
#endif