Move emulator_status to library/
[lsnes.git] / include / library / emustatus.hpp
blob5bf736dc9ec0431389e62c699f32bbacfef66f0d
1 #ifndef _library__emustatus__hpp__included__
2 #define _library__emustatus__hpp__included__
4 #include "library/workthread.hpp"
6 #include <map>
7 #include <string>
9 class emulator_status
11 public:
12 /**
13 * Constructor.
15 * Throws std::bad_alloc: Not enough memory.
17 emulator_status() throw(std::bad_alloc);
18 /**
19 * Destructor
21 ~emulator_status() throw();
22 /**
23 * Insert/Replace key.
25 * Parameter key: Key to insert/replace.
26 * Parameter value: The value to assign.
27 * Throws std::bad_alloc: Not enough memory.
29 void set(const std::string& key, const std::string& value) throw(std::bad_alloc);
30 /**
31 * Has key?
33 * Parameter key: Key to check.
34 * Returns: True if key exists, false if not.
36 bool haskey(const std::string& key) throw();
37 /**
38 * Erase key.
40 * Parameter key: Key to erase.
42 void erase(const std::string& key) throw();
43 /**
44 * Read key.
46 * Parameter key: The key to read.
47 * Returns: The value of key ("" if not found).
49 std::string get(const std::string& key) throw(std::bad_alloc);
50 /**
51 * Iterator.
53 struct iterator
55 /**
56 * Not valid flag.
58 bool not_valid;
59 /**
60 * Key.
62 std::string key;
63 /**
64 * Value.
66 std::string value;
68 /**
69 * Get first iterator
71 * Returns: Before-the-start iterator.
72 * Throws std::bad_alloc: Not enough memory.
74 iterator first() throw(std::bad_alloc);
75 /**
76 * Get next value.
78 * Parameter itr: Iterator to advance.
79 * Returns: True if next value was found, false if not.
80 * Throws std::bad_alloc: Not enough memory.
82 bool next(iterator& itr) throw(std::bad_alloc);
83 private:
84 emulator_status(const emulator_status&);
85 emulator_status& operator=(const emulator_status&);
86 mutex_class lock;
87 std::map<std::string, std::string> content;
90 #endif