CLHEP/GenericFunctions/Parameter.hh

00001 // -*- C++ -*-
00002 // $Id: Parameter.hh,v 1.4 2002/04/12 15:02:40 evc Exp $
00003 //-----------------------Class Parameter------------------------------------//
00004 //                                                                          //
00005 //  Joe Boudreau                                                            //
00006 //  Petar Maksimovic                                                        //
00007 //  November 1999                                                           //
00008 //                                                                          //
00009 //  This class is a simple low-level double precision number, together with //
00010 //  some limiting values. It is designed essentially as an ingredient for   //
00011 //  building function objects.                                              //
00012 //                                                                          //
00013 //  Parameters can be connnected to one another. If a parameter is          //
00014 //  connected, it takes is value (and limits) from the parameter to which   //
00015 //  it is connected.                                                        //
00016 //  When disconnected, it captures the values of the connected field before //
00017 //  dropping the connection.  An attempt to alter the values of the field   //
00018 //  while the Parameter is connected to another parameter will result in    //
00019 //  an obnoxious warning mesage.                                            //
00020 //                                                                          //
00021 //--------------------------------------------------------------------------//
00022 #ifndef Parameter_h
00023 #define Parameter_h 1
00024 
00025 #include "CLHEP/config/CLHEP.h"
00026 #include "CLHEP/config/iostream.h"
00027 #include <string>
00028 #include "CLHEP/GenericFunctions/AbsParameter.hh"
00029 
00030 namespace Genfun {
00031 
00036   class Parameter:public AbsParameter {
00037 
00038     PARAMETER_OBJECT_DEF(Parameter)
00039   
00040       public:
00041   
00042     // Constructor.
00043     Parameter(HepSTL::string name,
00044               double value, 
00045               double lowerLimit=-1e100,
00046               double upperLimit= 1e100);
00047   
00048     // Copy constructor
00049     Parameter(const Parameter & right);
00050   
00051     // Destructor
00052     virtual ~Parameter();
00053 
00054     // Assignment
00055     const Parameter & operator=(const Parameter &right);
00056   
00057     // Accessor for the Parameter name
00058     const HepSTL::string & getName() const;
00059 
00060     // Accessor for value
00061     virtual double getValue() const;
00062   
00063     // Accessor for Lower Limit
00064     double getLowerLimit() const;
00065   
00066     // Accessor for Upper Limit
00067     double getUpperLimit() const;
00068   
00069     // Set Value
00070     void setValue(double value);
00071   
00072     // Set Lower Limit
00073     void setLowerLimit(double lowerLimit);
00074   
00075     // Set Upper Limit
00076     void setUpperLimit(double upperLimit);
00077   
00078     // Take values + limits from some other parameter.
00079     void connectFrom(const AbsParameter *  source);
00080   
00081     // Extra lingual type information:
00082     virtual Parameter *parameter() {return this;}
00083     virtual const Parameter *parameter() const {return this;}
00084   
00085   private:
00086 
00087     HepSTL::string        _name ;                // name
00088     double                _value;                // value
00089     double                _lowerLimit;           // lower limit
00090     double                _upperLimit;           // upper limit
00091     const AbsParameter   *_sourceParameter;      // connection
00092   
00093   };
00094 HepStd::ostream & operator << ( HepStd::ostream & o, const Parameter &p);
00095 } // namespace Genfun
00096 
00097 #endif

Class Library for High Energy Physics (version 1.8)