MineLink
 All Data Structures Functions Variables Pages
dict.h
1 #ifndef __DICT_H__
2 #define __DICT_H__
3 
4 #include <map>
5 #include <string>
6 
7 using std::map;
8 using std::string;
9 namespace delphos{
13 class Dict {
14 private:
15  map<string,double> * _attrs;
16 public:
20  Dict();
27  Dict(const string & attr, const double & attr_value);
33  Dict(const map<string,double> & m);
37  virtual ~Dict();
43  const double operator [] (const string & attr_name) const;
49  double & operator [] (const string & attr_name);
55  const bool IsAttribute(const string & attr_name) const;
60  const unsigned int NumAttributes() const;
67  void AddAttribute(const string & attr_name, double const & attr_value);
72  const map<string, double> GetAttributes() const;
78  void SetAttributes(const map<string,double> attr_map);
84  const double GetAttribute(const string &attr_name);
85 };
86 }
87 #endif
88 
void AddAttribute(const string &attr_name, double const &attr_value)
Adds a new pair to the dictionary.
Definition: dict.cpp:40
void SetAttributes(const map< string, double > attr_map)
Overwrites or copy the argument on the internal container.
Definition: dict.cpp:48
virtual ~Dict()
Destructor.
Definition: dict.cpp:20
const double operator[](const string &attr_name) const
Enables the use of the [] on the instance to access values.
Definition: dict.cpp:24
const map< string, double > GetAttributes() const
Return a copy of the internal map container.
Definition: dict.cpp:44
Dict()
Creates a new empty dictionary.
Definition: dict.cpp:6
Abstact a dictionary to store and get attributes.
Definition: dict.h:13
const bool IsAttribute(const string &attr_name) const
Query if a there is a key matching the argument on the dictionary. Return true on success...
Definition: dict.cpp:32
const unsigned int NumAttributes() const
Return the amount of pairs on the dictionary.
Definition: dict.cpp:36
const double GetAttribute(const string &attr_name)
Return the value associated with the given key.
Definition: dict.cpp:52