source: trunk/lib/Configuration.h @ 508

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

default parse codons in Configuration and implemented writing of variable

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 3.1 KB
Line 
1#ifndef _theplu_svndigest_configuration_
2#define _theplu_svndigest_configuration_
3
4// $Id: Configuration.h 508 2007-12-08 07:08:33Z 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    /// @brief Aliases for Copyright
49    ///
50    const std::map<std::string, Alias>& copyright_alias(void) const;
51
52    ///
53    /// @brief load deafult configuration
54    ///
55    void load(void);
56
57    ///
58    /// throw if stream is not a valid config
59    ///
60    /// @brief load configuration from stream
61    ///
62    void load(std::istream&);
63
64    ///
65    /// @return true if we should warn about missing copyright statement
66    ///
67    bool  missing_copyright_warning(void) const;
68
69    /**
70       \return vector of parse codons for the given \a file_name
71     */
72    const std::vector<std::pair<std::string, std::string> >& 
73    parse_codon(std::string file_name) 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> > codons;
112    typedef std::vector<std::pair<std::string, codons> > String2Codons; 
113    String2Codons string2codons_;
114
115    std::string trac_root_;
116  };
117
118  ///
119  /// @brief Output operator
120  ///
121  std::ostream& operator<<(std::ostream&, const Configuration&);
122
123}} // end of namespace svndigest and namespace theplu
124
125#endif
126
127
Note: See TracBrowser for help on using the repository browser.