CMS 3D CMS Logo

AlgoImpl Class Reference

implementation of an algorithm, non generated checking code. More...

#include <DetectorDescription/ExprAlgo/interface/AlgoImpl.h>

Inheritance diagram for AlgoImpl:

global_angular_0 global_linear_0 global_linear_1 global_simpleAngular_0 global_simpleAngular_1 global_simpleAngular_2 presh_detectors

List of all members.

Public Member Functions

 AlgoImpl (AlgoPos *, std::string label)
 subclass must provide a similar constructor and call this one

Protected Member Functions

virtual bool checkParameters ()=0
 subclass must check the supplied parameters ParE_, ParS_
virtual void checkTermination ()
 for algorithms with incr_==0 the algorithm must check whether to terminate
virtual int copyno () const
 copy-number calculation
virtual DDRotationMatrix rotation ()=0
 subclass must calculate a rotation matrix
void terminate ()
 stop the current iteration of the algorithm (for incr_==0 types of algorithms)
virtual DD3Vector translation ()=0
 subclass must calculate a translation std::vector
virtual ~AlgoImpl ()

Static Protected Member Functions

static std::string d2s (double x)
 ahh, converts a double into a std::string ... yet another one of this kind!

Protected Attributes

const intcount_
const intcurr_
const intend_
std::string & err_
const intincr_
std::string label_
parE_typeParE_
parS_typeParS_
const intstart_
boolterminate_

Friends

class AlgoPos


Detailed Description

implementation of an algorithm, non generated checking code.

objects of this class must register themselves with the representation of the algorithm AlgoPos.

All methods will be called appropriately by AlgoPos.

Definition at line 19 of file AlgoImpl.h.


Constructor & Destructor Documentation

AlgoImpl::AlgoImpl ( AlgoPos al,
std::string  label 
)

subclass must provide a similar constructor and call this one

Definition at line 5 of file AlgoImpl.cc.

References AlgoPos::registerAlgo().

00006  : ParS_(al->ParS_),
00007    ParE_(al->ParE_),
00008    start_(al->start_), end_(al->end_), incr_(al->incr_),
00009    curr_(al->curr_), count_(al->count_),
00010    terminate_(al->terminate_), err_(al->err_),
00011    label_(label)
00012 {
00013  // DCOUT('E', "AlgoImpl ctor called with label=" << label << " AlgoPos.ddname=" << al->ddname() );
00014   al->registerAlgo(this);
00015 } 

AlgoImpl::~AlgoImpl (  )  [protected, virtual]

Definition at line 18 of file AlgoImpl.cc.

00019 { }


Member Function Documentation

virtual bool AlgoImpl::checkParameters (  )  [protected, pure virtual]

subclass must check the supplied parameters ParE_, ParS_

whether they are correct and should select this paricular algorithm.

If the parameters are correct by should not select this particular algorithm, checkParamters must return false otherwise true.

The std::string err_ is to be used to be extended with error information in case any errors have been detected. Error information must be attached to err_ because of the possibility of already contained error information.

In case of errors: If an DDException is thrown by the algorithm implementation, further processing of any other implementations of the algorithm will be stopped. If no exception is thrown, checkParamters must return false. It's preferable not to throw an exception in case of errors. The algorithm implementation will throw if all checkParamters() of all registered algorithm implementations have returned false.

Implemented in global_angular_0, global_linear_0, global_linear_1, global_simpleAngular_0, global_simpleAngular_1, global_simpleAngular_2, and presh_detectors.

void AlgoImpl::checkTermination (  )  [protected, virtual]

for algorithms with incr_==0 the algorithm must check whether to terminate

Overload this function in case the algorithm is a 'incr_==0' type. In this case provide some code which checks using perhaps the value of count_ and/or supplied algorithm parameters to check whether terminate() has to be called or not. If terminate() is called, the current iteration of the algorithm is not taken into account!

The default implementation will immidiately terminate the algorithm in case incr_==0.

In case of incr_!=0: checkTermination() is not called at all; the algorithm will terminate automatically when the specified range [start_, end_, incr_] has been covered or terminate() has been called from within translation() or rotation().

Reimplemented in global_angular_0, global_simpleAngular_0, global_simpleAngular_1, and global_simpleAngular_2.

Definition at line 34 of file AlgoImpl.cc.

References terminate().

Referenced by AlgoPos::checkTermination().

00035 {
00036   terminate();
00037 }  

int AlgoImpl::copyno (  )  const [protected, virtual]

copy-number calculation

In case incr_==0 it makes sense to overload this method, otherwise the invocation-count count_ will be returned as copy-number

If incr_ !=0 the copy-number will be curr_, the actual position in the range [start_,end_,incr_], unless this methods is overloaded.

Reimplemented in global_angular_0, and presh_detectors.

Definition at line 22 of file AlgoImpl.cc.

References count_, curr_, and incr_.

Referenced by global_angular_0::copyno(), and AlgoPos::copyno().

00023 {
00024   return incr_ ? curr_ : count_ ;
00025 }  

std::string AlgoImpl::d2s ( double  x  )  [static, protected]

ahh, converts a double into a std::string ... yet another one of this kind!

