Commit d3686170 authored by JINMEI Tatuya's avatar JINMEI Tatuya

removed 'using namespace' from src/lib/config/module_spec.cc, and adjusted other files accordingly.

for trac #373.


git-svn-id: svn://bind10.isc.org/svn/bind10/branches/trac373@3237 e5f2f494-b856-4b98-b285-d166d9295462
parent 412c4572
......@@ -38,6 +38,7 @@
using namespace std;
using namespace isc;
using namespace isc::data;
using namespace isc::dns;
using namespace isc::xfr;
using namespace isc::bench;
......
......@@ -45,6 +45,7 @@
using namespace std;
using isc::data::Element;
using isc::data::ConstElementPtr;
using isc::data::ElementPtr;
using isc::data::JSONError;
......
......@@ -31,7 +31,7 @@ namespace config {
/// \brief Creates a standard config/command level success answer message
/// (i.e. of the form { "result": [ 0 ] }
/// \return Standard command/config success answer message
ConstElementPtr createAnswer();
isc::data::ConstElementPtr createAnswer();
///
/// \brief Creates a standard config/command level answer message
......@@ -43,7 +43,8 @@ ConstElementPtr createAnswer();
/// Element type. For rcode == 1, this argument is mandatory,
/// and must be a StringElement containing an error description
/// \return Standard command/config answer message
ConstElementPtr createAnswer(const int rcode, ConstElementPtr arg);
isc::data::ConstElementPtr createAnswer(const int rcode,
isc::data::ConstElementPtr arg);
///
/// \brief Creates a standard config/command level answer message
......@@ -52,7 +53,8 @@ ConstElementPtr createAnswer(const int rcode, ConstElementPtr arg);
/// \param rcode The return code (0 for success)
/// \param arg A string to put into the StringElement argument
/// \return Standard command/config answer message
ConstElementPtr createAnswer(const int rcode, const std::string& arg);
isc::data::ConstElementPtr createAnswer(const int rcode,
const std::string& arg);
///
/// Parses a standard config/command level answer message
......@@ -63,7 +65,8 @@ ConstElementPtr createAnswer(const int rcode, const std::string& arg);
/// \return The optional argument in the message, or an empty ElementPtr
/// if there was no argument. If rcode != 0, this contains a
/// StringElement with the error description.
ConstElementPtr parseAnswer(int &rcode, ConstElementPtr msg);
isc::data::ConstElementPtr parseAnswer(int &rcode,
isc::data::ConstElementPtr msg);
///
/// \brief Creates a standard config/command command message with no
......@@ -71,7 +74,7 @@ ConstElementPtr parseAnswer(int &rcode, ConstElementPtr msg);
///
/// \param command The command string
/// \return The created message
ConstElementPtr createCommand(const std::string& command);
isc::data::ConstElementPtr createCommand(const std::string& command);
///
/// \brief Creates a standard config/command command message with the
......@@ -81,7 +84,8 @@ ConstElementPtr createCommand(const std::string& command);
/// \param arg The optional argument for the command. This can be of
/// any Element type, but it should conform to the .spec file.
/// \return The created message
ConstElementPtr createCommand(const std::string& command, ConstElementPtr arg);
isc::data::ConstElementPtr createCommand(const std::string& command,
isc::data::ConstElementPtr arg);
///
/// \brief Parses the given command into a string containing the actual
......@@ -92,7 +96,8 @@ ConstElementPtr createCommand(const std::string& command, ConstElementPtr arg);
/// \param command The command message containing the command (as made
/// by createCommand()
/// \return The command string
std::string parseCommand(ConstElementPtr& arg, ConstElementPtr command);
std::string parseCommand(isc::data::ConstElementPtr& arg,
isc::data::ConstElementPtr command);
///
......@@ -225,8 +230,9 @@ public:
* \param identifier The identifier of the config value
* \return The configuration setting at the given identifier
*/
ConstElementPtr getRemoteConfigValue(const std::string& module_name,
const std::string& identifier) const;
isc::data::ConstElementPtr getRemoteConfigValue(
const std::string& module_name,
const std::string& identifier) const;
private:
ModuleSpec readModuleSpecification(const std::string& filename);
......@@ -235,7 +241,8 @@ private:
std::string module_name_;
isc::cc::AbstractSession& session_;
ModuleSpec module_specification_;
ConstElementPtr handleConfigUpdate(ConstElementPtr new_config);
isc::data::ConstElementPtr handleConfigUpdate(
isc::data::ConstElementPtr new_config);
isc::data::ConstElementPtr(*config_handler_)(
isc::data::ConstElementPtr new_config);
......@@ -245,7 +252,7 @@ private:
std::map<std::string, ConfigData> remote_module_configs_;
void updateRemoteConfig(const std::string& module_name,
ConstElementPtr new_config);
isc::data::ConstElementPtr new_config);
};
}
......
......@@ -39,12 +39,14 @@ class ConfigData {
public:
/// Constructs a ConfigData option with no specification and an
/// empty configuration.
ConfigData() { _config = Element::createMap(); };
ConfigData() { _config = isc::data::Element::createMap(); };
/// Constructs a ConfigData option with the given specification
/// and an empty configuration.
/// \param module_spec A ModuleSpec for the relevant module
ConfigData(const ModuleSpec& module_spec) : _module_spec(module_spec) { _config = Element::createMap(); }
ConfigData(const ModuleSpec& module_spec) : _module_spec(module_spec) {
_config = isc::data::Element::createMap();
}
virtual ~ConfigData() {};
......@@ -55,7 +57,7 @@ public:
/// Raises a DataNotFoundError if the identifier is bad.
/// \param identifier The identifier pointing to the configuration
/// value that is to be returned
ConstElementPtr getValue(const std::string& identifier) const;
isc::data::ConstElementPtr getValue(const std::string& identifier) const;
/// Returns the value currently set for the given identifier
/// If no value is set, the default value (as specified by the
......@@ -67,8 +69,8 @@ public:
/// false otherwise
/// \param identifier The identifier pointing to the configuration
/// value that is to be returned
ConstElementPtr getValue(bool& is_default,
const std::string& identifier) const;
isc::data::ConstElementPtr getValue(bool& is_default,
const std::string& identifier) const;
/// Returns the ModuleSpec associated with this ConfigData object
const ModuleSpec& getModuleSpec() const { return (_module_spec); }
......@@ -80,12 +82,12 @@ public:
/// \param config An ElementPtr pointing to a MapElement containing
/// *all* non-default configuration values. Existing values
/// will be removed.
void setLocalConfig(ElementPtr config) { _config = config; }
void setLocalConfig(isc::data::ElementPtr config) { _config = config; }
/// Returns the local (i.e. non-default) configuration.
/// \returns An ElementPtr pointing to a MapElement containing all
/// non-default configuration options.
ElementPtr getLocalConfig() { return (_config); }
isc::data::ElementPtr getLocalConfig() { return (_config); }
/// Returns a list of all possible configuration options as specified
/// by the ModuleSpec.
......@@ -97,18 +99,18 @@ public:
/// StringElements that specify the identifiers at the given
/// location (or all possible identifiers if identifier==""
/// and recurse==false)
ConstElementPtr getItemList(const std::string& identifier = "",
bool recurse = false) const;
isc::data::ConstElementPtr getItemList(const std::string& identifier = "",
bool recurse = false) const;
/// Returns all current configuration settings (both non-default and default).
/// \return An ElementPtr pointing to a MapElement containing
/// string->value elements, where the string is the
/// full identifier of the configuration option and the
/// value is an ElementPtr with the value.
ConstElementPtr getFullConfig() const;
isc::data::ConstElementPtr getFullConfig() const;
private:
ElementPtr _config;
isc::data::ElementPtr _config;
ModuleSpec _module_spec;
};
......
......@@ -24,6 +24,7 @@
// todo: add more context to thrown ModuleSpecErrors?
using namespace isc::data;
using namespace isc::config;
namespace {
......
......@@ -20,8 +20,6 @@
#include <sstream>
using namespace isc::data;
namespace isc { namespace config {
///
......@@ -55,24 +53,27 @@ namespace isc { namespace config {
/// Create a \c ModuleSpec instance with the given data as
/// the specification
/// \param e The Element containing the data specification
explicit ModuleSpec(ConstElementPtr e, const bool check = true)
explicit ModuleSpec(isc::data::ConstElementPtr e,
const bool check = true)
throw(ModuleSpecError);
/// Returns the commands part of the specification as an
/// ElementPtr, returns an empty ElementPtr if there is none
/// \return ElementPtr Shared pointer to the commands
/// part of the specification
ConstElementPtr getCommandsSpec() const;
isc::data::ConstElementPtr getCommandsSpec() const;
/// Returns the configuration part of the specification as an
/// ElementPtr
/// \return ElementPtr Shared pointer to the configuration
/// part of the specification
ConstElementPtr getConfigSpec() const;
isc::data::ConstElementPtr getConfigSpec() const;
/// Returns the full module specification as an ElementPtr
/// \return ElementPtr Shared pointer to the specification
ConstElementPtr getFullSpec() const { return module_specification; }
isc::data::ConstElementPtr getFullSpec() const {
return module_specification;
}
/// Returns the module name as specified by the specification
const std::string getModuleName() const;
......@@ -87,22 +88,28 @@ namespace isc { namespace config {
/// \param data The base \c Element of the data to check
/// \return true if the data conforms to the specification,
/// false otherwise.
bool validate_config(ConstElementPtr data,
bool validate_config(isc::data::ConstElementPtr data,
const bool full = false) const;
/// errors must be of type ListElement
bool validate_config(ConstElementPtr data, const bool full,
ElementPtr errors) const;
bool validate_config(isc::data::ConstElementPtr data, const bool full,
isc::data::ElementPtr errors) const;
private:
bool validate_item(ConstElementPtr spec, ConstElementPtr data,
const bool full, ElementPtr errors) const;
bool validate_spec(ConstElementPtr spec, ConstElementPtr data,
const bool full, ElementPtr errors) const;
bool validate_spec_list(ConstElementPtr spec, ConstElementPtr data,
const bool full, ElementPtr errors) const;
ConstElementPtr module_specification;
bool validate_item(isc::data::ConstElementPtr spec,
isc::data::ConstElementPtr data,
const bool full,
isc::data::ElementPtr errors) const;
bool validate_spec(isc::data::ConstElementPtr spec,
isc::data::ConstElementPtr data,
const bool full,
isc::data::ElementPtr errors) const;
bool validate_spec_list(isc::data::ConstElementPtr spec,
isc::data::ConstElementPtr data,
const bool full,
isc::data::ElementPtr errors) const;
isc::data::ConstElementPtr module_specification;
};
/// Creates a \c ModuleSpec instance from the contents
......@@ -115,7 +122,7 @@ namespace isc { namespace config {
/// is checked to be of the correct form
ModuleSpec
moduleSpecFromFile(const std::string& file_name, const bool check = true)
throw(JSONError, ModuleSpecError);
throw(isc::data::JSONError, ModuleSpecError);
/// Creates a \c ModuleSpec instance from the given input
/// stream that contains the contents of a .spec file.
......@@ -127,7 +134,7 @@ namespace isc { namespace config {
/// to be of the correct form
ModuleSpec
moduleSpecFromFile(std::ifstream& in, const bool check = true)
throw(JSONError, ModuleSpecError);
throw(isc::data::JSONError, ModuleSpecError);
} }
#endif // _DATA_DEF_H
......
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