diff --git a/Interface/Makefile.am b/Interface/Makefile.am --- a/Interface/Makefile.am +++ b/Interface/Makefile.am @@ -1,23 +1,24 @@ mySOURCES = InterfaceBase.cc InterfacedBase.cc Interfaced.cc ParVector.cc \ - Parameter.cc RefVector.cc Reference.cc Switch.cc Command.cc \ + ParMap.cc Parameter.cc RefVector.cc Reference.cc Switch.cc Command.cc \ ClassDocumentation.cc Deleted.cc DOCFILES = Command.h InterfaceBase.h Interfaced.h InterfacedBase.h ParVector.h \ Parameter.h RefVector.h Reference.h Switch.h ClassDocumentation.h \ - Interface.h + Interface.h ParMap.h INCLUDEFILES = $(DOCFILES) Command.fh Command.tcc \ Command.xh InterfaceBase.fh InterfaceBase.xh \ InterfacedBase.xh ParVector.fh \ ParVector.tcc ParVector.xh Parameter.fh \ + ParMap.fh ParMap.tcc ParMap.xh \ Parameter.tcc Parameter.xh RefVector.fh \ RefVector.tcc RefVector.xh Reference.fh \ Reference.tcc Reference.xh Switch.fh \ Switch.tcc Switch.xh ClassDocumentation.fh Deleted.h noinst_LTLIBRARIES = libThePEGInter.la libThePEGInter_la_SOURCES = $(mySOURCES) $(INCLUDEFILES) include $(top_srcdir)/Config/Makefile.aminclude diff --git a/Interface/ParVector.cc b/Interface/ParMap.cc copy from Interface/ParVector.cc copy to Interface/ParMap.cc --- a/Interface/ParVector.cc +++ b/Interface/ParMap.cc @@ -1,141 +1,141 @@ // -*- C++ -*- // -// ParVector.cc is a part of ThePEG - Toolkit for HEP Event Generation +// ParMap.cc is a part of ThePEG - Toolkit for HEP Event Generation // Copyright (C) 1999-2019 Leif Lonnblad // // ThePEG is licenced under version 3 of the GPL, see COPYING for details. // Please respect the MCnet academic guidelines, see GUIDELINES for details. // // // This is the implementation of the non-inlined, non-templated member -// functions of the ParVectorBase class. +// functions of the ParMapBase class. // #include "InterfacedBase.h" -#include "ParVector.h" -#include "ParVector.xh" +#include "ParMap.h" +#include "ParMap.xh" #ifdef ThePEG_TEMPLATES_IN_CC_FILE -#include "ParVector.tcc" +#include "ParMap.tcc" #endif namespace ThePEG { -string ParVectorBase:: +string ParMapBase:: exec(InterfacedBase & i, string action, string arguments) const { istringstream arg(arguments.c_str()); int place = 0; if ( !(arg >> place) ) place = -1; ostringstream ret; if ( action == "get" ) { - StringVector v = get(i); + StringMap v = get(i); if ( place >= 0 ) return v[place]; - for ( StringVector::const_iterator it = v.begin(); it != v.end(); ++it ) { + for ( StringMap::const_iterator it = v.begin(); it != v.end(); ++it ) { if ( it != v.begin() ) ret << ", "; - ret << *it; + ret << "(" << it->first << "," << it->second << ")"; } } else if ( action == "erase" ) { erase(i, place); } else if ( action == "clear" ) { clear(i); } else if ( action == "min" ) { return minimum(i, place); } else if ( action == "max" ) { return maximum(i, place); } else if ( action == "def" ) { return def(i, place); } else if ( action == "setdef" ) { if ( objectDefaults(i).find(tag(place)) == objectDefaults(i).end() ) setDef(i, place); else set(i, objectDefaults(i)[tag(place)], place); } else if ( action == "set" || action == "insert" || action == "newdef") { string val; arg >> val; if ( action == "insert" ) insert(i, val, place); else set(i, val, place); if ( action == "newdef" ) objectDefaults(i)[tag(place)] = get(i)[place]; } else if ( action == "notdef" ) { - StringVector v = get(i); + StringMap v = get(i); for ( place = 0; unsigned(place) < v.size(); ++place ) { string deflt = def(i, place); if ( objectDefaults(i).find(tag(place)) != objectDefaults(i).end() ) deflt = objectDefaults(i)[tag(place)]; else if ( !hasDefault ) continue; if ( v[place] == deflt ) continue; ret << "[" << place << "] " << v[place] << " (" << deflt << ") "; } } else throw InterExUnknown(*this, i); return ret.str(); } -string ParVectorBase::fullDescription(const InterfacedBase & ib) const { +string ParMapBase::fullDescription(const InterfacedBase & ib) const { ostringstream os; - StringVector vals = get(ib); + StringMap vals = get(ib); os << InterfaceBase::fullDescription(ib) << size() << "\n" << vals.size() << "\n"; for ( int i = 0, N = vals.size(); i < N; ++i ) { string min = minimum(ib, i); if ( min.empty() ) min = "-inf"; string max = maximum(ib, i); if ( max.empty() ) max = "inf"; os << vals[i] << "\n" << min << "\n" << def(ib, i) << "\n" << max << "\n"; } return os.str(); } -ParVExIndex::ParVExIndex(const InterfaceBase & i, const InterfacedBase & o, +ParMExIndex::ParMExIndex(const InterfaceBase & i, const InterfacedBase & o, int j) { theMessage << "Could not access element " << j - << " of the parameter vector \"" << i.name() + << " of the parameter map \"" << i.name() << "\" for the object \"" << o.name() << "\" because the index was outside of the allowed range."; severity(setuperror); } -ParVExFixed::ParVExFixed(const InterfaceBase & i, const InterfacedBase & o) { - theMessage << "Cannot insert or delete in the parameter vector \"" +ParMExFixed::ParMExFixed(const InterfaceBase & i, const InterfacedBase & o) { + theMessage << "Cannot insert or delete in the parameter map \"" << i.name() << "\" for the object \"" << o.name() - << "\" since the vector is of fixed size."; + << "\" since the map is of fixed size."; severity(setuperror); } -ParVExDelUnknown::ParVExDelUnknown(const InterfaceBase & i, +ParMExDelUnknown::ParMExDelUnknown(const InterfaceBase & i, const InterfacedBase & o, int j) { theMessage << "Could not delete the value at position " << j - << " from the parameter vector \"" << i.name() + << " from the parameter map \"" << i.name() << "\" for the object \"" << o.name() << "\" because the delete function threw an unknown exception."; severity(setuperror); } -ParVExGetUnknown::ParVExGetUnknown(const InterfaceBase & i, +ParMExGetUnknown::ParMExGetUnknown(const InterfaceBase & i, const InterfacedBase & o, const char * s) { theMessage << "Could not get the " << s - << " values from the parameter vector\"" << i.name() + << " values from the parameter map\"" << i.name() << "\" for the object \"" << o.name() << "\" because the get function threw an unknown exception."; severity(setuperror); } } #ifdef ThePEG_TEMPLATES_IN_CC_FILE -#include "ParVector.tcc" +#include "ParMap.tcc" #endif diff --git a/Interface/ParVector.fh b/Interface/ParMap.fh copy from Interface/ParVector.fh copy to Interface/ParMap.fh --- a/Interface/ParVector.fh +++ b/Interface/ParMap.fh @@ -1,21 +1,21 @@ // -*- C++ -*- -#ifndef ThePEG_ParVector_FH -#define ThePEG_ParVector_FH +#ifndef ThePEG_ParMap_FH +#define ThePEG_ParMap_FH // -// This is the forward declaration of the ParVector, ParVectorTBase -// and ParVectorBase classes. +// This is the forward declaration of the ParMap, ParMapTBase +// and ParMapBase classes. // namespace ThePEG { -class ParVectorBase; +class ParMapBase; template -class ParVectorTBase; +class ParMapTBase; template -class ParVector; +class ParMap; } -#endif /* ThePEG_ParVector_FH */ +#endif /* ThePEG_ParMap_FH */ diff --git a/Interface/ParVector.h b/Interface/ParMap.h copy from Interface/ParVector.h copy to Interface/ParMap.h --- a/Interface/ParVector.h +++ b/Interface/ParMap.h @@ -1,1068 +1,1068 @@ // -*- C++ -*- // -// ParVector.h is a part of ThePEG - Toolkit for HEP Event Generation +// ParMap.h is a part of ThePEG - Toolkit for HEP Event Generation // Copyright (C) 1999-2019 Leif Lonnblad // // ThePEG is licenced under version 3 of the GPL, see COPYING for details. // Please respect the MCnet academic guidelines, see GUIDELINES for details. // -#ifndef ThePEG_ParVector_H -#define ThePEG_ParVector_H -// This is the declaration of the ParVector, ParVectorTBase and -// ParVectorBase classes. +#ifndef ThePEG_ParMap_H +#define ThePEG_ParMap_H +// This is the declaration of the ParMap, ParMapTBase and +// ParMapBase classes. #include "ThePEG/Config/ThePEG.h" #include "InterfaceBase.h" -#include "ParVector.fh" +#include "ParMap.fh" #include namespace ThePEG { /// Helper functions for putUnit namespace { template /** * Helper function for putUnit */ inline void putUnitImpl2(ostream & os, T v, T u, DimensionT) { os << v/u; } template /** * Helper function for putUnit */ inline void putUnitImpl2(ostream & os, T v, T u, StandardT) { if ( u > T() ) os << v/u; else os << v; } } /** - * The ParVector and its base classes ParVectorTBase and ParVectorBase + * The ParMap and its base classes ParMapTBase and ParMapBase * defines an interface to a class derived from the InterfacedBase, - * through which vectors (or any other container) of simple member - * variables can be manuipulated. ParVector is templated on the type + * through which maps (or any other container) of simple member + * variables can be manuipulated. ParMap is templated on the type * of the member variable and the type of the InterfacedBase class, * and is derived from the InterfaceBase class via - * ParVectorTBase (which is templated only on the class - * of the member variable) and ParVectorBase. + * ParMapTBase (which is templated only on the class + * of the member variable) and ParMapBase. * - * For each InterfacedBase class exactly one static ParVector object + * For each InterfacedBase class exactly one static ParMap object * should created for each member variable of container type which * should be interfaced. This object will automatically register * itself with the BaseRepository class. * * @see Parameter * @see InterfacedBase * @see InterfaceBase * */ -class ParVectorBase: public InterfaceBase { +class ParMapBase: public InterfaceBase { public: - /** A vector of strings. */ - typedef vector StringVector; + /** A map of strings. */ + typedef map StringMap; public: /** * Standard constructor. * * @param newName the name of the interface, may only contain * letters [a-zA-z0-9_]. * * @param newDescription a brief description of the interface. * * @param newClassName the name of the corresponding class. * * @param newTypeInfo the type_info object of the corresponding * class. * * @param newSize the size of the container or -1 if varying. * * @param depSafe set to true if calls to this interface for one * object does not influence other objects. * * @param readonly if this is set true the interface will not be * able to manipulate objects of the corresponding class, but will * still be able to access information. * * @param limits determines if the values of the parameters are * limited from above and/or below. The possible values are given by * Interface::Limits. */ - ParVectorBase(string newName, string newDescription, + ParMapBase(string newName, string newDescription, string newClassName, const type_info & newTypeInfo, int newSize, bool depSafe, bool readonly, int limits) : InterfaceBase(newName, newDescription, newClassName, newTypeInfo, depSafe, readonly), limit(limits), theSize(newSize) { hasDefault = false; } /** * Destructor. */ - virtual ~ParVectorBase() {} + virtual ~ParMapBase() {} /** * The general interface method overriding the one in * InterfaceBase. For this class, \a action can be any of "set", * "insert", "erase", "get", "min", "max", "def" and "setdef" and \a * argument should be a something which can be read into an integer * and into a variable through a stringstream with the standard '>>' * operator. */ virtual string exec(InterfacedBase &, string action, string arguments) const; /** - * Return a complete description of this parameter vector. + * Return a complete description of this parameter map. */ virtual string fullDescription(const InterfacedBase & ib) const; /** * Set the \a i'th element of a container of member variables of \a * ib to \a val. \a val should be able to be read into the * corresponding variable type through a stringstream with the * standard '>>' operator. */ virtual void set(InterfacedBase & ib, string val, int i) const = 0; /** * Insert a new object before the \a i'th element of a container of * member variables of \a ib and set it to \a val. \a val should be * able to be read into the corresponding variable type through a * stringstream with the standard '>>' operator. */ virtual void insert(InterfacedBase & ib, string val, int i) const = 0; /** * Remove the \a i'th element of a container of member variables of * \a ib. */ virtual void erase(InterfacedBase & ib, int i) const = 0; /** * Clear the container of pointers of \a ib. */ virtual void clear(InterfacedBase & ib) const = 0; /** * Return the values of a container of member variables of \a ib. */ - virtual StringVector get(const InterfacedBase & ib) const + virtual StringMap get(const InterfacedBase & ib) const = 0; /** * Return the minimum value allowed for the \a i'th element of a * container of member variables of \a ib. */ virtual string minimum(const InterfacedBase & ib, int i) const = 0; /** * Return the maximum value allowed for the \a i'th element of a * container of member variables of \a ib. */ virtual string maximum(const InterfacedBase & ib, int i) const = 0; /** * Return the default value for the \a i'th element of a container * of member variables of \a ib. */ virtual string def(const InterfacedBase & ib, int i) const = 0; /** - * Return the general default value for this parameter vector. + * Return the general default value for this parameter map. */ virtual string def() const = 0; /** * Set the \a i'th element of a container of member variables of \a * ib to its default value. */ virtual void setDef(InterfacedBase & ib, int i) const = 0; /** * True if there the variable is limited from above and below. */ bool limited() const { return limit != Interface::nolimits; } /** * True if there the variable is limited from abovew. */ bool upperLimit() const { return limit == Interface::limited || limit == Interface::upperlim; } /** * True if there the variable is limited from below. */ bool lowerLimit() const { return limit == Interface::limited || limit == Interface::lowerlim; } /** * Set a flag indicating that there are limits associated with the * variables. */ void setLimited() { limit = Interface::limited; } /** * Set a flag indicating if there are no limits associated with the * variables. */ void setUnlimited() { limit = Interface::nolimits; } /** * Get the size of the container being interfaced. If the size() is * less than 0, the size is allowed to vary. */ int size() const { return theSize; } /** * Set the size of the container being interfaced. If the size is * less than 0, the size is allowed to vary. */ void setSize(int sz) { theSize = sz; } /** * Set the size of the container being interfaced to -1, i.e. the * size is allowed to vary. */ void setVariableSize() { theSize = 0; } private: /** * True if there are limits associated with the * variables. */ int limit; /** * The size of the container being interfaced. */ int theSize; }; /** - * The ParVector and its base classes ParVectorTBase and ParVectorBase + * The ParMap and its base classes ParMapTBase and ParMapBase * defines an interface to a class derived from the InterfacedBase, - * through which vectors (or any other container) of simple member - * variables can be manuipulated. ParVector is templated on the type + * through which maps (or any other container) of simple member + * variables can be manuipulated. ParMap is templated on the type * of the member variable and the type of the InterfacedBase class, * and is derived from the InterfaceBase class via - * ParVectorTBase (which is templated only on the class - * of the member variable) and ParVectorBase. + * ParMapTBase (which is templated only on the class + * of the member variable) and ParMapBase. * - * For each InterfacedBase class exactly one static ParVector object + * For each InterfacedBase class exactly one static ParMap object * should created for each member variable of container type which * should be interfaced. This object will automatically register * itself with the BaseRepository class. * * @see Parameter * @see InterfacedBase * @see InterfaceBase * */ template -class ParVectorTBase: public ParVectorBase { +class ParMapTBase: public ParMapBase { public: - /** A vector of objects of the template argument type. */ - typedef vector TypeVector; + /** A map of objects of the template argument type. */ + typedef map TypeMap; public: /** * Standard constructor. * * @param newName the name of the interface, may only contain * letters [a-zA-z0-9_]. * * @param newDescription a brief description of the interface. * * @param newClassName the name of the corresponding class. * * @param newTypeInfo the type_info object of the corresponding * class. * * @param newUnit the unit assumed when a number is read or written * to a stream. * * @param newSize the size of the container or -1 if varying. * * @param depSafe set to true if calls to this interface for one * object does not influence other objects. * * @param readonly if this is set true the interface will not be * able to manipulate objects of the corresponding class, but will * still be able to access information. * * @param limits determines if the values of the parameters are * limited from above and/or below. The possible values are given by * Interface::Limits. */ - ParVectorTBase(string newName, string newDescription, + ParMapTBase(string newName, string newDescription, string newClassName, const type_info & newTypeInfo, Type newUnit, int newSize, bool depSafe, bool readonly, int limits) - : ParVectorBase(newName, newDescription, newClassName, + : ParMapBase(newName, newDescription, newClassName, newTypeInfo, newSize, depSafe, readonly, limits), theUnit(newUnit) {} /** * Destructor. */ - virtual ~ParVectorTBase() {} + virtual ~ParMapTBase() {} /** * Return a code for the type of this parameter. */ virtual string type() const; /** * Return a string describing the type of interface to be included * in the Doxygen documentation. */ virtual string doxygenType() const; /** - * Return a complete description of this parameter vector. + * Return a complete description of this parameter map. */ virtual string fullDescription(const InterfacedBase & ib) const; /** * Set the \a i'th element of a container of member variables of \a * ib to val. Uses a stringstream to read the \a val into a Type * object and then calls tset(InterfacedBase &, Type, int). */ virtual void set(InterfacedBase & ib, string val, int i) const ; /** * Set the \a i'th element of a container of member variables of \a * ib to \a val. */ virtual void tset(InterfacedBase & ib, Type val, int i) const = 0; /** * Insert a new object before the \a i'th element of a container of * member variables of \a ib and set it to \a val. Uses a * stringstream to read the \a val into a Type object and then calls * tinsert(InterfacedBase &, Type, int). */ virtual void insert(InterfacedBase & ib, string val, int i) const ; private: /// Implementation of set() for standard types. void setImpl(InterfacedBase & ib, string val, int i, StandardT) const; /// Implementation of set() for dimensioned types. void setImpl(InterfacedBase & ib, string val, int i, DimensionT) const; /// Implementation of insert() for standard types. void insertImpl(InterfacedBase & ib, string val, int i, StandardT) const; /// Implementation of insert() for dimensioned types. void insertImpl(InterfacedBase & ib, string val, int i, DimensionT) const; public: /** * Insert a new object before the \a i'th element of a container of * member variables of \a ib and set it to \a val. */ virtual void tinsert(InterfacedBase & ib, Type val, int i) const = 0; /** * Return the values of a container of member variables of \a ib in - * a vector of strings. Calls the The tget(const InterfacedBase &) - * and returns a vector of strings converted with ostringstreams. + * a map of strings. Calls the The tget(const InterfacedBase &) + * and returns a map of strings converted with ostringstreams. */ - virtual StringVector get(const InterfacedBase & ib) const + virtual StringMap get(const InterfacedBase & ib) const ; /** * Return the values of a container of member variables of \a ib in a - * vector of Type. + * map of Type. */ - virtual TypeVector tget(const InterfacedBase & ib) const + virtual TypeMap tget(const InterfacedBase & ib) const = 0; /** * Return the minimum value allowed for the \a i'th element of a * container of member variables of \a ib. Calls tminimum(const * InterfacedBase &, int) and converts the returned value with an * ostringstream. * */ virtual string minimum(const InterfacedBase & ib, int i) const ; /** * Return the minimum value allowed for the \a i'th element of a * container of member variables of \a ib. */ virtual Type tminimum(const InterfacedBase & ib, int i) const = 0; /** * Return the maximum value allowed for the \a i'th element of a * container of member variables of \a ib. Calls tmaximum(const * InterfacedBase &, int) and converts the returned value with an * ostringstream. */ virtual string maximum(const InterfacedBase & ib, int i) const ; /** * Return the maximum value allowed for the \a i'th element of a * container of member variables of \a ib. */ virtual Type tmaximum(const InterfacedBase & ib, int i) const = 0; /** * Return the default value for the \a i'th element of a container * of member variables of \a ib. Calls tdef(const InterfacedBase &, * int) and converts the returned value with an ostringstream. */ virtual string def(const InterfacedBase & ib, int i) const ; /** * Return the default value for the \a i'th element of a container of * member variables of \a ib. */ virtual Type tdef(const InterfacedBase & ib, int i) const = 0; /** - * Return the general default value for this parameter vector. Calls + * Return the general default value for this parameter map. Calls * tdef() and converts the returned value with an ostringstream. */ virtual string def() const; /** - * Return the general default value for this parameter vector. + * Return the general default value for this parameter map. */ virtual Type tdef() const = 0; /** * set the \a i'th element of a container of member variables of \a ib to * its default value. */ virtual void setDef(InterfacedBase & ib, int i) const ; /** * Get the unit which an Type object is divided (multiplied) by when * written to (read from) a stream via a double. If unit() is zero, * the Type object is written/read directly. */ Type unit() const { return theUnit; } /** * Set the unit which an Type object is divided (multiplied) by when * written to (read from) a stream via a double. If unit() is zero, * the Type object is written/read directly. */ void unit(Type u) { theUnit = u; } protected: /** * Write a numer to a stream with the unit specified with unit(). */ void putUnit(ostream & os, Type val) const { putUnitImpl2(os, val, unit(), typename TypeTraits::DimType()); } private: /** * The unit which an Type object is divided (multiplied) by * when written to (read from) a stream via a double. If unit() is * zero, the Type object is written/read directly. */ Type theUnit; }; /** - * The ParVector and its base classes ParVectorTBase and ParVectorBase + * The ParMap and its base classes ParMapTBase and ParMapBase * defines an interface to a class derived from the InterfacedBase, - * through which vectors (or any other container) of simple member - * variables can be manuipulated. ParVector is templated on the type + * through which maps (or any other container) of simple member + * variables can be manuipulated. ParMap is templated on the type * of the member variable and the type of the InterfacedBase class, * and is derived from the InterfaceBase class via - * ParVectorTBase (which is templated only on the class - * of the member variable) and ParVectorBase. + * ParMapTBase (which is templated only on the class + * of the member variable) and ParMapBase. * - * For each InterfacedBase class exactly one static ParVector object + * For each InterfacedBase class exactly one static ParMap object * should created for each member variable of container type which * should be interfaced. This object will automatically register * itself with the BaseRepository class. * * @see Parameter * @see InterfacedBase * @see InterfaceBase * */ template -class ParVector: public ParVectorTBase { +class ParMap: public ParMapTBase { public: /** * The declaration of member functions which can be used by this - * ParVector interface for 'set' actions. + * ParMap interface for 'set' actions. */ typedef void (T::*SetFn)(Type, int); /** * The declaration of member functions which can be used by this - * ParVector interface for 'insert' actions. + * ParMap interface for 'insert' actions. */ typedef void (T::*InsFn)(Type, int); /** * The declaration of member functions which can be used by this - * ParVector interface for 'erase' actions. + * ParMap interface for 'erase' actions. */ typedef void (T::*DelFn)(int); /** - * A vector of objects of the template parameter Type. + * A map of objects of the template parameter Type. */ - typedef vector TypeVector; + typedef map TypeMap; /** * The declaration of member functions which can be used by this - * ParVector interface for 'get' actions. + * ParMap interface for 'get' actions. */ - typedef TypeVector (T::*GetFn)() const; + typedef TypeMap (T::*GetFn)() const; /** - * A vector of strings. + * A map of strings. */ - typedef vector StringVector; + typedef map StringMap; /** * The declaration of member functions which can be used by this - * ParVector interface for 'get' actions. + * ParMap interface for 'get' actions. */ - typedef StringVector (T::*StringGetFn)() const; + typedef StringMap (T::*StringGetFn)() const; /** * The declaration of member functions which can be used by this - * ParVector interface for 'erase' actions. + * ParMap interface for 'erase' actions. */ typedef Type (T::*DefFn)(int) const; /** * Declaration of a direct pointer to the member variable in case it - * is a vector. + * is a map. */ - typedef TypeVector T::* Member; + typedef TypeMap T::* Member; public: /** * Standard constructor. * * @param newName the name of the interface, may only contain * letters [a-zA-z0-9_]. * * @param newDescription a brief description of the interface. * - * @param newMember a pointer to a Member which is a TypeVector. May + * @param newMember a pointer to a Member which is a TypeMap. May * be null, in which case the pointers to member functions must be * specified. * * @param newSize the size of the container or -1 if varying. * * @param newDef the default value of the corresponding parameters. * * @param newMin the minimum value of the corresponding parameters. * * @param newMax the maximum value of the corresponding parameters. * * @param depSafe set to true if calls to this interface for one * object does not influence other objects. * * @param readonly if this is set true the interface will not be * able to manipulate objects of the corresponding class, but will * still be able to access information. * * @param limits determines if the values of the parameters are * limited from above and below. * * @param newSetFn optional pointer to member function for the 'set' * action. * * @param newInsFn optional pointer to member function for the * 'insert' action. * * @param newDelFn optional pointer to member function for the * 'erase' action. * * @param newDefFn optional pointer to member function for the * 'default' action. * * @param newGetFn optional pointer to member function for the * 'get' action. * * @param newMinFn optional pointer to member function for the * 'minimum' action. * * @param newMaxFn optional pointer to member function for the * 'maximum' action. * * @param newStringGetFn optional pointer to member function for the * 'get' action. */ - ParVector(string newName, string newDescription, + ParMap(string newName, string newDescription, Member newMember, int newSize, Type newDef, Type newMin, Type newMax, bool depSafe = false, bool readonly = false, bool limits = true, SetFn newSetFn = 0, InsFn newInsFn = 0, DelFn newDelFn = 0, GetFn newGetFn = 0, DefFn newDefFn = 0, DefFn newMinFn = 0, DefFn newMaxFn = 0, StringGetFn newStringGetFn = 0) - : ParVectorTBase(newName, newDescription, ClassTraits::className(), + : ParMapTBase(newName, newDescription, ClassTraits::className(), typeid(T), Type(), newSize, depSafe, readonly, limits), theMember(newMember), theDef(newDef), theMin(newMin), theMax(newMax), theSetFn(newSetFn), theInsFn(newInsFn), theDelFn(newDelFn), theGetFn(newGetFn), theDefFn(newDefFn), theMinFn(newMinFn), theMaxFn(newMaxFn), theStringGetFn(newStringGetFn) {} /** * Standard constructor. * * @param newName the name of the interface, may only contain * letters [a-zA-z0-9_]. * * @param newDescription a brief description of the interface. * - * @param newMember a pointer to a Member which is a TypeVector. May + * @param newMember a pointer to a Member which is a TypeMap. May * be null, in which case the pointers to member functions must be * specified. * * @param newUnit the unit assumed when a number is read or written * to a stream. * * @param newSize the size of the container or -1 if varying. * * @param newDef the default value of the corresponding parameters. * * @param newGetFn optional pointer to member function for the * 'get' action. * * @param newMin the minimum value of the corresponding parameters. * * @param newMax the maximum value of the corresponding parameters. * * @param depSafe set to true if calls to this interface for one * object does not influence other objects. * * @param readonly if this is set true the interface will not be * able to manipulate objects of the corresponding class, but will * still be able to access information. * * @param limits determines if the values of the parameters are * limited from above and below. * * @param newSetFn optional pointer to member function for the 'set' * action. * * @param newInsFn optional pointer to member function for the * 'insert' action. * * @param newDelFn optional pointer to member function for the * 'erase' action. * * @param newDefFn optional pointer to member function for the * 'default' action. * * @param newMinFn optional pointer to member function for the * 'minimum' action. * * @param newMaxFn optional pointer to member function for the * 'maximum' action. * * @param newStringGetFn optional pointer to member function for the * 'get' action. */ - ParVector(string newName, string newDescription, Member newMember, + ParMap(string newName, string newDescription, Member newMember, Type newUnit, int newSize, Type newDef, Type newMin, Type newMax, bool depSafe = false, bool readonly = false, bool limits = true, SetFn newSetFn = 0, InsFn newInsFn = 0, DelFn newDelFn = 0, GetFn newGetFn = 0, DefFn newDefFn = 0, DefFn newMinFn = 0, DefFn newMaxFn = 0, StringGetFn newStringGetFn = 0) - : ParVectorTBase(newName, newDescription, ClassTraits::className(), + : ParMapTBase(newName, newDescription, ClassTraits::className(), typeid(T), newUnit, newSize, depSafe, readonly, limits), theMember(newMember), theDef(newDef), theMin(newMin), theMax(newMax), theSetFn(newSetFn), theInsFn(newInsFn), theDelFn(newDelFn), theGetFn(newGetFn), theDefFn(newDefFn), theMinFn(newMinFn), theMaxFn(newMaxFn), theStringGetFn(newStringGetFn) {} /** * Standard constructor. * * @param newName the name of the interface, may only contain * letters [a-zA-z0-9_]. * * @param newDescription a brief description of the interface. * - * @param newMember a pointer to a Member which is a TypeVector. May + * @param newMember a pointer to a Member which is a TypeMap. May * be null, in which case the pointers to member functions must be * specified. * * @param newSize the size of the container or -1 if varying. * * @param newDef the default value of the corresponding parameters. * * @param newMin the minimum value of the corresponding parameters. * * @param newMax the maximum value of the corresponding parameters. * * @param depSafe set to true if calls to this interface for one * object does not influence other objects. * * @param readonly if this is set true the interface will not be * able to manipulate objects of the corresponding class, but will * still be able to access information. * * @param limits determines if the values of the parameters are * limited from above and/or below. The possible values are given by * Interface::Limits. * * @param newSetFn optional pointer to member function for the 'set' * action. * * @param newInsFn optional pointer to member function for the * 'insert' action. * * @param newDelFn optional pointer to member function for the * 'erase' action. * * @param newDefFn optional pointer to member function for the * 'default' action. * * @param newGetFn optional pointer to member function for the * 'get' action. * * @param newMinFn optional pointer to member function for the * 'minimum' action. * * @param newMaxFn optional pointer to member function for the * 'maximum' action. * * @param newStringGetFn optional pointer to member function for the * 'get' action. */ - ParVector(string newName, string newDescription, + ParMap(string newName, string newDescription, Member newMember, int newSize, Type newDef, Type newMin, Type newMax, bool depSafe = false, bool readonly = false, int limits = Interface::limited, SetFn newSetFn = 0, InsFn newInsFn = 0, DelFn newDelFn = 0, GetFn newGetFn = 0, DefFn newDefFn = 0, DefFn newMinFn = 0, DefFn newMaxFn = 0, StringGetFn newStringGetFn = 0) - : ParVectorTBase(newName, newDescription, ClassTraits::className(), + : ParMapTBase(newName, newDescription, ClassTraits::className(), typeid(T), Type(), newSize, depSafe, readonly, limits), theMember(newMember), theDef(newDef), theMin(newMin), theMax(newMax), theSetFn(newSetFn), theInsFn(newInsFn), theDelFn(newDelFn), theGetFn(newGetFn), theDefFn(newDefFn), theMinFn(newMinFn), theMaxFn(newMaxFn), theStringGetFn(newStringGetFn) {} /** * Standard constructor. * * @param newName the name of the interface, may only contain * letters [a-zA-z0-9_]. * * @param newDescription a brief description of the interface. * - * @param newMember a pointer to a Member which is a TypeVector. May + * @param newMember a pointer to a Member which is a TypeMap. May * be null, in which case the pointers to member functions must be * specified. * * @param newUnit the unit assumed when a number is read or written * to a stream. * * @param newSize the size of the container or -1 if varying. * * @param newDef the default value of the corresponding parameters. * * @param newGetFn optional pointer to member function for the * 'get' action. * * @param newMin the minimum value of the corresponding parameters. * * @param newMax the maximum value of the corresponding parameters. * * @param depSafe set to true if calls to this interface for one * object does not influence other objects. * * @param readonly if this is set true the interface will not be * able to manipulate objects of the corresponding class, but will * still be able to access information. * * @param limits determines if the values of the parameters are * limited from above and/or below. The possible values are given by * Interface::Limits. * * @param newSetFn optional pointer to member function for the 'set' * action. * * @param newInsFn optional pointer to member function for the * 'insert' action. * * @param newDelFn optional pointer to member function for the * 'erase' action. * * @param newDefFn optional pointer to member function for the * 'default' action. * * @param newMinFn optional pointer to member function for the * 'minimum' action. * * @param newMaxFn optional pointer to member function for the * 'maximum' action. * * @param newStringGetFn optional pointer to member function for the * 'get' action. */ - ParVector(string newName, string newDescription, Member newMember, + ParMap(string newName, string newDescription, Member newMember, Type newUnit, int newSize, Type newDef, Type newMin, Type newMax, bool depSafe = false, bool readonly = false, int limits = Interface::limited, SetFn newSetFn = 0, InsFn newInsFn = 0, DelFn newDelFn = 0, GetFn newGetFn = 0, DefFn newDefFn = 0, DefFn newMinFn = 0, DefFn newMaxFn = 0, StringGetFn newStringGetFn = 0) - : ParVectorTBase(newName, newDescription, ClassTraits::className(), + : ParMapTBase(newName, newDescription, ClassTraits::className(), typeid(T), newUnit, newSize, depSafe, readonly, limits), theMember(newMember), theDef(newDef), theMin(newMin), theMax(newMax), theSetFn(newSetFn), theInsFn(newInsFn), theDelFn(newDelFn), theGetFn(newGetFn), theDefFn(newDefFn), theMinFn(newMinFn), theMaxFn(newMaxFn), theStringGetFn(newStringGetFn) {} /** * Set the \a i'th element of a container of member variables of \a * ib to \a val. */ virtual void tset(InterfacedBase & ib, Type val, int i) const ; /** * Insert a new object before the \a i'th element of a container of * member variables of \a ib and set it to \a val. */ virtual void tinsert(InterfacedBase & ib, Type val, int i) const ; /** * Remove the \a i'th element of a container of * member variables of \a ib. */ virtual void erase(InterfacedBase & ib, int i) const; /** * Clear the container of pointers of \a ib. */ virtual void clear(InterfacedBase & ib) const; /** * Return the values of a container of member variables of \a ib in - * a vector of strings. Calls the The tget(const InterfacedBase &) - * and returns a vector of strings converted with ostringstreams. + * a map of strings. Calls the The tget(const InterfacedBase &) + * and returns a map of strings converted with ostringstreams. */ - virtual StringVector get(const InterfacedBase & ib) const + virtual StringMap get(const InterfacedBase & ib) const ; /** * Return the values of a container of member variables of \a ib in a - * vector of Type. + * map of Type. */ - virtual TypeVector tget(const InterfacedBase & ib) const + virtual TypeMap tget(const InterfacedBase & ib) const ; /** * Return the minimum value allowed for the \a i'th element of a * container of member variables of \a ib. */ virtual Type tminimum(const InterfacedBase & ib, int i) const ; /** * Return the maximum value allowed for the \a i'th element of a * container of member variables of \a ib. */ virtual Type tmaximum(const InterfacedBase & ib, int i) const ; /** * Return the default value for the \a i'th element of a container of * member variables of \a ib. */ virtual Type tdef(const InterfacedBase &, int) const ; /** - * Return the general default value for this parameter vector. + * Return the general default value for this parameter map. */ virtual Type tdef() const; /** * Give a pointer to a member function to be used by tset(). */ void setSetFunction(SetFn sf) { theSetFn = sf; } /** * Give a pointer to a member function to be used by tinsert(). */ void setInsertFunction(InsFn ifn) { theInsFn = ifn; } /** * Give a pointer to a member function to be used by tget(). */ void setGetFunction(GetFn gf) { theGetFn = gf; } /** * Give a pointer to a member function to be used by terase(). */ void setEraseFunction(DelFn df) { theDelFn = df; } /** * Give a pointer to a member function to be used by tdef(). */ void setDefaultFunction(GetFn df) { theDefFn = df; } /** * Give a pointer to a member function to be used by tminimum(). */ void setMinFunction(GetFn mf) { theMinFn = mf; } /** * Give a pointer to a member function to be used by tmaximum(). */ void setMaxFunction(GetFn mf) { theMaxFn = mf; } /** * Give a pointer to a member function to be used by get(). */ void setStringGetFunction(StringGetFn gf) { theStringGetFn = gf; } /** * Print a description to be included in the Doxygen documentation * to the given \a stream. */ virtual void doxygenDescription(ostream & stream) const; private: /** * The pointer to the member variable. */ Member theMember; /** * Default value to be used if no corresponding member function * pointer is given. */ Type theDef; /** * Minimum value to be used if no corresponding member function * pointer is given. */ Type theMin; /** * Maximum value to be used if no * corresponding member function pointer is given. */ Type theMax; /** * A pointer to a member function to be used by tset(). */ SetFn theSetFn; /** * A pointer to a member function to be used by tinsert(). */ InsFn theInsFn; /** * A pointer to a member function to be used by terase(). */ DelFn theDelFn; /** * A pointer to a member function to be used by tget(). */ GetFn theGetFn; /** * Pointer to member function to be used by tdef(). */ DefFn theDefFn; /** * Pointer to member function to be used by tminimum(). */ DefFn theMinFn; /** * Pointer to member function to be used by tmaximum(). */ DefFn theMaxFn; /** * A pointer to a member function to be used by set(). */ StringGetFn theStringGetFn; }; } #ifndef ThePEG_TEMPLATES_IN_CC_FILE -#include "ParVector.tcc" +#include "ParMap.tcc" #endif -#endif /* ThePEG_ParVector_H */ +#endif /* ThePEG_ParMap_H */ diff --git a/Interface/ParVector.tcc b/Interface/ParMap.tcc copy from Interface/ParVector.tcc copy to Interface/ParMap.tcc --- a/Interface/ParVector.tcc +++ b/Interface/ParMap.tcc @@ -1,384 +1,378 @@ // -*- C++ -*- // -// ParVector.tcc is a part of ThePEG - Toolkit for HEP Event Generation +// ParMap.tcc is a part of ThePEG - Toolkit for HEP Event Generation // Copyright (C) 1999-2019 Leif Lonnblad // // ThePEG is licenced under version 3 of the GPL, see COPYING for details. // Please respect the MCnet academic guidelines, see GUIDELINES for details. // // // This is the implementation of the non-inlined templated member -// functions of the ParVector and ParVectorTBase classes. +// functions of the ParMap and ParMapTBase classes. // -#include "ParVector.xh" +#include "ParMap.xh" namespace ThePEG { template -string ParVectorTBase::type() const { +string ParMapTBase::type() const { if ( std::numeric_limits::is_integer ) return "Vi"; if ( typeid(Type) == typeid(string) ) return "Vs"; return "Vf"; } template -string ParVectorTBase::doxygenType() const { +string ParMapTBase::doxygenType() const { ostringstream os; if ( size() <= 0 ) os << "Varying size "; else os << "Fixed size (" << size() << ") "; - os << "vector of "; + os << "map of "; string lim = ""; if ( !limited() ) lim = " unlimited"; if ( std::numeric_limits::is_integer ) os << lim << "integer "; else if ( typeid(Type) == typeid(string) ) os << "string "; else os << lim; os << "parameters"; return os.str(); } template -string ParVectorTBase::fullDescription(const InterfacedBase & ib) const { - return ParVectorBase::fullDescription(ib) + def() + "\n"; +string ParMapTBase::fullDescription(const InterfacedBase & ib) const { + return ParMapBase::fullDescription(ib) + def() + "\n"; } template -void ParVectorTBase::setDef(InterfacedBase & i, int place) const +void ParMapTBase::setDef(InterfacedBase & i, int place) const { if ( place >= 0 ) tset(i, tdef(i, place), place); int sz = get(i).size(); for ( int j = 0; j < sz; ++j ) tset(i, tdef(i, j), j); } template -inline void ParVectorTBase:: +inline void ParMapTBase:: setImpl(InterfacedBase & i, string newValue, int place, StandardT) const { istringstream is(newValue); if ( unit() > Type() ) { double t; is >> t; tset(i, Type(t*unit()), place); } else { Type t = Type(); is >> t; tset(i, t, place); } } template<> -inline void ParVectorTBase:: +inline void ParMapTBase:: setImpl(InterfacedBase & i, string newValue, int place, StandardT) const { istringstream is(newValue); bool t; is >> t; tset(i, t, place); } template -inline void ParVectorTBase:: +inline void ParMapTBase:: setImpl(InterfacedBase & i, string newValue, int place, DimensionT) const { istringstream is(newValue); double t; is >> t; tset(i, t*unit(), place); } template -void ParVectorTBase:: +void ParMapTBase:: set(InterfacedBase & i, string newValue, int place) const { setImpl(i, newValue, place, typename TypeTraits::DimType()); } template -inline void ParVectorTBase:: +inline void ParMapTBase:: insertImpl(InterfacedBase & i, string newValue, int place, StandardT) const { istringstream is(newValue); if ( unit() > Type() ) { double t; is >> t; tinsert(i, Type(t*unit()), place); } else { Type t = Type(); is >> t; tinsert(i, t, place); } } template <> -inline void ParVectorTBase:: +inline void ParMapTBase:: insertImpl(InterfacedBase & i, string newValue, int place, StandardT) const { istringstream is(newValue); bool t; is >> t; tinsert(i, t, place); } template -inline void ParVectorTBase:: +inline void ParMapTBase:: insertImpl(InterfacedBase & i, string newValue, int place, DimensionT) const { istringstream is(newValue); double t; is >> t; tinsert(i, t*unit(), place); } template -void ParVectorTBase:: +void ParMapTBase:: insert(InterfacedBase & i, string newValue, int place) const { insertImpl(i, newValue, place, typename TypeTraits::DimType()); } template -typename ParVectorTBase::StringVector ParVectorTBase:: +typename ParMapTBase::StringMap ParMapTBase:: get(const InterfacedBase & i) const { - TypeVector tres = tget(i); - StringVector res; - for ( typename TypeVector::iterator it = tres.begin(); + TypeMap tres = tget(i); + StringMap res; + for ( typename TypeMap::iterator it = tres.begin(); it != tres.end(); ++it ) { ostringstream os; - putUnit(os, *it); - res.push_back(os.str()); + putUnit(os, it->second); + res.insert(make_pair(it->first,os.str())); } return res; } template -string ParVectorTBase:: +string ParMapTBase:: minimum(const InterfacedBase & i, int place) const { ostringstream os; putUnit(os, tminimum(i,place)); return os.str(); } template -string ParVectorTBase:: +string ParMapTBase:: maximum(const InterfacedBase & i, int place) const { ostringstream os; putUnit(os, tmaximum(i, place)); return os.str(); } template -string ParVectorTBase:: +string ParMapTBase:: def(const InterfacedBase & i, int place) const { ostringstream os; putUnit(os, tdef(i,place)); return os.str(); } template -string ParVectorTBase::def() const { +string ParMapTBase::def() const { ostringstream os; putUnit(os, tdef()); return os.str(); } template -Type ParVector::tdef() const { +Type ParMap::tdef() const { return theDef; } template -void ParVector::tset(InterfacedBase & i, Type newValue, int place) const +void ParMap::tset(InterfacedBase & i, Type newValue, int place) const { if ( InterfaceBase::readOnly() ) throw InterExReadOnly(*this, i); T * t = dynamic_cast(&i); if ( !t ) throw InterExClass(*this, i); - if ( ( ParVectorBase::lowerLimit() && newValue < tminimum(*t, place) ) || - ( ParVectorBase::upperLimit() && newValue > tmaximum(*t, place) ) ) - throw ParVExLimit(*this, i, newValue); - TypeVector oldVector = tget(i); + if ( ( ParMapBase::lowerLimit() && newValue < tminimum(*t, place) ) || + ( ParMapBase::upperLimit() && newValue > tmaximum(*t, place) ) ) + throw ParMExLimit(*this, i, newValue); + TypeMap oldMap = tget(i); if ( theSetFn ) { try { (t->*theSetFn)(newValue, place); } catch (InterfaceException & e) { throw e; } - catch ( ... ) { throw ParVExUnknown(*this, i, newValue, place, "set"); } + catch ( ... ) { throw ParMExUnknown(*this, i, newValue, place, "set"); } } else { if ( !theMember ) throw InterExSetup(*this, i); - if ( place < 0 || unsigned(place) >= (t->*theMember).size() ) - throw ParVExIndex(*this, i, place); (t->*theMember)[place] = newValue; } - if ( !InterfaceBase::dependencySafe() && oldVector != tget(i) ) i.touch(); + if ( !InterfaceBase::dependencySafe() && oldMap != tget(i) ) i.touch(); } template -void ParVector:: +void ParMap:: tinsert(InterfacedBase & i, Type newValue, int place) const { if ( InterfaceBase::readOnly() ) throw InterExReadOnly(*this, i); - if ( ParVectorBase::size() > 0 ) throw ParVExFixed(*this, i); + if ( ParMapBase::size() > 0 ) throw ParMExFixed(*this, i); T * t = dynamic_cast(&i); if ( !t ) throw InterExClass(*this, i); - if ( ( ParVectorBase::lowerLimit() && newValue < tminimum(*t, place) ) || - ( ParVectorBase::upperLimit() && newValue > tmaximum(*t, place) ) ) - throw ParVExLimit(*this, i, newValue); - TypeVector oldVector = tget(i); + if ( ( ParMapBase::lowerLimit() && newValue < tminimum(*t, place) ) || + ( ParMapBase::upperLimit() && newValue > tmaximum(*t, place) ) ) + throw ParMExLimit(*this, i, newValue); + TypeMap oldMap = tget(i); if ( theInsFn ) { try { (t->*theInsFn)(newValue, place); } catch (InterfaceException & e) { throw e; } - catch ( ... ) { throw ParVExUnknown(*this, i, newValue, place, "insert"); } + catch ( ... ) { throw ParMExUnknown(*this, i, newValue, place, "insert"); } } else { if ( !theMember ) throw InterExSetup(*this, i); - if ( place < 0 || unsigned(place) > (t->*theMember).size() ) - throw ParVExIndex(*this, i, place); - (t->*theMember).insert((t->*theMember).begin()+place, newValue); + (t->*theMember).insert(make_pair(place, newValue)); } - if ( !InterfaceBase::dependencySafe() && oldVector != tget(i) ) i.touch(); + if ( !InterfaceBase::dependencySafe() && oldMap != tget(i) ) i.touch(); } template -void ParVector:: +void ParMap:: erase(InterfacedBase & i, int place) const { if ( InterfaceBase::readOnly() ) throw InterExReadOnly(*this, i); - if ( ParVectorBase::size() > 0 ) throw ParVExFixed(*this, i); + if ( ParMapBase::size() > 0 ) throw ParMExFixed(*this, i); T * t = dynamic_cast(&i); if ( !t ) throw InterExClass(*this, i); - TypeVector oldVector = tget(i); + TypeMap oldMap = tget(i); if ( theDelFn ) { try { (t->*theDelFn)(place); } catch (InterfaceException & e) { throw e; } - catch ( ... ) { throw ParVExDelUnknown(*this, i, place); } + catch ( ... ) { throw ParMExDelUnknown(*this, i, place); } } else { if ( !theMember ) throw InterExSetup(*this, i); - if ( place < 0 || unsigned(place) >= (t->*theMember).size() ) - throw ParVExIndex(*this, i, place); - (t->*theMember).erase((t->*theMember).begin()+place); + (t->*theMember).erase(place); } - if ( !InterfaceBase::dependencySafe() && oldVector != tget(i) ) i.touch(); + if ( !InterfaceBase::dependencySafe() && oldMap != tget(i) ) i.touch(); } template -void ParVector::clear(InterfacedBase & i) const +void ParMap::clear(InterfacedBase & i) const { - if ( ParVectorBase::readOnly() ) throw InterExReadOnly(*this, i); - if ( ParVectorBase::size() > 0 ) throw ParVExFixed(*this, i); + if ( ParMapBase::readOnly() ) throw InterExReadOnly(*this, i); + if ( ParMapBase::size() > 0 ) throw ParMExFixed(*this, i); T * t = dynamic_cast(&i); if ( !t ) throw InterExClass(*this, i); (t->*theMember).clear(); if ( !InterfaceBase::dependencySafe() ) i.touch(); } template -typename ParVector::TypeVector ParVector:: +typename ParMap::TypeMap ParMap:: tget(const InterfacedBase & i) const { const T * t = dynamic_cast(&i); if ( !t ) throw InterExClass(*this, i); if ( theGetFn ) { try { return (t->*theGetFn)(); } catch (InterfaceException & e) { throw e; } - catch ( ... ) { throw ParVExGetUnknown(*this, i, "current"); } + catch ( ... ) { throw ParMExGetUnknown(*this, i, "current"); } } if ( theMember ) return t->*theMember; throw InterExSetup(*this, i); } template -typename ParVector::StringVector ParVector:: +typename ParMap::StringMap ParMap:: get(const InterfacedBase & i) const { - if ( !theStringGetFn ) return ParVectorTBase::get(i); + if ( !theStringGetFn ) return ParMapTBase::get(i); const T * t = dynamic_cast(&i); if ( !t ) throw InterExClass(*this, i); try { return (t->*theStringGetFn)(); } catch (InterfaceException & e) { throw e; } - catch ( ... ) { throw ParVExGetUnknown(*this, i, "current"); } + catch ( ... ) { throw ParMExGetUnknown(*this, i, "current"); } } template -Type ParVector::tdef(const InterfacedBase & i, int place) const +Type ParMap::tdef(const InterfacedBase & i, int place) const { - if ( place < 0 || !theDefFn ) return theMin; + if ( !theDefFn ) return theMin; const T * t = dynamic_cast(&i); if ( !t ) throw InterExClass(*this, i); try { return (t->*theDefFn)(place); } catch (InterfaceException & e) { throw e; } - catch ( ... ) { throw ParVExGetUnknown(*this, i, "default"); } + catch ( ... ) { throw ParMExGetUnknown(*this, i, "default"); } } template -Type ParVector::tminimum(const InterfacedBase & i, int place) const +Type ParMap::tminimum(const InterfacedBase & i, int place) const { - if ( place < 0 || !theMinFn ) return theMin; + if ( !theMinFn ) return theMin; const T * t = dynamic_cast(&i); if ( !t ) throw InterExClass(*this, i); try { return (t->*theMinFn)(place); } catch (InterfaceException & e) { throw e; } - catch ( ... ) { throw ParVExGetUnknown(*this, i, "minimum"); } + catch ( ... ) { throw ParMExGetUnknown(*this, i, "minimum"); } } template -Type ParVector::tmaximum(const InterfacedBase & i, int place) const +Type ParMap::tmaximum(const InterfacedBase & i, int place) const { - if ( place < 0 || !theMaxFn ) return theMax; + if ( !theMaxFn ) return theMax; const T * t = dynamic_cast(&i); if ( !t ) throw InterExClass(*this, i); try { return (t->*theMaxFn)(place); } catch (InterfaceException & e) { throw e; } - catch ( ... ) { throw ParVExGetUnknown(*this, i, "maximum"); } + catch ( ... ) { throw ParMExGetUnknown(*this, i, "maximum"); } } template -void ParVector::doxygenDescription(ostream & os) const { - ParVectorTBase::doxygenDescription(os); +void ParMap::doxygenDescription(ostream & os) const { + ParMapTBase::doxygenDescription(os); os << "Default value: "; this->putUnit(os, theDef); if ( theDefFn ) os << " (May be changed by member function.)"; - if ( ParVectorBase::lowerLimit() ) { + if ( ParMapBase::lowerLimit() ) { os << "
\nMinimum value: "; this->putUnit(os, theMin); if ( theMinFn ) os << " (May be changed by member function.)"; } - if ( ParVectorBase::upperLimit() ) { + if ( ParMapBase::upperLimit() ) { os << "
\nMaximum value: "; this->putUnit(os, theMax); if ( theMaxFn ) os << " (May be changed by member function.)"; } os << "
\n"; } namespace { template inline void ostreamInsert2(ostream & os, T v, DimensionT) { os << ounit(v, T::baseunit()); } template inline void ostreamInsert2(ostream & os, T v, StandardT) { os << v; } } template -ParVExLimit::ParVExLimit(const InterfaceBase & i, +ParMExLimit::ParMExLimit(const InterfaceBase & i, const InterfacedBase & o, T v) { theMessage << "Could not set/insert "; ostreamInsert2(theMessage,v,typename TypeTraits::DimType() ); - theMessage << " in the parameter vector \"" + theMessage << " in the parameter map \"" << i.name() << "\" for the object \"" << o.name() << "\" because the value is outside the specified limits."; severity(setuperror); } template -ParVExUnknown::ParVExUnknown(const InterfaceBase & i, const InterfacedBase & o, +ParMExUnknown::ParMExUnknown(const InterfaceBase & i, const InterfacedBase & o, T v, int j, const char * s) { theMessage << "Could not " << s << " the value "; ostreamInsert2(theMessage,v,typename TypeTraits::DimType() ); theMessage << " at position " - << j << " in the parameter vector \"" << i.name() + << j << " in the parameter map \"" << i.name() << "\" for the object \"" << o.name() << "\" because the " << s << " function threw an unknown exception."; severity(setuperror); } } diff --git a/Interface/ParVector.xh b/Interface/ParMap.xh copy from Interface/ParVector.xh copy to Interface/ParMap.xh --- a/Interface/ParVector.xh +++ b/Interface/ParMap.xh @@ -1,68 +1,68 @@ // -*- C++ -*- // -// ParVector.xh is a part of ThePEG - Toolkit for HEP Event Generation +// ParMap.xh is a part of ThePEG - Toolkit for HEP Event Generation // Copyright (C) 1999-2019 Leif Lonnblad // // ThePEG is licenced under version 3 of the GPL, see COPYING for details. // Please respect the MCnet academic guidelines, see GUIDELINES for details. // -#ifndef ThePEG_ParVector_XH -#define ThePEG_ParVector_XH +#ifndef ThePEG_ParMap_XH +#define ThePEG_ParMap_XH // // This is the declarations of the exception classes used by the -// ParVector class. +// ParMap class. // #include "InterfaceBase.xh" namespace ThePEG { /** @cond EXCEPTIONCLASSES */ -/** Exception class used by ParVector if a value is set outside the +/** Exception class used by ParMap if a value is set outside the * given limits. */ -struct ParVExLimit: public InterfaceException { +struct ParMExLimit: public InterfaceException { /** Standard constructor. */ template - ParVExLimit(const InterfaceBase & i, const InterfacedBase & o, T v); + ParMExLimit(const InterfaceBase & i, const InterfacedBase & o, T v); }; -/** Exception class used by ParVector if an unknown error was encountered. */ -struct ParVExUnknown: public InterfaceException { +/** Exception class used by ParMap if an unknown error was encountered. */ +struct ParMExUnknown: public InterfaceException { /** Standard constructor. */ template - ParVExUnknown(const InterfaceBase & i, const InterfacedBase & o, + ParMExUnknown(const InterfaceBase & i, const InterfacedBase & o, T v, int j, const char * s); }; -/** Exception class used by ParVector if an index is outside the given +/** Exception class used by ParMap if an index is outside the given * limits. */ -struct ParVExIndex: public InterfaceException { +struct ParMExIndex: public InterfaceException { /** Standard constructor. */ - ParVExIndex(const InterfaceBase & i, const InterfacedBase & o, int index); + ParMExIndex(const InterfaceBase & i, const InterfacedBase & o, int index); }; -/** Exception class used by ParVector if the size of a fixed-size +/** Exception class used by ParMap if the size of a fixed-size * container is changed. */ -struct ParVExFixed: public InterfaceException { +struct ParMExFixed: public InterfaceException { /** Standard constructor. */ - ParVExFixed(const InterfaceBase & i, const InterfacedBase & o); + ParMExFixed(const InterfaceBase & i, const InterfacedBase & o); }; -/** Exception class used by ParVector if an unknown error was encountered. */ -struct ParVExDelUnknown: public InterfaceException { +/** Exception class used by ParMap if an unknown error was encountered. */ +struct ParMExDelUnknown: public InterfaceException { /** Standard constructor. */ - ParVExDelUnknown(const InterfaceBase & i, const InterfacedBase & o, int j); + ParMExDelUnknown(const InterfaceBase & i, const InterfacedBase & o, int j); }; -/** Exception class used by ParVector if an unknown error was encountered. */ -struct ParVExGetUnknown: public InterfaceException { +/** Exception class used by ParMap if an unknown error was encountered. */ +struct ParMExGetUnknown: public InterfaceException { /** Standard constructor. */ - ParVExGetUnknown(const InterfaceBase & i, + ParMExGetUnknown(const InterfaceBase & i, const InterfacedBase & o, const char * s); }; /** @endcond */ } -#endif /* ThePEG_ParVector_XH */ +#endif /* ThePEG_ParMap_XH */