source: trunk/lib/Configuration.h @ 515

Last change on this file since 515 was 515, checked in by Peter Johansson, 14 years ago

adding dictionary variable in Configuration. Reading and usage of the variable needs to be implemented

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 3.2 KB
Line 
1#ifndef _theplu_svndigest_configuration_
2#define _theplu_svndigest_configuration_
3
4// $Id: Configuration.h 515 2007-12-09 02:38:34Z peter $
5
6/*
7  Copyright (C) 2007 Peter Johansson
8
9  This file is part of svndigest, http://trac.thep.lu.se/trac/svndigest
10
11  svndigest is free software; you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation; either version 2 of the License, or
14  (at your option) any later version.
15
16  svndigest is distributed in the hope that it will be useful, but
17  WITHOUT ANY WARRANTY; without even the implied warranty of
18  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19  General Public License for more details.
20
21  You should have received a copy of the GNU General Public License
22  along with this program; if not, write to the Free Software
23  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
24  02111-1307, USA.
25*/
26
27#include "Alias.h"
28
29#include <iostream>
30#include <map>
31#include <string>
32#include <utility>
33#include <vector>
34
35namespace theplu{
36namespace svndigest{
37
38  ///
39  /// Configuration class takes care of all setting defined in the
40  /// configuration file.
41  ///
42  class Configuration
43  {
44  public:
45    static Configuration& instance(void);
46
47    /**
48       \return vector of parse codons for the given \a file_name
49     */
50    const std::vector<std::pair<std::string, std::string> >* 
51    codon(std::string file_name) const;
52
53    ///
54    /// @brief Aliases for Copyright
55    ///
56    const std::map<std::string, Alias>& copyright_alias(void) const;
57
58    ///
59    /// @brief load deafult configuration
60    ///
61    void load(void);
62
63    ///
64    /// throw if stream is not a valid config
65    ///
66    /// @brief load configuration from stream
67    ///
68    void load(std::istream&);
69
70    ///
71    /// @return true if we should warn about missing copyright statement
72    ///
73    bool  missing_copyright_warning(void) const;
74
75    ///
76    /// @return root for the trac envrionment, e.g.,
77    /// http://trac.thep.lu.se/trac/svndigest/
78    ///
79    std::string trac_root(void) const;
80
81  private:
82    ///
83    /// Creates a Config object with default settings.
84    ///
85    /// @brief Default Constructor
86    ///
87    Configuration(void);
88    // Copy Constructor not implemented
89    Configuration(const Configuration&);
90    // assignment not implemented because assignment is always self-assignment
91    Configuration& operator=(const Configuration&);
92
93    friend std::ostream& operator<<(std::ostream&, const Configuration&);
94
95    void add_codon(std::string, std::string, std::string);
96
97    void clear(void);
98
99    bool equal_false(const std::string&) const;
100    bool equal_true(const std::string&) const;
101    std::string trans_end_code(std::string) const;
102    std::string trans_beg_code(std::string) const;
103    void set_default(void);
104   
105    static Configuration* instance_;
106
107    std::map<std::string, Alias> copyright_alias_;
108
109    bool missing_copyright_warning_;
110   
111    typedef std::vector<std::pair<std::string, std::string> > VectorPair;
112    typedef std::vector<std::pair<std::string, VectorPair> > String2Codons; 
113    String2Codons string2codons_;
114
115    VectorPair dictionary_;
116
117    std::string trac_root_;
118  };
119
120  ///
121  /// @brief Output operator
122  ///
123  std::ostream& operator<<(std::ostream&, const Configuration&);
124
125}} // end of namespace svndigest and namespace theplu
126
127#endif
128
129
Note: See TracBrowser for help on using the repository browser.