Definition at line 40 of file AlgoImpl.cc.

Referenced by global_angular_0::checkParameters(), and AlgoPos::setParameters().

00041 {
00042   char buffer [25]; 
00043   sprintf(buffer,"%g",x);
00044   return std::string(buffer);
00045 }

virtual DDRotationMatrix AlgoImpl::rotation (  )  [protected, pure virtual]

subclass must calculate a rotation matrix

depending on the current position curr_ in the range [start_,end_,incr_] and the user supplied parameters ParE_, ParS_

Implemented in global_angular_0, global_linear_0, global_linear_1, global_simpleAngular_0, global_simpleAngular_1, global_simpleAngular_2, and presh_detectors.

Referenced by AlgoPos::rotation().

void AlgoImpl::terminate ( void   )  [protected]

stop the current iteration of the algorithm (for incr_==0 types of algorithms)

terminate() should be called in translation() or rotation() whenever the algorithm detects its termination condition. The current iteration of the algorithm then is not taken into account for algorithmic positioning.

If the algorithm is of type incr_ != 0 it will terminate automatically after its range [start_,end_,incr_] has been covered unless the algorithm calls terminate() from within translation() or rotation().

If the algorithm is of type incr_ == 0 the algorithm implementation has to provide code in checkTermination() which must call terminate() when it detects a termination condition (depending on the invocation-count of the algorithm , ...)

Definition at line 28 of file AlgoImpl.cc.

References terminate_.

Referenced by global_simpleAngular_0::checkTermination(), global_angular_0::checkTermination(), global_simpleAngular_2::checkTermination(), global_simpleAngular_1::checkTermination(), and checkTermination().

00029 {
00030   terminate_ = true;
00031 }

virtual DD3Vector AlgoImpl::translation (  )  [protected, pure virtual]

subclass must calculate a translation std::vector

depending on the current position curr_ in the range [start_,end_,incr_] and the user supplied parameters ParE_, ParS_

Implemented in global_angular_0, global_linear_0, global_linear_1, global_simpleAngular_0, global_simpleAngular_1, global_simpleAngular_2, and presh_detectors.

Referenced by AlgoPos::translation().


Friends And Related Function Documentation

friend class AlgoPos [friend]

Definition at line 21 of file AlgoImpl.h.


Member Data Documentation

const int& AlgoImpl::count_ [protected]

Definition at line 118 of file AlgoImpl.h.

Referenced by global_simpleAngular_0::checkTermination(), global_angular_0::checkTermination(), global_simpleAngular_2::checkTermination(), global_simpleAngular_1::checkTermination(), copyno(), global_simpleAngular_2::rotation(), global_simpleAngular_1::rotation(), global_simpleAngular_0::rotation(), global_angular_0::rotation(), global_angular_0::translation(), global_simpleAngular_0::translation(), global_simpleAngular_1::translation(), and global_simpleAngular_2::translation().

const int& AlgoImpl::curr_ [protected]

Definition at line 117 of file AlgoImpl.h.

Referenced by copyno(), global_linear_1::translation(), and global_linear_0::translation().

const int& AlgoImpl::end_ [protected]

Definition at line 115 of file AlgoImpl.h.

std::string& AlgoImpl::err_ [protected]

Definition at line 120 of file AlgoImpl.h.

Referenced by global_linear_0::checkParameters(), global_simpleAngular_0::checkParameters(), global_simpleAngular_2::checkParameters(), global_linear_1::checkParameters(), global_angular_0::checkParameters(), and global_simpleAngular_1::checkParameters().

const int& AlgoImpl::incr_ [protected]

Definition at line 116 of file AlgoImpl.h.

Referenced by copyno().

std::string AlgoImpl::label_ [protected]

Definition at line 121 of file AlgoImpl.h.

parE_type& AlgoImpl::ParE_ [protected]

Definition at line 113 of file AlgoImpl.h.

Referenced by global_linear_0::checkParameters(), global_simpleAngular_0::checkParameters(), global_simpleAngular_2::checkParameters(), global_linear_1::checkParameters(), global_angular_0::checkParameters(), global_simpleAngular_1::checkParameters(), global_simpleAngular_0::checkTermination(), global_simpleAngular_2::checkTermination(), global_simpleAngular_1::checkTermination(), global_simpleAngular_2::rotation(), global_simpleAngular_1::rotation(), global_simpleAngular_0::rotation(), global_linear_1::translation(), global_simpleAngular_0::translation(), global_simpleAngular_1::translation(), global_simpleAngular_2::translation(), and global_linear_0::translation().

parS_type& AlgoImpl::ParS_ [protected]

Definition at line 112 of file AlgoImpl.h.

Referenced by global_angular_0::checkParameters(), global_simpleAngular_2::rotation(), global_simpleAngular_1::rotation(), and global_simpleAngular_0::rotation().

const int& AlgoImpl::start_ [protected]

Definition at line 114 of file AlgoImpl.h.

bool& AlgoImpl::terminate_ [protected]

Definition at line 119 of file AlgoImpl.h.

Referenced by terminate().


The documentation for this class was generated from the following files:
Generated on Tue Jun 9 18:14:11 2009 for CMSSW by  doxygen 1.5.4