CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Protected Member Functions | Static Protected Member Functions | Protected Attributes | Friends
AlgoImpl Class Referenceabstract

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

#include <AlgoImpl.h>

Inheritance diagram for AlgoImpl:
global_angular_0 global_linear_0 global_linear_1 global_simpleAngular_0 global_simpleAngular_1 global_simpleAngular_2

Public Member Functions

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

Protected Member Functions

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

Protected Attributes

const int & count_
 
const int & curr_
 
const int & end_
 
std::string & err_
 
const int & incr_
 
std::string label_
 
parE_typeParE_
 
parS_typeParS_
 
const int & start_
 
bool & terminate_
 

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 6 of file AlgoImpl.cc.

References AlgoPos::registerAlgo().

7  : ParS_(al->ParS_),
8  ParE_(al->ParE_),
9  start_(al->start_), end_(al->end_), incr_(al->incr_),
10  curr_(al->curr_), count_(al->count_),
11  terminate_(al->terminate_), err_(al->err_),
12  label_(label)
13 {
14  // DCOUT('E', "AlgoImpl ctor called with label=" << label << " AlgoPos.ddname=" << al->ddname() );
15  al->registerAlgo(this);
16 }
int end_
Definition: AlgoPos.h:138
int curr_
current position in the range of the algorithm
Definition: AlgoPos.h:146
const int & end_
Definition: AlgoImpl.h:115
parE_type & ParE_
Definition: AlgoImpl.h:113
const int & curr_
Definition: AlgoImpl.h:117
int count_
invocation count
Definition: AlgoPos.h:153
std::string & err_
Definition: AlgoImpl.h:120
const int & count_
Definition: AlgoImpl.h:118
int start_
range of the algorithm
Definition: AlgoPos.h:138
parS_type ParS_
std::string valued parameters passed to the algorithm
Definition: AlgoPos.h:161
bool terminate_
flag to signal whether the algorithm has finished (true)
Definition: AlgoPos.h:172
parE_type ParE_
double valued parameters passed to the algorithm
Definition: AlgoPos.h:169
const int & incr_
Definition: AlgoImpl.h:116
void registerAlgo(AlgoImpl *)
registers an implementation of the algorithm
Definition: AlgoPos.cc:72
bool & terminate_
Definition: AlgoImpl.h:119
int incr_
Definition: AlgoPos.h:138
std::string label_
Definition: AlgoImpl.h:121
parS_type & ParS_
Definition: AlgoImpl.h:112
std::string err_
std::string to hold potential error messages found inside checkParameters()
Definition: AlgoPos.h:175
const int & start_
Definition: AlgoImpl.h:114
AlgoImpl::~AlgoImpl ( void  )
protectedvirtual

Definition at line 18 of file AlgoImpl.cc.

19 { }

Member Function Documentation

virtual bool AlgoImpl::checkParameters ( )
protectedpure 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_simpleAngular_2, global_simpleAngular_1, global_linear_1, global_simpleAngular_0, global_linear_0, and global_angular_0.

void AlgoImpl::checkTermination ( void  )
protectedvirtual

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_simpleAngular_2, global_simpleAngular_1, global_simpleAngular_0, and global_angular_0.

Definition at line 34 of file AlgoImpl.cc.

References terminate().

Referenced by AlgoPos::checkTermination().

35 {
36  terminate();
37 }
void terminate()
stop the current iteration of the algorithm (for incr_==0 types of algorithms)
Definition: AlgoImpl.cc:28
int AlgoImpl::copyno ( void  ) const
protectedvirtual

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.

Definition at line 22 of file AlgoImpl.cc.

References count_, curr_, and incr_.

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

23 {
24  return incr_ ? curr_ : count_ ;
25 }
const int & curr_
Definition: AlgoImpl.h:117
const int & count_
Definition: AlgoImpl.h:118
const int & incr_
Definition: AlgoImpl.h:116
std::string AlgoImpl::d2s ( double  x)
staticprotected

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

Definition at line 40 of file AlgoImpl.cc.

References AlCaHLTBitMon_QueryRunRegistry::string.

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

41 {
42  char buffer [25];
43  int len = snprintf( buffer, 25, "%g", x );
44  if( len >= 25 )
45  edm::LogError( "DoubleToString" ) << "Length truncated (from " << len << ")";
46  return std::string( buffer );
47 }
Definition: DDAxes.h:10
virtual DDRotationMatrix AlgoImpl::rotation ( )
protectedpure 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_simpleAngular_2, global_simpleAngular_1, global_linear_1, global_simpleAngular_0, global_linear_0, and global_angular_0.

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_angular_0::checkTermination(), global_simpleAngular_0::checkTermination(), global_simpleAngular_1::checkTermination(), checkTermination(), and global_simpleAngular_2::checkTermination().

29 {
30  terminate_ = true;
31 }
bool & terminate_
Definition: AlgoImpl.h:119
virtual DD3Vector AlgoImpl::translation ( )
protectedpure 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_simpleAngular_2, global_simpleAngular_1, global_linear_1, global_simpleAngular_0, global_linear_0, and global_angular_0.

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
const int& AlgoImpl::curr_
protected

Definition at line 117 of file AlgoImpl.h.

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

const int& AlgoImpl::end_
protected

Definition at line 115 of file AlgoImpl.h.

std::string& AlgoImpl::err_
protected
const int& AlgoImpl::incr_
protected

Definition at line 116 of file AlgoImpl.h.

Referenced by copyno().

std::string AlgoImpl::label_
protected
parE_type& AlgoImpl::ParE_
protected
parS_type& AlgoImpl::ParS_
protected
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().