CLHEP 2.4.6.4
C++ Class Library for High Energy Physics
Loading...
Searching...
No Matches
Argument.hh
Go to the documentation of this file.
1// -*- C++ -*-
2//
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
11namespace Genfun {
12
13 /**
14 * @author
15 * @ingroup genfun
16 */
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 (unsigned int)_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
Argument(int ndim=0)
Definition: Argument.hh:73
const Argument & operator=(const Argument &)
Definition: Argument.hh:52
friend std::ostream & operator<<(std::ostream &o, const Argument &a)
Definition: Argument.hh:81
unsigned int dimension() const
Definition: Argument.hh:61
double & operator[](int I)
Definition: Argument.hh:65
#define double(obj)
Definition: excDblThrow.cc:32
Definition: Abs.hh:14
std::ostream & operator<<(std::ostream &os, const Argument &a)
Definition: Argument.hh:81