Nemiver  0.3
nmv-i-conf-mgr.h
Go to the documentation of this file.
1 // Author: Dodji Seketeli
2 /*
3  *This file is part of the Nemiver project
4  *
5  *Nemiver is free software; you can redistribute
6  *it and/or modify it under the terms of
7  *the GNU General Public License as published by the
8  *Free Software Foundation; either version 2,
9  *or (at your option) any later version.
10  *
11  *Nemiver is distributed in the hope that it will
12  *be useful, but WITHOUT ANY WARRANTY;
13  *without even the implied warranty of
14  *MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
15  *See the GNU General Public License for more details.
16  *
17  *You should have received a copy of the
18  *GNU General Public License along with Nemiver;
19  *see the file COPYING.
20  *If not, write to the Free Software Foundation,
21  *Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22  *
23  *See COPYRIGHT file copyright information.
24  */
25 #ifndef __NMV_CONF_MGR_H__
26 #define __NMV_CONF_MGR_H__
27 
28 #include "config.h"
29 #include <list>
31 #include "common/nmv-env.h"
32 
40 
41 NEMIVER_BEGIN_NAMESPACE (nemiver)
42 
43 class IConfMgr;
45 
47  //non copyable
48  IConfMgr (const IConfMgr &);
49  IConfMgr& operator= (const IConfMgr &);
50 
51 protected:
52 
53  IConfMgr (DynamicModule *a_dynmod) : DynModIface (a_dynmod)
54  {
55  }
56 
57 public:
58 
59  virtual ~IConfMgr () {}
60 
61  virtual const UString& get_default_namespace () const = 0;
62 
63  virtual void register_namespace
64  (const UString &a_namespace = /*default namespace*/"") = 0;
65 
66  virtual bool get_key_value (const UString &a_key,
67  UString &a_value,
68  const UString &a_namespace = "") = 0;
69  virtual void set_key_value (const UString &a_key,
70  const UString &a_value,
71  const UString &a_namespace = "") = 0;
72 
73  virtual bool get_key_value (const UString &a_key,
74  bool &a_value,
75  const UString &a_namespace = "") = 0;
76  virtual void set_key_value (const UString &a_key,
77  bool a_value,
78  const UString &a_namespace = "") = 0;
79 
80  virtual bool get_key_value (const UString &a_key,
81  int &a_value,
82  const UString &a_namespace = "") = 0;
83  virtual void set_key_value (const UString &a_key,
84  int a_value,
85  const UString &a_namespace = "") = 0;
86 
87  virtual bool get_key_value (const UString &a_key,
88  double &a_value,
89  const UString &a_namespace = "") = 0;
90  virtual void set_key_value (const UString &a_key,
91  double a_value,
92  const UString &a_namespace = "") = 0;
93 
94  virtual bool get_key_value (const UString &a_key,
95  std::list<UString> &a_value,
96  const UString &a_namespace = "") = 0;
97  virtual void set_key_value (const UString &a_key,
98  const std::list<UString> &a_value,
99  const UString &a_namespace = "") = 0;
100 
101  virtual sigc::signal<void,
102  const UString&,
103  const UString&>& value_changed_signal () = 0;
104 
105 };//end class IConfMgr
106 
118 template<class T>
120 load_iface_and_confmgr (const UString &a_dynmod_name,
121  const UString &a_iface_name,
122  IConfMgrSafePtr &a_confmgr)
123 {
124  typedef SafePtr<T, ObjectRef, ObjectUnref> TSafePtr;
125 
126  // Load the confmgr interface
127  a_confmgr =
128  common::DynamicModuleManager::load_iface_with_default_manager<IConfMgr>
129  (CONFIG_MGR_MODULE_NAME, "IConfMgr");
130 
131  //Load the IDebugger iterface
132  TSafePtr iface =
133  common::DynamicModuleManager::load_iface_with_default_manager<T>
134  (a_dynmod_name, a_iface_name);
135  THROW_IF_FAIL (iface);
136  return iface;
137 }
138 
154 template<class T>
156 load_iface_and_confmgr (const UString &a_dynmod_name,
157  const UString &a_iface_name)
158 {
159  IConfMgrSafePtr m;
161  result = load_iface_and_confmgr<T> (a_dynmod_name, a_iface_name, m);
162  result->do_init (m);
163  return result;
164 }
165 
166 
167 NEMIVER_END_NAMESPACE(nemiver)
168 
169 #endif //__NMV_CONF_MGR_H__
nemiver::load_iface_and_confmgr
SafePtr< T, ObjectRef, ObjectUnref > load_iface_and_confmgr(const UString &a_dynmod_name, const UString &a_iface_name)
Definition: nmv-i-conf-mgr.h:156
nemiver
Definition: nmv-address.h:31
nemiver::common::ObjectRef
Definition: nmv-safe-ptr-utils.h:45
NEMIVER_API
#define NEMIVER_API
Definition: nmv-api-macros.h:53
nemiver::common::DynamicModule
The base class for loadable modules.
Definition: nmv-dynamic-module.h:76
nemiver::common::UString
Definition: nmv-ustring.h:45
nemiver::common::DynModIface
Definition: nmv-dynamic-module.h:220
nemiver::IConfMgr::IConfMgr
IConfMgr(DynamicModule *a_dynmod)
Definition: nmv-i-conf-mgr.h:53
nemiver::IConfMgr
Definition: nmv-i-conf-mgr.h:46
nmv-dynamic-module.h
nmv-env.h
nemiver::IConfMgr::~IConfMgr
virtual ~IConfMgr()
Definition: nmv-i-conf-mgr.h:59
nemiver::common::ObjectUnref
Definition: nmv-safe-ptr-utils.h:55
nemiver::common::SafePtr
Definition: nmv-safe-ptr.h:71
nemiver::common::DynamicModuleSafePtr
SafePtr< DynamicModule, ObjectRef, ObjectUnref > DynamicModuleSafePtr
Definition: nmv-dynamic-module.h:61
THROW_IF_FAIL
#define THROW_IF_FAIL(a_cond)
Definition: nmv-exception.h:65