OSDN Git Service

Persist sorry server connection.
[ultramonkey-l7/ultramonkey-l7-v2.git] / parameter / parameter_impl.h
1 #ifndef __PARAMETER_IMPL_H__
2 #define __PARAMETER_IMPL_H__
3
4 #include "parameter_enum.h"
5 #include <iostream>
6 #include <string>
7 #include <map>
8
9
10 namespace l7vs
11 {
12         struct  component{
13                 std::string     section;
14                 void            (*function)();
15                 component(){ section = ""; function = NULL;}
16                 component( std::string str, void (*p_func)() ){ section = str; function = p_func;}
17                 component& operator=(const component& in_comp){ section = in_comp.section; function = in_comp.function;return *this;}
18         };
19         class ParameterImpl
20         {
21         private:
22                 std::string     removebrank( const std::string& );
23                 bool    readParameterFile( const std::string& );
24                 bool    isNumeric( const std::string& );
25
26                 std::multimap<std::string,std::string>  preparse;
27
28                 std::map<PARAMETER_COMPONENT_TAG, component>    compTable;
29                 std::map<std::string, std::string>      stringMap;
30                 std::map<std::string, int>              intMap;
31
32         protected:
33                 ParameterImpl();
34                 ParameterImpl( const ParameterImpl& );
35                 ParameterImpl& operator=( const ParameterImpl& );
36
37         public:
38                 static ParameterImpl & getInstance(){
39                         static ParameterImpl instance;
40                         return instance;
41                 }
42                 bool    init();
43                 bool    rereadFile( const PARAMETER_COMPONENT_TAG );
44         
45                 bool    isIntExist( const PARAMETER_COMPONENT_TAG, const std::string& );
46                 bool    isStringExist( const PARAMETER_COMPONENT_TAG, const std::string& );
47                 int     getIntValue( const PARAMETER_COMPONENT_TAG, const std::string& );
48                 std::string     getStringValue( const PARAMETER_COMPONENT_TAG, const std::string& );
49
50                 void    registerFunctionPointer( const PARAMETER_COMPONENT_TAG, void (*)() );
51         };
52 }
53 #endif  //__PARAMETER_IMPL_H__