CLHEP VERSION Reference Documentation
   
CLHEP Home Page     CLHEP Documentation     CLHEP Bug Reports

CLHEP/GenericFunctions/Argument.hh
Go to the documentation of this file.
1 // -*- C++ -*-
2 // $Id: Argument.hh,v 1.2 2003/09/06 14:04:13 boudreau Exp $
3 #ifndef __ARGUMENT_H_
4 #define __ARGUMENT_H_
5 #include <iostream>
6 #include <vector>
7 #include <iterator>
8 #include <algorithm>
9 // Here is an argument
10 
11 namespace Genfun {
12 
17  class Argument {
18 
19  public:
20 
21  // Constructor
22  Argument(int ndim=0);
23 
24  // Copy Constructor
25  Argument( const Argument &);
26 
27  // Assignment operator
28  const Argument & operator=(const Argument &);
29 
30  // Destructor:
31  ~Argument();
32 
33  // Set/Get Value
34  double & operator[] (int I);
35  const double & operator[] (int i) const;
36 
37  // Get the dimensions
38  unsigned int dimension() const;
39 
40  private:
41 
42  std::vector<double> *_data;
43 
44  friend std::ostream & operator << (std::ostream & o, const Argument & a);
45 
46  };
47 
48  inline Argument::Argument(const Argument & right):
49  _data(new std::vector<double>(*(right._data))){
50  }
51 
52  inline const Argument & Argument::operator=( const Argument & right) {
53  if (this != &right) {
54  delete _data;
55  _data=NULL;
56  _data = new std::vector<double>(*(right._data));
57  }
58  return *this;
59  }
60 
61  inline unsigned int Argument::dimension() const {
62  return _data->size();
63  }
64 
65  inline double & Argument::operator[] (int i) {
66  return (*_data)[i];
67  }
68 
69  inline const double & Argument::operator[] (int i) const {
70  return (*_data)[i];
71  }
72 
73  inline Argument::Argument(int ndim): _data(new std::vector<double>(ndim)) {
74  }
75 
77  delete _data;
78  }
79 
80 
81  inline std::ostream & operator << (std::ostream & os, const Argument & a) {
82  std::ostream_iterator<double> oi(os,",");
83  std::copy (a._data->begin(),a._data->end(),oi);
84  return os;
85  }
86 } // namespace Genfun
87 #endif
double
#define double(obj)
Definition: excDblThrow.cc:32
a
@ a
Definition: testCategories.cc:125
Genfun::Argument::operator[]
double & operator[](int I)
Definition: CLHEP/GenericFunctions/Argument.hh:65
Genfun::operator<<
std::ostream & operator<<(std::ostream &os, const Argument &a)
Definition: CLHEP/GenericFunctions/Argument.hh:81
Genfun::Argument::dimension
unsigned int dimension() const
Definition: CLHEP/GenericFunctions/Argument.hh:61
Genfun::Argument::operator=
const Argument & operator=(const Argument &)
Definition: CLHEP/GenericFunctions/Argument.hh:52
Genfun::Argument::~Argument
~Argument()
Definition: CLHEP/GenericFunctions/Argument.hh:76
Genfun::Argument::operator<<
friend std::ostream & operator<<(std::ostream &o, const Argument &a)
Definition: CLHEP/GenericFunctions/Argument.hh:81
Genfun::Argument
Definition: CLHEP/GenericFunctions/Argument.hh:17
Genfun::Argument::Argument
Argument(int ndim=0)
Definition: CLHEP/GenericFunctions/Argument.hh:73
i
long i
Definition: JamesRandomSeeding.txt:27
Genfun
Definition: CLHEP/GenericFunctions/Abs.hh:14