libpnicore
config_argument.hpp
1 //
2 // (c) Copyright 2012 DESY, Eugen Wintersberger <eugen.wintersberger@desy.de>
3 //
4 // This file is part of libpnicore.
5 //
6 // libpnicore is free software: you can redistribute it and/or modify
7 // it under the terms of the GNU General Public License as published by
8 // the Free Software Foundation, either version 2 of the License, or
9 // (at your option) any later version.
10 //
11 // libpnicore is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
15 //
16 // You should have received a copy of the GNU General Public License
17 // along with libpnicore. If not, see <http://www.gnu.org/licenses/>.
18 //
19 // ============================================================================
20 //
21 // Created on: Dec 27, 2012
22 // Author: Eugen Wintersberger <eugen.wintersberger@desy.de>
24 #pragma once
25 
26 #include "../types.hpp"
27 #include "config_option.hpp"
28 
29 
30 namespace pni{
31 namespace core{
32 
49  template<typename T>
51  {
52  private:
54  int _position;
55 
56  public:
57  //-----------------------------------------------------------------
60 
61  //-----------------------------------------------------------------
69  config_argument(const string &lname,int pos,T *exref=nullptr);
70 
71  //-----------------------------------------------------------------
80  config_argument(const string &lname,int pos,T default_value,
81  T *exref=nullptr);
82 
83  //-----------------------------------------------------------------
86 
87  //-----------------------------------------------------------------
89  int position() const { return _position; }
90  };
91 
92  //--------------------------------------------------------------------------
93  template<typename T> config_argument<T>::config_argument():
94  config_option<T>(),
95  _position(0)
96  {}
97 
98  //--------------------------------------------------------------------------
99  template<typename T>
100  config_argument<T>::config_argument(const string &lname,int pos,T *exref):
101  config_option<T>(lname,"","",exref),
102  _position(pos)
103  {}
104 
105  //--------------------------------------------------------------------------
106  template<typename T>
107  config_argument<T>::config_argument(const string &lname,int pos,
108  T default_value, T *exref):
109  config_option<T>(lname,"","",default_value,exref),
110  _position(pos)
111  {}
112 
113 //end of namespace
114 }
115 }
class describing a program option
Definition: config_option.hpp:47
class describing a program argument
Definition: config_argument.hpp:50
Definition: add_op.hpp:29
int _position
position of the argument in the argument list
Definition: config_argument.hpp:54
config_argument()
default constructor
Definition: config_argument.hpp:93
int position() const
get short name
Definition: config_argument.hpp:89
T default_value() const
get default value
Definition: config_option.hpp:117
~config_argument()
destructor
Definition: config_argument.hpp:85