|
|
|||
File indexing completed on 2026-08-06 09:38:26
0001 // -*- C++ -*- 0002 // 0003 // ParVector.h is a part of ThePEG - Toolkit for HEP Event Generation 0004 // Copyright (C) 1999-2019 Leif Lonnblad 0005 // 0006 // ThePEG is licenced under version 3 of the GPL, see COPYING for details. 0007 // Please respect the MCnet academic guidelines, see GUIDELINES for details. 0008 // 0009 #ifndef ThePEG_ParVector_H 0010 #define ThePEG_ParVector_H 0011 // This is the declaration of the ParVector, ParVectorTBase and 0012 // ParVectorBase classes. 0013 0014 #include "ThePEG/Config/ThePEG.h" 0015 #include "InterfaceBase.h" 0016 #include "ParVector.fh" 0017 #include <limits> 0018 0019 namespace ThePEG { 0020 0021 /// Helper functions for putUnit 0022 namespace { 0023 template <typename T> 0024 /** 0025 * Helper function for putUnit 0026 */ 0027 inline void putUnitImpl2(ostream & os, T v, T u, DimensionT) { 0028 os << v/u; 0029 } 0030 0031 template <typename T> 0032 /** 0033 * Helper function for putUnit 0034 */ 0035 inline void putUnitImpl2(ostream & os, T v, T u, StandardT) { 0036 if ( u > T() ) 0037 os << v/u; 0038 else 0039 os << v; 0040 } 0041 } 0042 0043 /** 0044 * The ParVector and its base classes ParVectorTBase and ParVectorBase 0045 * defines an interface to a class derived from the InterfacedBase, 0046 * through which vectors (or any other container) of simple member 0047 * variables can be manuipulated. ParVector is templated on the type 0048 * of the member variable and the type of the InterfacedBase class, 0049 * and is derived from the InterfaceBase class via 0050 * ParVectorTBase (which is templated only on the class 0051 * of the member variable) and ParVectorBase. 0052 * 0053 * For each InterfacedBase class exactly one static ParVector object 0054 * should created for each member variable of container type which 0055 * should be interfaced. This object will automatically register 0056 * itself with the BaseRepository class. 0057 * 0058 * @see Parameter 0059 * @see InterfacedBase 0060 * @see InterfaceBase 0061 * 0062 */ 0063 class ParVectorBase: public InterfaceBase { 0064 0065 public: 0066 0067 /** A vector of strings. */ 0068 typedef vector<string> StringVector; 0069 0070 public: 0071 0072 /** 0073 * Standard constructor. 0074 * 0075 * @param newName the name of the interface, may only contain 0076 * letters [a-zA-z0-9_]. 0077 * 0078 * @param newDescription a brief description of the interface. 0079 * 0080 * @param newClassName the name of the corresponding class. 0081 * 0082 * @param newTypeInfo the type_info object of the corresponding 0083 * class. 0084 * 0085 * @param newSize the size of the container or -1 if varying. 0086 * 0087 * @param depSafe set to true if calls to this interface for one 0088 * object does not influence other objects. 0089 * 0090 * @param readonly if this is set true the interface will not be 0091 * able to manipulate objects of the corresponding class, but will 0092 * still be able to access information. 0093 * 0094 * @param limits determines if the values of the parameters are 0095 * limited from above and/or below. The possible values are given by 0096 * Interface::Limits. 0097 */ 0098 ParVectorBase(string newName, string newDescription, 0099 string newClassName, 0100 const type_info & newTypeInfo, int newSize, 0101 bool depSafe, bool readonly, int limits) 0102 : InterfaceBase(newName, newDescription, newClassName, 0103 newTypeInfo, depSafe, 0104 readonly), limit(limits), theSize(newSize) { 0105 hasDefault = false; 0106 } 0107 0108 /** 0109 * Destructor. 0110 */ 0111 virtual ~ParVectorBase() {} 0112 0113 /** 0114 * The general interface method overriding the one in 0115 * InterfaceBase. For this class, \a action can be any of "set", 0116 * "insert", "erase", "get", "min", "max", "def" and "setdef" and \a 0117 * argument should be a something which can be read into an integer 0118 * and into a variable through a stringstream with the standard '>>' 0119 * operator. 0120 */ 0121 virtual string exec(InterfacedBase &, string action, 0122 string arguments) const; 0123 0124 /** 0125 * Return a complete description of this parameter vector. 0126 */ 0127 virtual string fullDescription(const InterfacedBase & ib) const; 0128 0129 /** 0130 * Set the \a i'th element of a container of member variables of \a 0131 * ib to \a val. \a val should be able to be read into the 0132 * corresponding variable type through a stringstream with the 0133 * standard '>>' operator. 0134 */ 0135 virtual void set(InterfacedBase & ib, string val, int i) 0136 const = 0; 0137 0138 /** 0139 * Insert a new object before the \a i'th element of a container of 0140 * member variables of \a ib and set it to \a val. \a val should be 0141 * able to be read into the corresponding variable type through a 0142 * stringstream with the standard '>>' operator. 0143 */ 0144 virtual void insert(InterfacedBase & ib, string val, int i) 0145 const = 0; 0146 0147 /** 0148 * Remove the \a i'th element of a container of member variables of 0149 * \a ib. 0150 */ 0151 virtual void erase(InterfacedBase & ib, int i) 0152 const = 0; 0153 0154 /** 0155 * Clear the container of pointers of \a ib. 0156 */ 0157 virtual void clear(InterfacedBase & ib) 0158 const = 0; 0159 0160 /** 0161 * Return the values of a container of member variables of \a ib. 0162 */ 0163 virtual StringVector get(const InterfacedBase & ib) const 0164 = 0; 0165 0166 /** 0167 * Return the minimum value allowed for the \a i'th element of a 0168 * container of member variables of \a ib. 0169 */ 0170 virtual string minimum(const InterfacedBase & ib, int i) const 0171 = 0; 0172 0173 /** 0174 * Return the maximum value allowed for the \a i'th element of a 0175 * container of member variables of \a ib. 0176 */ 0177 virtual string maximum(const InterfacedBase & ib, int i) const 0178 = 0; 0179 0180 /** 0181 * Return the default value for the \a i'th element of a container 0182 * of member variables of \a ib. 0183 */ 0184 virtual string def(const InterfacedBase & ib, int i) const 0185 = 0; 0186 0187 /** 0188 * Return the general default value for this parameter vector. 0189 */ 0190 virtual string def() const = 0; 0191 0192 /** 0193 * Set the \a i'th element of a container of member variables of \a 0194 * ib to its default value. 0195 */ 0196 virtual void setDef(InterfacedBase & ib, int i) const 0197 = 0; 0198 0199 /** 0200 * True if there the variable is limited from above and below. 0201 */ 0202 bool limited() const { return limit != Interface::nolimits; } 0203 0204 /** 0205 * True if there the variable is limited from abovew. 0206 */ 0207 bool upperLimit() const { 0208 return limit == Interface::limited || limit == Interface::upperlim; 0209 } 0210 0211 /** 0212 * True if there the variable is limited from below. 0213 */ 0214 bool lowerLimit() const { 0215 return limit == Interface::limited || limit == Interface::lowerlim; 0216 } 0217 0218 /** 0219 * Set a flag indicating that there are limits associated with the 0220 * variables. 0221 */ 0222 void setLimited() { limit = Interface::limited; } 0223 0224 /** 0225 * Set a flag indicating if there are no limits associated with the 0226 * variables. 0227 */ 0228 void setUnlimited() { limit = Interface::nolimits; } 0229 0230 /** 0231 * Get the size of the container being interfaced. If the size() is 0232 * less than 0, the size is allowed to vary. 0233 */ 0234 int size() const { return theSize; } 0235 0236 /** 0237 * Set the size of the container being interfaced. If the size is 0238 * less than 0, the size is allowed to vary. 0239 */ 0240 void setSize(int sz) { theSize = sz; } 0241 0242 /** 0243 * Set the size of the container being interfaced to -1, i.e. the 0244 * size is allowed to vary. 0245 */ 0246 void setVariableSize() { theSize = 0; } 0247 0248 private: 0249 0250 /** 0251 * True if there are limits associated with the 0252 * variables. 0253 */ 0254 int limit; 0255 0256 /** 0257 * The size of the container being interfaced. 0258 */ 0259 int theSize; 0260 0261 }; 0262 0263 /** 0264 * The ParVector and its base classes ParVectorTBase and ParVectorBase 0265 * defines an interface to a class derived from the InterfacedBase, 0266 * through which vectors (or any other container) of simple member 0267 * variables can be manuipulated. ParVector is templated on the type 0268 * of the member variable and the type of the InterfacedBase class, 0269 * and is derived from the InterfaceBase class via 0270 * ParVectorTBase (which is templated only on the class 0271 * of the member variable) and ParVectorBase. 0272 * 0273 * For each InterfacedBase class exactly one static ParVector object 0274 * should created for each member variable of container type which 0275 * should be interfaced. This object will automatically register 0276 * itself with the BaseRepository class. 0277 * 0278 * @see Parameter 0279 * @see InterfacedBase 0280 * @see InterfaceBase 0281 * 0282 */ 0283 template <typename Type> 0284 class ParVectorTBase: public ParVectorBase { 0285 0286 public: 0287 0288 /** A vector of objects of the template argument type. */ 0289 typedef vector<Type> TypeVector; 0290 0291 public: 0292 0293 /** 0294 * Standard constructor. 0295 * 0296 * @param newName the name of the interface, may only contain 0297 * letters [a-zA-z0-9_]. 0298 * 0299 * @param newDescription a brief description of the interface. 0300 * 0301 * @param newClassName the name of the corresponding class. 0302 * 0303 * @param newTypeInfo the type_info object of the corresponding 0304 * class. 0305 * 0306 * @param newUnit the unit assumed when a number is read or written 0307 * to a stream. 0308 * 0309 * @param newSize the size of the container or -1 if varying. 0310 * 0311 * @param depSafe set to true if calls to this interface for one 0312 * object does not influence other objects. 0313 * 0314 * @param readonly if this is set true the interface will not be 0315 * able to manipulate objects of the corresponding class, but will 0316 * still be able to access information. 0317 * 0318 * @param limits determines if the values of the parameters are 0319 * limited from above and/or below. The possible values are given by 0320 * Interface::Limits. 0321 */ 0322 ParVectorTBase(string newName, string newDescription, 0323 string newClassName, const type_info & newTypeInfo, 0324 Type newUnit, int newSize, bool depSafe, 0325 bool readonly, int limits) 0326 : ParVectorBase(newName, newDescription, newClassName, 0327 newTypeInfo, newSize, 0328 depSafe, readonly, limits), theUnit(newUnit) {} 0329 0330 0331 /** 0332 * Destructor. 0333 */ 0334 virtual ~ParVectorTBase() {} 0335 0336 /** 0337 * Return a code for the type of this parameter. 0338 */ 0339 virtual string type() const; 0340 0341 /** 0342 * Return a string describing the type of interface to be included 0343 * in the Doxygen documentation. 0344 */ 0345 virtual string doxygenType() const; 0346 0347 /** 0348 * Return a complete description of this parameter vector. 0349 */ 0350 virtual string fullDescription(const InterfacedBase & ib) const; 0351 0352 /** 0353 * Set the \a i'th element of a container of member variables of \a 0354 * ib to val. Uses a stringstream to read the \a val into a Type 0355 * object and then calls tset(InterfacedBase &, Type, int). 0356 */ 0357 virtual void set(InterfacedBase & ib, string val, int i) const 0358 ; 0359 0360 /** 0361 * Set the \a i'th element of a container of member variables of \a 0362 * ib to \a val. 0363 */ 0364 virtual void tset(InterfacedBase & ib, Type val, int i) 0365 const = 0; 0366 0367 /** 0368 * Insert a new object before the \a i'th element of a container of 0369 * member variables of \a ib and set it to \a val. Uses a 0370 * stringstream to read the \a val into a Type object and then calls 0371 * tinsert(InterfacedBase &, Type, int). 0372 */ 0373 virtual void insert(InterfacedBase & ib, string val, int i) const 0374 ; 0375 0376 private: 0377 /// Implementation of set() for standard types. 0378 void setImpl(InterfacedBase & ib, string val, int i, StandardT) 0379 const; 0380 0381 /// Implementation of set() for dimensioned types. 0382 void setImpl(InterfacedBase & ib, string val, int i, DimensionT) 0383 const; 0384 0385 /// Implementation of insert() for standard types. 0386 void insertImpl(InterfacedBase & ib, string val, int i, StandardT) 0387 const; 0388 0389 /// Implementation of insert() for dimensioned types. 0390 void insertImpl(InterfacedBase & ib, string val, int i, DimensionT) 0391 const; 0392 0393 public: 0394 0395 /** 0396 * Insert a new object before the \a i'th element of a container of 0397 * member variables of \a ib and set it to \a val. 0398 */ 0399 virtual void tinsert(InterfacedBase & ib, Type val, int i) 0400 const = 0; 0401 0402 /** 0403 * Return the values of a container of member variables of \a ib in 0404 * a vector of strings. Calls the The tget(const InterfacedBase &) 0405 * and returns a vector of strings converted with ostringstreams. 0406 */ 0407 virtual StringVector get(const InterfacedBase & ib) const 0408 ; 0409 0410 /** 0411 * Return the values of a container of member variables of \a ib in a 0412 * vector of Type. 0413 */ 0414 virtual TypeVector tget(const InterfacedBase & ib) const 0415 = 0; 0416 0417 /** 0418 * Return the minimum value allowed for the \a i'th element of a 0419 * container of member variables of \a ib. Calls tminimum(const 0420 * InterfacedBase &, int) and converts the returned value with an 0421 * ostringstream. 0422 * 0423 */ 0424 virtual string minimum(const InterfacedBase & ib, int i) const 0425 ; 0426 0427 /** 0428 * Return the minimum value allowed for the \a i'th element of a 0429 * container of member variables of \a ib. 0430 */ 0431 virtual Type tminimum(const InterfacedBase & ib, int i) const 0432 = 0; 0433 0434 /** 0435 * Return the maximum value allowed for the \a i'th element of a 0436 * container of member variables of \a ib. Calls tmaximum(const 0437 * InterfacedBase &, int) and converts the returned value with an 0438 * ostringstream. 0439 */ 0440 virtual string maximum(const InterfacedBase & ib, int i) const 0441 ; 0442 0443 /** 0444 * Return the maximum value allowed for the \a i'th element of a 0445 * container of member variables of \a ib. 0446 */ 0447 virtual Type tmaximum(const InterfacedBase & ib, int i) const 0448 = 0; 0449 0450 /** 0451 * Return the default value for the \a i'th element of a container 0452 * of member variables of \a ib. Calls tdef(const InterfacedBase &, 0453 * int) and converts the returned value with an ostringstream. 0454 */ 0455 virtual string def(const InterfacedBase & ib, int i) const 0456 ; 0457 0458 /** 0459 * Return the default value for the \a i'th element of a container of 0460 * member variables of \a ib. 0461 */ 0462 virtual Type tdef(const InterfacedBase & ib, int i) const 0463 = 0; 0464 0465 /** 0466 * Return the general default value for this parameter vector. Calls 0467 * tdef() and converts the returned value with an ostringstream. 0468 */ 0469 virtual string def() const; 0470 0471 /** 0472 * Return the general default value for this parameter vector. 0473 */ 0474 virtual Type tdef() const = 0; 0475 0476 /** 0477 * set the \a i'th element of a container of member variables of \a ib to 0478 * its default value. 0479 */ 0480 virtual void setDef(InterfacedBase & ib, int i) const 0481 ; 0482 0483 /** 0484 * Get the unit which an Type object is divided (multiplied) by when 0485 * written to (read from) a stream via a double. If unit() is zero, 0486 * the Type object is written/read directly. 0487 */ 0488 Type unit() const { return theUnit; } 0489 0490 /** 0491 * Set the unit which an Type object is divided (multiplied) by when 0492 * written to (read from) a stream via a double. If unit() is zero, 0493 * the Type object is written/read directly. 0494 */ 0495 void unit(Type u) { theUnit = u; } 0496 0497 protected: 0498 0499 /** 0500 * Write a numer to a stream with the unit specified with unit(). 0501 */ 0502 void putUnit(ostream & os, Type val) const { 0503 putUnitImpl2(os, val, unit(), typename TypeTraits<Type>::DimType()); 0504 } 0505 0506 private: 0507 0508 /** 0509 * The unit which an Type object is divided (multiplied) by 0510 * when written to (read from) a stream via a double. If unit() is 0511 * zero, the Type object is written/read directly. 0512 */ 0513 Type theUnit; 0514 0515 }; 0516 0517 /** 0518 * The ParVector and its base classes ParVectorTBase and ParVectorBase 0519 * defines an interface to a class derived from the InterfacedBase, 0520 * through which vectors (or any other container) of simple member 0521 * variables can be manuipulated. ParVector is templated on the type 0522 * of the member variable and the type of the InterfacedBase class, 0523 * and is derived from the InterfaceBase class via 0524 * ParVectorTBase (which is templated only on the class 0525 * of the member variable) and ParVectorBase. 0526 * 0527 * For each InterfacedBase class exactly one static ParVector object 0528 * should created for each member variable of container type which 0529 * should be interfaced. This object will automatically register 0530 * itself with the BaseRepository class. 0531 * 0532 * @see Parameter 0533 * @see InterfacedBase 0534 * @see InterfaceBase 0535 * 0536 */ 0537 template <typename T, typename Type> 0538 class ParVector: public ParVectorTBase<Type> { 0539 0540 public: 0541 0542 /** 0543 * The declaration of member functions which can be used by this 0544 * ParVector interface for 'set' actions. 0545 */ 0546 typedef void (T::*SetFn)(Type, int); 0547 0548 /** 0549 * The declaration of member functions which can be used by this 0550 * ParVector interface for 'insert' actions. 0551 */ 0552 typedef void (T::*InsFn)(Type, int); 0553 0554 /** 0555 * The declaration of member functions which can be used by this 0556 * ParVector interface for 'erase' actions. 0557 */ 0558 typedef void (T::*DelFn)(int); 0559 0560 /** 0561 * A vector of objects of the template parameter Type. 0562 */ 0563 typedef vector<Type> TypeVector; 0564 0565 /** 0566 * The declaration of member functions which can be used by this 0567 * ParVector interface for 'get' actions. 0568 */ 0569 typedef TypeVector (T::*GetFn)() const; 0570 0571 /** 0572 * A vector of strings. 0573 */ 0574 typedef vector<string> StringVector; 0575 0576 /** 0577 * The declaration of member functions which can be used by this 0578 * ParVector interface for 'get' actions. 0579 */ 0580 typedef StringVector (T::*StringGetFn)() const; 0581 0582 /** 0583 * The declaration of member functions which can be used by this 0584 * ParVector interface for 'erase' actions. 0585 */ 0586 typedef Type (T::*DefFn)(int) const; 0587 0588 /** 0589 * Declaration of a direct pointer to the member variable in case it 0590 * is a vector. 0591 */ 0592 typedef TypeVector T::* Member; 0593 0594 public: 0595 0596 /** 0597 * Standard constructor. 0598 * 0599 * @param newName the name of the interface, may only contain 0600 * letters [a-zA-z0-9_]. 0601 * 0602 * @param newDescription a brief description of the interface. 0603 * 0604 * @param newMember a pointer to a Member which is a TypeVector. May 0605 * be null, in which case the pointers to member functions must be 0606 * specified. 0607 * 0608 * @param newSize the size of the container or -1 if varying. 0609 * 0610 * @param newDef the default value of the corresponding parameters. 0611 * 0612 * @param newMin the minimum value of the corresponding parameters. 0613 * 0614 * @param newMax the maximum value of the corresponding parameters. 0615 * 0616 * @param depSafe set to true if calls to this interface for one 0617 * object does not influence other objects. 0618 * 0619 * @param readonly if this is set true the interface will not be 0620 * able to manipulate objects of the corresponding class, but will 0621 * still be able to access information. 0622 * 0623 * @param limits determines if the values of the parameters are 0624 * limited from above and below. 0625 * 0626 * @param newSetFn optional pointer to member function for the 'set' 0627 * action. 0628 * 0629 * @param newInsFn optional pointer to member function for the 0630 * 'insert' action. 0631 * 0632 * @param newDelFn optional pointer to member function for the 0633 * 'erase' action. 0634 * 0635 * @param newDefFn optional pointer to member function for the 0636 * 'default' action. 0637 * 0638 * @param newGetFn optional pointer to member function for the 0639 * 'get' action. 0640 * 0641 * @param newMinFn optional pointer to member function for the 0642 * 'minimum' action. 0643 * 0644 * @param newMaxFn optional pointer to member function for the 0645 * 'maximum' action. 0646 * 0647 * @param newStringGetFn optional pointer to member function for the 0648 * 'get' action. 0649 */ 0650 ParVector(string newName, string newDescription, 0651 Member newMember, int newSize, Type newDef, Type newMin, 0652 Type newMax, bool depSafe = false, bool readonly = false, 0653 bool limits = true, SetFn newSetFn = 0, 0654 InsFn newInsFn = 0, DelFn newDelFn = 0, GetFn newGetFn = 0, 0655 DefFn newDefFn = 0, DefFn newMinFn = 0, DefFn newMaxFn = 0, 0656 StringGetFn newStringGetFn = 0) 0657 : ParVectorTBase<Type>(newName, newDescription, ClassTraits<T>::className(), 0658 typeid(T), Type(), newSize, depSafe, readonly, 0659 limits), 0660 theMember(newMember), theDef(newDef), theMin(newMin), theMax(newMax), 0661 theSetFn(newSetFn), theInsFn(newInsFn), theDelFn(newDelFn), 0662 theGetFn(newGetFn), theDefFn(newDefFn), theMinFn(newMinFn), 0663 theMaxFn(newMaxFn), theStringGetFn(newStringGetFn) {} 0664 0665 0666 /** 0667 * Standard constructor. 0668 * 0669 * @param newName the name of the interface, may only contain 0670 * letters [a-zA-z0-9_]. 0671 * 0672 * @param newDescription a brief description of the interface. 0673 * 0674 * @param newMember a pointer to a Member which is a TypeVector. May 0675 * be null, in which case the pointers to member functions must be 0676 * specified. 0677 * 0678 * @param newUnit the unit assumed when a number is read or written 0679 * to a stream. 0680 * 0681 * @param newSize the size of the container or -1 if varying. 0682 * 0683 * @param newDef the default value of the corresponding parameters. 0684 * 0685 * @param newGetFn optional pointer to member function for the 0686 * 'get' action. 0687 * 0688 * @param newMin the minimum value of the corresponding parameters. 0689 * 0690 * @param newMax the maximum value of the corresponding parameters. 0691 * 0692 * @param depSafe set to true if calls to this interface for one 0693 * object does not influence other objects. 0694 * 0695 * @param readonly if this is set true the interface will not be 0696 * able to manipulate objects of the corresponding class, but will 0697 * still be able to access information. 0698 * 0699 * @param limits determines if the values of the parameters are 0700 * limited from above and below. 0701 * 0702 * @param newSetFn optional pointer to member function for the 'set' 0703 * action. 0704 * 0705 * @param newInsFn optional pointer to member function for the 0706 * 'insert' action. 0707 * 0708 * @param newDelFn optional pointer to member function for the 0709 * 'erase' action. 0710 * 0711 * @param newDefFn optional pointer to member function for the 0712 * 'default' action. 0713 * 0714 * @param newMinFn optional pointer to member function for the 0715 * 'minimum' action. 0716 * 0717 * @param newMaxFn optional pointer to member function for the 0718 * 'maximum' action. 0719 * 0720 * @param newStringGetFn optional pointer to member function for the 0721 * 'get' action. 0722 */ 0723 ParVector(string newName, string newDescription, Member newMember, 0724 Type newUnit, int newSize, Type newDef, Type newMin, 0725 Type newMax, bool depSafe = false, bool readonly = false, 0726 bool limits = true, SetFn newSetFn = 0, 0727 InsFn newInsFn = 0, DelFn newDelFn = 0, GetFn newGetFn = 0, 0728 DefFn newDefFn = 0, DefFn newMinFn = 0, DefFn newMaxFn = 0, 0729 StringGetFn newStringGetFn = 0) 0730 : ParVectorTBase<Type>(newName, newDescription, ClassTraits<T>::className(), 0731 typeid(T), newUnit, newSize, depSafe, readonly, 0732 limits), 0733 theMember(newMember), theDef(newDef), theMin(newMin), theMax(newMax), 0734 theSetFn(newSetFn), theInsFn(newInsFn), theDelFn(newDelFn), 0735 theGetFn(newGetFn), theDefFn(newDefFn), theMinFn(newMinFn), 0736 theMaxFn(newMaxFn), theStringGetFn(newStringGetFn) {} 0737 0738 /** 0739 * Standard constructor. 0740 * 0741 * @param newName the name of the interface, may only contain 0742 * letters [a-zA-z0-9_]. 0743 * 0744 * @param newDescription a brief description of the interface. 0745 * 0746 * @param newMember a pointer to a Member which is a TypeVector. May 0747 * be null, in which case the pointers to member functions must be 0748 * specified. 0749 * 0750 * @param newSize the size of the container or -1 if varying. 0751 * 0752 * @param newDef the default value of the corresponding parameters. 0753 * 0754 * @param newMin the minimum value of the corresponding parameters. 0755 * 0756 * @param newMax the maximum value of the corresponding parameters. 0757 * 0758 * @param depSafe set to true if calls to this interface for one 0759 * object does not influence other objects. 0760 * 0761 * @param readonly if this is set true the interface will not be 0762 * able to manipulate objects of the corresponding class, but will 0763 * still be able to access information. 0764 * 0765 * @param limits determines if the values of the parameters are 0766 * limited from above and/or below. The possible values are given by 0767 * Interface::Limits. 0768 * 0769 * @param newSetFn optional pointer to member function for the 'set' 0770 * action. 0771 * 0772 * @param newInsFn optional pointer to member function for the 0773 * 'insert' action. 0774 * 0775 * @param newDelFn optional pointer to member function for the 0776 * 'erase' action. 0777 * 0778 * @param newDefFn optional pointer to member function for the 0779 * 'default' action. 0780 * 0781 * @param newGetFn optional pointer to member function for the 0782 * 'get' action. 0783 * 0784 * @param newMinFn optional pointer to member function for the 0785 * 'minimum' action. 0786 * 0787 * @param newMaxFn optional pointer to member function for the 0788 * 'maximum' action. 0789 * 0790 * @param newStringGetFn optional pointer to member function for the 0791 * 'get' action. 0792 */ 0793 ParVector(string newName, string newDescription, 0794 Member newMember, int newSize, Type newDef, Type newMin, 0795 Type newMax, bool depSafe = false, bool readonly = false, 0796 int limits = Interface::limited, SetFn newSetFn = 0, 0797 InsFn newInsFn = 0, DelFn newDelFn = 0, GetFn newGetFn = 0, 0798 DefFn newDefFn = 0, DefFn newMinFn = 0, DefFn newMaxFn = 0, 0799 StringGetFn newStringGetFn = 0) 0800 : ParVectorTBase<Type>(newName, newDescription, ClassTraits<T>::className(), 0801 typeid(T), Type(), newSize, depSafe, readonly, 0802 limits), 0803 theMember(newMember), theDef(newDef), theMin(newMin), theMax(newMax), 0804 theSetFn(newSetFn), theInsFn(newInsFn), theDelFn(newDelFn), 0805 theGetFn(newGetFn), theDefFn(newDefFn), theMinFn(newMinFn), 0806 theMaxFn(newMaxFn), theStringGetFn(newStringGetFn) {} 0807 0808 /** 0809 * Standard constructor. 0810 * 0811 * @param newName the name of the interface, may only contain 0812 * letters [a-zA-z0-9_]. 0813 * 0814 * @param newDescription a brief description of the interface. 0815 * 0816 * @param newMember a pointer to a Member which is a TypeVector. May 0817 * be null, in which case the pointers to member functions must be 0818 * specified. 0819 * 0820 * @param newUnit the unit assumed when a number is read or written 0821 * to a stream. 0822 * 0823 * @param newSize the size of the container or -1 if varying. 0824 * 0825 * @param newDef the default value of the corresponding parameters. 0826 * 0827 * @param newGetFn optional pointer to member function for the 0828 * 'get' action. 0829 * 0830 * @param newMin the minimum value of the corresponding parameters. 0831 * 0832 * @param newMax the maximum value of the corresponding parameters. 0833 * 0834 * @param depSafe set to true if calls to this interface for one 0835 * object does not influence other objects. 0836 * 0837 * @param readonly if this is set true the interface will not be 0838 * able to manipulate objects of the corresponding class, but will 0839 * still be able to access information. 0840 * 0841 * @param limits determines if the values of the parameters are 0842 * limited from above and/or below. The possible values are given by 0843 * Interface::Limits. 0844 * 0845 * @param newSetFn optional pointer to member function for the 'set' 0846 * action. 0847 * 0848 * @param newInsFn optional pointer to member function for the 0849 * 'insert' action. 0850 * 0851 * @param newDelFn optional pointer to member function for the 0852 * 'erase' action. 0853 * 0854 * @param newDefFn optional pointer to member function for the 0855 * 'default' action. 0856 * 0857 * @param newMinFn optional pointer to member function for the 0858 * 'minimum' action. 0859 * 0860 * @param newMaxFn optional pointer to member function for the 0861 * 'maximum' action. 0862 * 0863 * @param newStringGetFn optional pointer to member function for the 0864 * 'get' action. 0865 */ 0866 ParVector(string newName, string newDescription, Member newMember, 0867 Type newUnit, int newSize, Type newDef, Type newMin, 0868 Type newMax, bool depSafe = false, bool readonly = false, 0869 int limits = Interface::limited, SetFn newSetFn = 0, 0870 InsFn newInsFn = 0, DelFn newDelFn = 0, GetFn newGetFn = 0, 0871 DefFn newDefFn = 0, DefFn newMinFn = 0, DefFn newMaxFn = 0, 0872 StringGetFn newStringGetFn = 0) 0873 : ParVectorTBase<Type>(newName, newDescription, ClassTraits<T>::className(), 0874 typeid(T), newUnit, newSize, depSafe, readonly, 0875 limits), 0876 theMember(newMember), theDef(newDef), theMin(newMin), theMax(newMax), 0877 theSetFn(newSetFn), theInsFn(newInsFn), theDelFn(newDelFn), 0878 theGetFn(newGetFn), theDefFn(newDefFn), theMinFn(newMinFn), 0879 theMaxFn(newMaxFn), theStringGetFn(newStringGetFn) {} 0880 0881 /** 0882 * Set the \a i'th element of a container of member variables of \a 0883 * ib to \a val. 0884 */ 0885 virtual void tset(InterfacedBase & ib, Type val, int i) const 0886 ; 0887 0888 /** 0889 * Insert a new object before the \a i'th element of a container of 0890 * member variables of \a ib and set it to \a val. 0891 */ 0892 virtual void tinsert(InterfacedBase & ib, Type val, int i) const 0893 ; 0894 0895 /** 0896 * Remove the \a i'th element of a container of 0897 * member variables of \a ib. 0898 */ 0899 virtual void erase(InterfacedBase & ib, int i) 0900 const; 0901 0902 /** 0903 * Clear the container of pointers of \a ib. 0904 */ 0905 virtual void clear(InterfacedBase & ib) 0906 const; 0907 0908 /** 0909 * Return the values of a container of member variables of \a ib in 0910 * a vector of strings. Calls the The tget(const InterfacedBase &) 0911 * and returns a vector of strings converted with ostringstreams. 0912 */ 0913 virtual StringVector get(const InterfacedBase & ib) const 0914 ; 0915 0916 /** 0917 * Return the values of a container of member variables of \a ib in a 0918 * vector of Type. 0919 */ 0920 virtual TypeVector tget(const InterfacedBase & ib) const 0921 ; 0922 0923 /** 0924 * Return the minimum value allowed for the \a i'th element of a 0925 * container of member variables of \a ib. 0926 */ 0927 virtual Type tminimum(const InterfacedBase & ib, int i) const 0928 ; 0929 0930 /** 0931 * Return the maximum value allowed for the \a i'th element of a 0932 * container of member variables of \a ib. 0933 */ 0934 virtual Type tmaximum(const InterfacedBase & ib, int i) const 0935 ; 0936 0937 /** 0938 * Return the default value for the \a i'th element of a container of 0939 * member variables of \a ib. 0940 */ 0941 virtual Type tdef(const InterfacedBase &, int) const 0942 ; 0943 0944 /** 0945 * Return the general default value for this parameter vector. 0946 */ 0947 virtual Type tdef() const; 0948 0949 /** 0950 * Give a pointer to a member function to be used by tset(). 0951 */ 0952 void setSetFunction(SetFn sf) { theSetFn = sf; } 0953 0954 /** 0955 * Give a pointer to a member function to be used by tinsert(). 0956 */ 0957 void setInsertFunction(InsFn ifn) { theInsFn = ifn; } 0958 0959 /** 0960 * Give a pointer to a member function to be used by tget(). 0961 */ 0962 void setGetFunction(GetFn gf) { theGetFn = gf; } 0963 0964 /** 0965 * Give a pointer to a member function to be used by terase(). 0966 */ 0967 void setEraseFunction(DelFn df) { theDelFn = df; } 0968 0969 /** 0970 * Give a pointer to a member function to be used by tdef(). 0971 */ 0972 void setDefaultFunction(GetFn df) { theDefFn = df; } 0973 0974 /** 0975 * Give a pointer to a member function to be used by tminimum(). 0976 */ 0977 void setMinFunction(GetFn mf) { theMinFn = mf; } 0978 0979 /** 0980 * Give a pointer to a member function to be used by tmaximum(). 0981 */ 0982 void setMaxFunction(GetFn mf) { theMaxFn = mf; } 0983 0984 /** 0985 * Give a pointer to a member function to be used by get(). 0986 */ 0987 void setStringGetFunction(StringGetFn gf) { theStringGetFn = gf; } 0988 0989 /** 0990 * Print a description to be included in the Doxygen documentation 0991 * to the given \a stream. 0992 */ 0993 virtual void doxygenDescription(ostream & stream) const; 0994 0995 private: 0996 0997 /** 0998 * The pointer to the member variable. 0999 */ 1000 Member theMember; 1001 1002 /** 1003 * Default value to be used if no corresponding member function 1004 * pointer is given. 1005 */ 1006 Type theDef; 1007 1008 /** 1009 * Minimum value to be used if no corresponding member function 1010 * pointer is given. 1011 */ 1012 Type theMin; 1013 1014 /** 1015 * Maximum value to be used if no 1016 * corresponding member function pointer is given. 1017 */ 1018 Type theMax; 1019 1020 /** 1021 * A pointer to a member function to be used by tset(). 1022 */ 1023 SetFn theSetFn; 1024 1025 /** 1026 * A pointer to a member function to be used by tinsert(). 1027 */ 1028 InsFn theInsFn; 1029 1030 /** 1031 * A pointer to a member function to be used by terase(). 1032 */ 1033 DelFn theDelFn; 1034 1035 /** 1036 * A pointer to a member function to be used by tget(). 1037 */ 1038 GetFn theGetFn; 1039 1040 /** 1041 * Pointer to member function to be used by tdef(). 1042 */ 1043 DefFn theDefFn; 1044 1045 /** 1046 * Pointer to member function to be used by tminimum(). 1047 */ 1048 DefFn theMinFn; 1049 1050 /** 1051 * Pointer to member function to be used by tmaximum(). 1052 */ 1053 DefFn theMaxFn; 1054 1055 /** 1056 * A pointer to a member function to be used by set(). 1057 */ 1058 StringGetFn theStringGetFn; 1059 1060 }; 1061 1062 } 1063 1064 #ifndef ThePEG_TEMPLATES_IN_CC_FILE 1065 #include "ParVector.tcc" 1066 #endif 1067 1068 #endif /* ThePEG_ParVector_H */
| [ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
|
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
|