source: trunk/bin/AbstractParameter.h @ 1293

Last change on this file since 1293 was 1293, checked in by Peter Johansson, 11 years ago

rewrite svndigest-copy-cache in C++. closes #463

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 2.6 KB
Line 
1#ifndef _theplu_svndigest_abstract_parameter_
2#define _theplu_svndigest_abstract_parameter_
3
4// $Id: AbstractParameter.h 1293 2010-11-14 05:34:10Z peter $
5
6/*
7  Copyright (C) 2006, 2007, 2008 Jari Häkkinen, Peter Johansson
8  Copyright (C) 2009, 2010 Peter Johansson
9
10  This file is part of svndigest, http://dev.thep.lu.se/svndigest
11
12  svndigest is free software; you can redistribute it and/or modify it
13  under the terms of the GNU General Public License as published by
14  the Free Software Foundation; either version 3 of the License, or
15  (at your option) any later version.
16
17  svndigest is distributed in the hope that it will be useful, but
18  WITHOUT ANY WARRANTY; without even the implied warranty of
19  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20  General Public License for more details.
21
22  You should have received a copy of the GNU General Public License
23  along with svndigest. If not, see <http://www.gnu.org/licenses/>.
24*/
25
26#include "lib/OptionVersion.h"
27
28#include "yat/CommandLine.h"
29#include "yat/OptionArg.h"
30#include "yat/OptionHelp.h"
31#include "yat/OptionSwitch.h"
32
33
34#include <string>
35
36namespace theplu {
37namespace yat { 
38namespace utility {
39  class OptionHelp;
40  class OptionSwitch;
41}}
42namespace svndigest {
43
44  class OptionVersion;
45
46  // class for command line options.
47  class AbstractParameter {
48  public:
49    AbstractParameter(void);
50    virtual ~AbstractParameter(void);
51    void parse( int argc, char *argv[]);
52
53    /**
54       @return Dereferenced absolute path to root directory
55    */
56    std::string root(void) const;
57
58    /**
59       If --root argument is a link we return the file_name(argument).
60       Otherwise we return file_name(root()). See root(void).
61
62       \return basename of --root argument.
63     */
64    const std::string& root_basename(void) const;
65    bool verbose(void) const;
66
67  protected:
68    yat::utility::CommandLine cmd_;
69    yat::utility::OptionHelp help_;
70    yat::utility::OptionArg<std::string> root_;
71
72    // check that root is OK, i.e., an existing, readable and
73    // accessible directory. throw cmd_error if not.
74    void analyse_root(const std::string root);
75
76    // throw cmd_error if path doesn't exist
77    void check_existence(std::string path) const;
78    // throw cmd_error if path is not dir
79    void check_is_dir(std::string path) const;
80    // throw cmd_error if path is not readable
81    void check_readable(std::string path) const;
82
83  private:
84    void analyse(void);
85    virtual void analyse1(void)=0;
86    void init(void);
87    // called at end of init(void)
88    virtual void init1(void) = 0;
89    void set_default(void);
90    virtual void set_default1(void)=0;
91
92    std::string root_basename_;
93    std::string root_full_;
94    yat::utility::OptionSwitch verbose_;
95  protected:
96    OptionVersion version_;
97
98  };
99
100}} // of namespace svndigest and namespace theplu
101
102#endif
Note: See TracBrowser for help on using the repository browser.