Darwin  1.10(beta)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
drwnConfigManager.h
1 /******************************************************************************
2 ** DARWIN: A FRAMEWORK FOR MACHINE LEARNING RESEARCH AND DEVELOPMENT
3 ** Distributed under the terms of the BSD license (see the LICENSE file)
4 ** Copyright (c) 2007-2015, Stephen Gould
5 ** All rights reserved.
6 **
7 ******************************************************************************
8 ** FILENAME: drwnConfigManager.h
9 ** AUTHOR(S): Stephen Gould <stephen.gould@anu.edu.au>
10 **
11 *****************************************************************************/
12 
13 #pragma once
14 
15 #include <string>
16 #include <string.h>
17 #include <iostream>
18 #include <map>
19 
20 #include "drwnXMLParser.h"
21 
22 using namespace std;
23 
24 // drwnConfigurableModule -----------------------------------------------------
25 
36  private:
37  string _moduleName;
38 
39  public:
41  drwnConfigurableModule(const char *module);
44  virtual ~drwnConfigurableModule();
45 
47  inline const string& name() const { return _moduleName; }
49  virtual void usage(ostream& os) const;
50 
52  void readConfiguration(const char *filename);
54  virtual void readConfiguration(drwnXMLNode& node);
56  virtual void setConfiguration(const char* name, const char *value) = 0;
57 };
58 
59 // drwnConfigurationManager ---------------------------------------------------
60 
72  friend class drwnConfigurableModule;
73 
74  private:
75  typedef map<string, drwnConfigurableModule *> drwnConfigRegistry;
76  drwnConfigRegistry _registry;
77 
78  public:
80 
82  static drwnConfigurationManager& get();
83 
85  void configure(const char *filename);
87  void configure(drwnXMLNode& root);
89  void configure(const char *module, const char *name, const char *value);
90 
92  void showModuleUsage(const char *module) const;
94  void showRegistry(bool bIncludeUsage = true) const;
95 
96  protected:
97  drwnConfigurationManager(); // singleton class so hide constructor
98 
100  void registerModule(drwnConfigurableModule *m);
102  void unregisterModule(drwnConfigurableModule *m);
103 };
const string & name() const
return the name of the module
Definition: drwnConfigManager.h:47
Configuration manager.
Definition: drwnConfigManager.h:71
Interface for a configurable module.
Definition: drwnConfigManager.h:35
Provides XML parsing functionality for serializing and deserializing objects and containers of object...