Changeset 264 for trunk/lib


Ignore:
Timestamp:
Apr 30, 2007, 11:54:25 PM (14 years ago)
Author:
Peter Johansson
Message:

turned Configuration class into a singleton

Location:
trunk/lib
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/Configuration.cc

    r229 r264  
    3535namespace svndigest{
    3636
     37  Configuration* Configuration::instance_=NULL;
     38
     39
    3740  Configuration::Configuration(void)
     41  {
     42  }
     43
     44
     45  void Configuration::load(void)
    3846  {
    3947    set_default();
     
    4149
    4250
    43   Configuration::Configuration(std::istream& is)
     51  void Configuration::load(std::istream& is)
    4452  {
    4553    assert(is.good());
     
    6674      }
    6775    }
     76  }
     77
     78
     79  Configuration* Configuration::instance(void)
     80  {
     81    if (!instance_)
     82      instance_ = new Configuration;
     83    return instance_;
    6884  }
    6985
  • trunk/lib/Configuration.h

    r229 r264  
    2525*/
    2626
    27 #include <fstream>
     27#include <iostream>
    2828#include <map>
    2929#include <string>
     
    3535  {
    3636  public:
    37     ///
    38     /// Creates a Config object with default settings.
    39     ///
    40     /// @brief Default Constructor
    41     ///
    42     Configuration(void);
     37    static Configuration* instance(void);
    4338
    4439    ///
    45     /// @brief Stream Constructor
     40    /// @brief load deafult configuration
    4641    ///
    47     Configuration(std::istream&);
     42    void load(void);
     43
     44    ///
     45    /// @brief load configuration from stream
     46    ///
     47    void load(std::istream&);
    4848
    4949    ///
     
    5454
    5555  private:
     56    ///
     57    /// Creates a Config object with default settings.
     58    ///
     59    /// @brief Default Constructor
     60    ///
     61    Configuration(void);
     62
     63    void clear(void);
     64
    5665    void set_default(void);
     66
     67    static Configuration* instance_;
    5768
    5869    std::map<std::string, std::string> copyright_alias_;
Note: See TracChangeset for help on using the changeset viewer.