OptionDictionary.h
/*
* File: OptionDictionary.h
*
* Copyright (c) Freescale Semiconductor, Inc. All rights reserved.
* See included license file for license details.
*/
#if !defined(_OptionDictionary_h_)
#define _OptionDictionary_h_
#include "OptionContext.h"
#include <map>
namespace elftosb
{
class OptionDictionary : public OptionContext
{
public:
OptionDictionary()
: m_parent(0)
{
}
OptionDictionary(OptionContext *parent)
: m_parent(parent)
{
}
~OptionDictionary();
inline OptionContext *getParent() const { return m_parent; }
inline void setParent(OptionContext *newParent) { m_parent = newParent; }
virtual bool hasOption(const std::string &name) const;
virtual const Value *getOption(const std::string &name) const;
virtual void setOption(const std::string &name, Value *value);
virtual void deleteOption(const std::string &name);
bool isOptionLocked(const std::string &name) const;
void lockOption(const std::string &name);
void unlockOption(const std::string &name);
const Value *operator[](const std::string &name) const;
protected:
OptionContext *m_parent;
struct OptionValue
{
Value *m_value;
bool m_isLocked;
OptionValue()
: m_value(0)
, m_isLocked(false)
{
}
};
typedef std::map<std::string, OptionValue> option_map_t;
option_map_t m_options;
};
}; // namespace elftosb
#endif // _OptionDictionary_h_
elftosb::OptionDictionary::OptionDictionary
OptionDictionary(OptionContext *parent)
Constructor taking a parent context.
Definition: OptionDictionary.h:37
elftosb::OptionDictionary::option_map_t
std::map< std::string, OptionValue > option_map_t
Map from option name to value.
Definition: OptionDictionary.h:109
elftosb::OptionDictionary::unlockOption
void unlockOption(const std::string &name)
Allow an option to be changed.
Definition: OptionDictionary.cpp:153
elftosb::OptionDictionary::getOption
virtual const Value * getOption(const std::string &name) const
Returns the option&#39;s value.
Definition: OptionDictionary.cpp:50
elftosb::OptionDictionary::OptionValue::OptionValue
OptionValue()
Constructor.
Definition: OptionDictionary.h:102
elftosb::OptionDictionary::lockOption
void lockOption(const std::string &name)
Prevent further modifications of an option&#39;s value.
Definition: OptionDictionary.cpp:141
elftosb::OptionDictionary::m_options
option_map_t m_options
The option dictionary.
Definition: OptionDictionary.h:110
elftosb::OptionDictionary
Concrete implementation of OptionContext.
Definition: OptionDictionary.h:27
elftosb::OptionDictionary::OptionValue::m_value
Value * m_value
The object for this option&#39;s value.
Definition: OptionDictionary.h:98
elftosb::OptionDictionary::getParent
OptionContext * getParent() const
Returns the current parent context.
Definition: OptionDictionary.h:50
elftosb::OptionDictionary::isOptionLocked
bool isOptionLocked(const std::string &name) const
Returns true if the specified option is locked from further changes.
Definition: OptionDictionary.cpp:128
elftosb::OptionDictionary::~OptionDictionary
~OptionDictionary()
Destructor.
Definition: OptionDictionary.cpp:14
elftosb::OptionDictionary::setParent
void setParent(OptionContext *newParent)
Change the parent context.
Definition: OptionDictionary.h:54
elftosb
Definition: BootImage.h:13
elftosb::Value
Abstract base class for values of arbitrary types.
Definition: apps/elftosb/common/Value.h:20
elftosb::OptionContext
Pure abstract interface class to a table of options.
Definition: apps/elftosb/common/OptionContext.h:18
elftosb::OptionDictionary::setOption
virtual void setOption(const std::string &name, Value *value)
Adds or changes an option&#39;s value.
Definition: OptionDictionary.cpp:82
elftosb::OptionDictionary::hasOption
virtual bool hasOption(const std::string &name) const
Detemine whether the named option is present in the table.
Definition: OptionDictionary.cpp:32
elftosb::OptionDictionary::operator[]
const Value * operator[](const std::string &name) const
Indexing operator; returns the value for the option name.
Definition: OptionDictionary.cpp:165
elftosb::OptionDictionary::OptionValue
Information about one option&#39;s value.
Definition: OptionDictionary.h:96
elftosb::OptionDictionary::OptionValue::m_isLocked
bool m_isLocked
True if this value is locked from further changes.
Definition: OptionDictionary.h:99
elftosb::OptionDictionary::m_parent
OptionContext * m_parent
Our parent context.
Definition: OptionDictionary.h:91
elftosb::OptionDictionary::deleteOption
virtual void deleteOption(const std::string &name)
Removes an option from the table.
Definition: OptionDictionary.cpp:112
elftosb::OptionDictionary::OptionDictionary
OptionDictionary()
Default constructor.
Definition: OptionDictionary.h:31