00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef MISC_H
00020 #define MISC_H
00021 #include <string>
00022 #include <map>
00023 #include <stdint.h>
00024
00025 #include <libstoragemgmt/libstoragemgmt_common.h>
00026
00027 namespace LSM {
00028
00035 LSM_DLL_LOCAL std::string getValue(std::string query_string, std::string key);
00036
00042 template <class Type>
00043 class LSM_DLL_LOCAL JobControl {
00044
00045 public:
00046
00050 JobControl():ticket(0)
00051 {
00052 }
00053
00059 int insert( Type t )
00060 {
00061 jobs[++ticket] = t;
00062 return ticket;
00063 }
00064
00070 Type get(uint32_t num)
00071 {
00072 return getInt(num)->second;
00073 }
00074
00080 bool present(uint32_t num)
00081 {
00082 return ( getInt(num) != jobs.end());
00083 }
00084
00089 void remove(uint32_t num)
00090 {
00091 jobs.erase(getInt(num));
00092 }
00093
00094 private:
00095 typename std::map<uint32_t, Type>::iterator getInt(uint32_t num )
00096 {
00097 typename std::map<uint32_t, Type>::iterator i = jobs.find(num);
00098 return i;
00099 }
00100 uint32_t ticket;
00101 std::map<uint32_t , Type> jobs;
00102 };
00103
00104 }
00105
00106
00107 #endif