CMS 3D CMS Logo

Public Member Functions | Protected Member Functions | Static Protected Member Functions | Protected Attributes | Friends

AlgoImpl Class Reference

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

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 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().

  : ParS_(al->ParS_),
    ParE_(al->ParE_),
    start_(al->start_), end_(al->end_), incr_(al->incr_),
    curr_(al->curr_), count_(al->count_),
    terminate_(al->terminate_), err_(al->err_),
    label_(label)
{
  // DCOUT('E', "AlgoImpl ctor called with label=" << label << " AlgoPos.ddname=" << al->ddname() );
  al->registerAlgo(this);
} 
AlgoImpl::~AlgoImpl ( void  ) [protected, virtual]

Definition at line 18 of file AlgoImpl.cc.

{ }

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, and global_simpleAngular_2.

void AlgoImpl::checkTermination ( void  ) [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().

{
  terminate();
}  
int AlgoImpl::copyno ( void  ) 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.

Definition at line 22 of file AlgoImpl.cc.

References count_, curr_, and incr_.

Referenced by AlgoPos::copyno().

{
  return incr_ ? curr_ : count_ ;
}  
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().

{
  char buffer [25]; 
  int len = snprintf( buffer, 25, "%g", x );
  if( len >= 25 )
    edm::LogError( "DoubleToString" ) << "Length truncated (from " << len << ")";
  return std::string( buffer );
}
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, and global_simpleAngular_2.

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().

{
  terminate_ = true;
}
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, and global_simpleAngular_2.

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_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]
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]
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().