Pol  Revision:cb584c9
cfgrepos.h
Go to the documentation of this file.
1 
11 #ifndef CFGREPOS_H
12 #define CFGREPOS_H
13 
14 #include "pol_global_config.h"
15 
16 #include <map>
17 #include <string>
18 #include <time.h>
19 #include <utility>
20 
21 #include "../clib/boostutils.h"
22 #include "../clib/maputil.h"
23 #include "../clib/refptr.h"
24 
25 namespace Pol
26 {
27 namespace Bscript
28 {
29 class BObjectImp;
30 }
31 namespace Clib
32 {
33 class ConfigElem;
34 class ConfigFile;
35 }
36 namespace Core
37 {
39 {
40 private:
41  typedef std::multimap<boost_utils::cfg_key_flystring, ref_ptr<Bscript::BObjectImp>,
44 
45 public:
46  StoredConfigElem() = default;
49 
50  StoredConfigElem( const StoredConfigElem& elem ) = delete;
51  StoredConfigElem& operator=( const StoredConfigElem& ) = delete;
52 
53  size_t estimateSize() const;
54 
55  Bscript::BObjectImp* getimp( const std::string& propname ) const;
56  Bscript::BObjectImp* listprops() const;
57  void addprop( const std::string& propname, Bscript::BObjectImp* imp );
58 
59  typedef StoredConfigElem::PropImpList::const_iterator const_iterator;
60  std::pair<const_iterator, const_iterator> equal_range( const std::string& propname ) const;
61 
62 private:
64 };
65 
67 {
68 public:
70  // ~StoredConfigFile();
71  void load( Clib::ConfigFile& cf );
72  void load_tus_scp( const std::string& filename );
73  size_t estimateSize() const;
74 
76  ElemRef findelem( int key );
77  ElemRef findelem( const std::string& key );
78 
79  int maxintkey() const;
80  time_t modified() const;
81 
82  typedef std::map<std::string, ElemRef, Clib::ci_cmp_pred> ElementsByName;
83  ElementsByName::const_iterator byname_begin() { return elements_byname_.begin(); }
84  ElementsByName::const_iterator byname_end() { return elements_byname_.end(); }
85  typedef std::map<int, ElemRef> ElementsByNum;
86  ElementsByNum::const_iterator bynum_begin() { return elements_bynum_.begin(); }
87  ElementsByNum::const_iterator bynum_end() { return elements_bynum_.end(); }
88  bool reload; // try to reload cfg file?
89 private:
90  ElementsByName elements_byname_;
91 
92  ElementsByNum elements_bynum_;
93 
94  time_t modified_; // used to detect modification
95 
96  // not implemented:
98  StoredConfigFile& operator=( const StoredConfigFile& );
99 };
100 
102 
103 ConfigFileRef FindConfigFile( const std::string& filename, const std::string& allpkgbase );
104 void CreateEmptyStoredConfigFile( const std::string& filename );
105 int UnloadConfigFile( const std::string& filename );
106 ConfigFileRef LoadTusScpFile( const std::string& filename );
107 
108 #ifdef MEMORYLEAK
109 void ConfigFiles_log_stuff();
110 #endif
111 }
112 }
113 
114 #endif
std::map< int, ElemRef > ElementsByNum
Definition: cfgrepos.h:85
ref_ptr< StoredConfigElem > ElemRef
Definition: cfgrepos.h:75
ElementsByNum::const_iterator bynum_end()
Definition: cfgrepos.h:87
ref_ptr< StoredConfigFile > ConfigFileRef
Definition: cfgrepos.h:101
void CreateEmptyStoredConfigFile(const std::string &filename)
Definition: cfgrepos.cpp:338
int UnloadConfigFile(const std::string &filename)
Definition: cfgrepos.cpp:344
ElementsByName elements_byname_
Definition: cfgrepos.h:90
StoredConfigElem::PropImpList::const_iterator const_iterator
Definition: cfgrepos.h:59
ElementsByName::const_iterator byname_begin()
Definition: cfgrepos.h:83
std::multimap< boost_utils::cfg_key_flystring, ref_ptr< Bscript::BObjectImp >, Clib::ci_cmp_pred > PropImpList
Definition: cfgrepos.h:43
Definition: refptr.h:65
ElementsByNum elements_bynum_
Definition: cfgrepos.h:92
ConfigFileRef FindConfigFile(const std::string &filename, const std::string &allpkgbase)
Definition: cfgrepos.cpp:245
ElementsByName::const_iterator byname_end()
Definition: cfgrepos.h:84
ConfigFileRef LoadTusScpFile(const std::string &filename)
Definition: cfgrepos.cpp:326
Definition: berror.cpp:12
ElementsByNum::const_iterator bynum_begin()
Definition: cfgrepos.h:86
std::map< std::string, ElemRef, Clib::ci_cmp_pred > ElementsByName
Definition: cfgrepos.h:82