List of all members | Public Member Functions | Protected Types | Static Protected Attributes | Private Member Functions | Private Attributes
det::MPositionable< Config > Class Template Referenceabstract

Mixin class to be inherited from objects that have a position. More...

#include <MPositionable.h>

Inheritance diagram for det::MPositionable< Config >:
Inheritance graph
[legend]

Public Member Functions

utl::CoordinateSystemPtr GetLocalCoordinateSystem () const
 Local system based on position and configured rotations. More...
 
utl::Point GetPosition () const
 
 MPositionable (const Config &cp)
 
virtual ~MPositionable ()
 

Protected Types

typedef std::string CoordinateType
 Simple internal typedef to emulate the actual enumeration via a type handled in the configuration mechanism. More...
 

Protected Member Functions

Specific datum accesor components.

In the most commeon situation deriving clases won't override these methods (and so the actual retrieval will be forwarded to the expected method in the Config template argument. Nevertheless they are made virtual in order to allow posible customization by subclasses. This customization could be done in principle in the Get method, basing the decision on the tag, but that would be pretty ugly.

virtual double GetComponent1 () const
 First component of the position vector. More...
 
virtual double GetComponent2 () const
 Second component of the position vector. More...
 
virtual double GetComponent3 () const
 Third component of the position vector. More...
 
virtual double GetEulerPhi () const
 First Euler angle for rotation over (original) z. More...
 
virtual double GetEulerTheta () const
 Second Euler angle for rotation over (intermediate) x. More...
 
virtual double GetEulerPsi () const
 Third Euler angle for rotation over (intermediate) z. More...
 
virtual CoordinateType GetCoordinateType () const
 Coordinate type. More...
 

Static Protected Attributes

static const std::string kComponent1Tag = "positionComponent1"
 Tag for first vector component in config. More...
 
static const std::string kComponent2Tag = "positionComponent2"
 Tag for second vector component in config. More...
 
static const std::string kComponent3Tag = "positionComponent3"
 Tag for third vector component in config. More...
 
static const std::string kCoordinateTypeTag = "coordinateType"
 
static const std::string kEulerPhiTag = "eulerPhi"
 Tag for first rotation's Euler angle in config. More...
 
static const std::string kEulerPsiTag = "eulerPsi"
 Tag for third rotation's Euler angle in config. More...
 
static const std::string kEulerThetaTag = "eulerTheta"
 Tag for second rotation's Euler angle in config. More...
 

Private Member Functions

virtual utl::CoordinateSystemPtr GetReferenceCoordinateSystem () const =0
 

Private Attributes

const ConfigfConfig
 Hold a reference to the configuration proxy. More...
 
utl::ShadowPtr< double > fComponent1
 
utl::ShadowPtr< double > fComponent2
 
utl::ShadowPtr< double > fComponent3
 
utl::ShadowPtr< double > fEulerPhi
 
utl::ShadowPtr< double > fEulerTheta
 
utl::ShadowPtr< double > fEulerPsi
 
utl::ShadowPtr< CoordinateTypefCoordinateType
 
utl::CoordinateSystemPtr fLocalCoordinateSystem
 

Detailed Description

template<class Config>
class det::MPositionable< Config >

Mixin class to be inherited from objects that have a position.

The class provides the basic methods for one of those objects:

Delegates to deriving classes the definition of the coordinate system to which the position is referred (GetReferenceCoordinateSystem). The actual values are retrieved from the configuration imposed by the objects of the template argument. The position is specified by components and angles, the components can be on any of the defined types of coordinates.

The translational part is configured by three components, and the rotation by the so-called "Euler angles". The convention for Euler angles is taken from: Goldstein, Herbert et al; "Classical Mechanics", 3rd edition, Addison-Wesley. See 4.4-The Euler angles / pp 150-154. For quick reference the convention is given here:

These conventions for Euler angles are also the ones used in ROOT's TGeoRotation.

The template argument Config is expected to be able to resolve a member call with the following signatures:

-double& GetData(utl::ShadowPtr<double>&, const std::string&) const; -CoordinateType& GetData(utl::ShadowPtr<CoordinateType>&, const std::string&) const;

with the semantics that that call will initialize the pointer or retrieve its current value (whatever is correct) for the given property (see constants with the tag names).

Todo:
All the non template-dependant code may be put in a superclass and the template dependant code be kept here. Then the template MPositionable would derive from the former. In this way some bloat (of the generated object files) may be avoided. See next todo about Boost's shared_ptr. See Scott Meyers' "Effective C++", item 44 "Factor parameter-independent code out of templates".
Todo:
Note that the template argument is used as the callback mechanism to resolve particular datum. This class could be made non-template in two ways. The first is obviously to have, in Java parlance, an interface defined with the callback method, and so accept objects deriving from it. Another posibility is to borrow the idea of Boost's shared pointers; that is to define that interface privately, have a private implementation of it and then wrap with the second the objects received by a templated constructor. See "My Most Important C++ Aha! Moments...Ever" by Scott Meyers http://www.artima.com/cppsource/top_cpp_aha_moments.html "External Polymorphism" by Chris Cleeland et al. http://www.cs.wustl.edu/~schmidt/PDF/External-Polymorphism.pdf "The shared_ptr Class" by Danny Kalev http://www.informit.com/guides/content.aspx?g=cplusplus&seqNum=239 and of course Boost's docs & srcs.
Todo:
This class could be split into two clases:
  • A pure abstract interface with the required methods that make a "positionable" (GetPosition, GetLocalCoordinateSystem). In relation to this note that users of this class won't be likely to be treated polymorphically, so this interface may not be needed.
  • A base implementation of the former. Given this, the clients could choose between mixing-in the functionality via (posibly multiple) inheritance (the choice favored by the current single class implementation) or composition plus method-call delegation (in an idiom more typical of Java). What would be also necesary in this second approach is to change the stategy for GetReferenceCoordinateSystem, what should be done is something like giving directly a reference to that system via the nested-object's constructor (in addition to the current reference to this, used to resolve GetData). Another possibility (instead of a 2nd argument in constructor) would be to split even more the classes, and put GetReferenceCoordinateSystem in less specific interface, that would be extended by the original interface, implemented by the delegatee class and required by the delegate (in it's constructor). Of course, given the use of templates (for GetData resolution) that interface with GetReferenceCoordinateSystem may be implicitly required on the type, that is, C++ parlance, a concept.
Todo:
In the light of the first usage (within a hierarchy of det::DetectorComponent) another last posibility would be to define a type to mix "positionable" with "component", let's say something like PositionableDetectorComponent: in this way multiple inheritance would be avoided.
Todo:
This class doesn't handle UTM points. For that case, in addition to the 3 components band & zone are required (and there's no coordinate type). Up to now the neccesity was only to work with derived coordinate systems (which is materialized by the presence of the GetReferenceCoordinateSystem method).

As reference see item 40 "Use multiple inheritance judiciouly" in "Effective C++" by Scott Meyers.

Author
Rodolfo Federico Gamarra
Date
09 Jan 2009

Definition at line 120 of file MPositionable.h.

Member Typedef Documentation

template<class Config>
typedef std::string det::MPositionable< Config >::CoordinateType
protected

Simple internal typedef to emulate the actual enumeration via a type handled in the configuration mechanism.

Definition at line 157 of file MPositionable.h.

Constructor & Destructor Documentation

template<class Config>
det::MPositionable< Config >::MPositionable ( const Config cp)
inline

Construct a MPositionable with the config provider. A reference to c is kept const within this class, and to it the resolution of values (components, angles and type) are forwarded when appropiate. More preciselly the

Definition at line 126 of file MPositionable.h.

template<class Config>
virtual det::MPositionable< Config >::~MPositionable ( )
inlinevirtual

Definition at line 128 of file MPositionable.h.

Member Function Documentation

template<class Config >
double det::MPositionable< Config >::GetComponent1 ( ) const
protectedvirtual

First component of the position vector.

It could be x or r, according to the type determined by GetCoordinateType.

See Also
utl::Vector

Definition at line 304 of file MPositionable.h.

template<class Config >
double det::MPositionable< Config >::GetComponent2 ( ) const
protectedvirtual

Second component of the position vector.

See Also
GetComponent1

Definition at line 313 of file MPositionable.h.

template<class Config >
double det::MPositionable< Config >::GetComponent3 ( ) const
protectedvirtual

Third component of the position vector.

See Also
GetComponent1

Definition at line 317 of file MPositionable.h.

template<class Config >
MPositionable< Config >::CoordinateType det::MPositionable< Config >::GetCoordinateType ( ) const
protectedvirtual

Coordinate type.

See Also
utl::Vector::CoordinateType

Definition at line 333 of file MPositionable.h.

template<class Config >
double det::MPositionable< Config >::GetEulerPhi ( ) const
protectedvirtual

First Euler angle for rotation over (original) z.

Definition at line 321 of file MPositionable.h.

Referenced by mdet::Module::GetPhi0().

template<class Config >
double det::MPositionable< Config >::GetEulerPsi ( ) const
protectedvirtual

Third Euler angle for rotation over (intermediate) z.

Definition at line 329 of file MPositionable.h.

template<class Config >
double det::MPositionable< Config >::GetEulerTheta ( ) const
protectedvirtual

Second Euler angle for rotation over (intermediate) x.

Definition at line 325 of file MPositionable.h.

template<class Config >
utl::CoordinateSystemPtr det::MPositionable< Config >::GetLocalCoordinateSystem ( ) const
template<class Config >
utl::Point det::MPositionable< Config >::GetPosition ( ) const
template<class Config>
virtual utl::CoordinateSystemPtr det::MPositionable< Config >::GetReferenceCoordinateSystem ( ) const
privatepure virtual

Coordinate system of reference wrt which the components are expressed. This pure virtual method acts as a hook by which deriving classes determine a reference coordinate system from which refer the coordinates.

Implemented in mdet::Module, mdet::Scintillator, mdet::Fiber, and mdet::Counter.

Member Data Documentation

template<class Config>
utl::ShadowPtr<double> det::MPositionable< Config >::fComponent1
mutableprivate

Cached data. Hold pointer to the data resolved by the respective calls to GetData. Note the usage of mutable, that goes along the caching meaning. Note that for the coordinate-system was is actually stored is computed from the calls to the here-defined GetXXX functions.

Definition at line 267 of file MPositionable.h.

template<class Config>
utl::ShadowPtr<double> det::MPositionable< Config >::fComponent2
mutableprivate

Definition at line 268 of file MPositionable.h.

template<class Config>
utl::ShadowPtr<double> det::MPositionable< Config >::fComponent3
mutableprivate

Definition at line 269 of file MPositionable.h.

template<class Config>
const Config& det::MPositionable< Config >::fConfig
private

Hold a reference to the configuration proxy.

Definition at line 277 of file MPositionable.h.

template<class Config>
utl::ShadowPtr<CoordinateType> det::MPositionable< Config >::fCoordinateType
mutableprivate

Definition at line 273 of file MPositionable.h.

template<class Config>
utl::ShadowPtr<double> det::MPositionable< Config >::fEulerPhi
mutableprivate

Definition at line 270 of file MPositionable.h.

template<class Config>
utl::ShadowPtr<double> det::MPositionable< Config >::fEulerPsi
mutableprivate

Definition at line 272 of file MPositionable.h.

template<class Config>
utl::ShadowPtr<double> det::MPositionable< Config >::fEulerTheta
mutableprivate

Definition at line 271 of file MPositionable.h.

template<class Config>
utl::CoordinateSystemPtr det::MPositionable< Config >::fLocalCoordinateSystem
mutableprivate

Definition at line 274 of file MPositionable.h.

template<class Config>
const std::string det::MPositionable< Config >::kComponent1Tag = "positionComponent1"
staticprotected

Tag for first vector component in config.

Definition at line 145 of file MPositionable.h.

template<class Config>
const std::string det::MPositionable< Config >::kComponent2Tag = "positionComponent2"
staticprotected

Tag for second vector component in config.

Definition at line 147 of file MPositionable.h.

template<class Config>
const std::string det::MPositionable< Config >::kComponent3Tag = "positionComponent3"
staticprotected

Tag for third vector component in config.

Definition at line 149 of file MPositionable.h.

template<class Config>
const std::string det::MPositionable< Config >::kCoordinateTypeTag = "coordinateType"
staticprotected

Tag for coordinate type selection. This tag defines the meaning of the three components.

See Also
utl::BasicVector::CoordinateType

Definition at line 143 of file MPositionable.h.

template<class Config>
const std::string det::MPositionable< Config >::kEulerPhiTag = "eulerPhi"
staticprotected

Tag for first rotation's Euler angle in config.

Definition at line 151 of file MPositionable.h.

template<class Config>
const std::string det::MPositionable< Config >::kEulerPsiTag = "eulerPsi"
staticprotected

Tag for third rotation's Euler angle in config.

Definition at line 155 of file MPositionable.h.

template<class Config>
const std::string det::MPositionable< Config >::kEulerThetaTag = "eulerTheta"
staticprotected

Tag for second rotation's Euler angle in config.

Definition at line 153 of file MPositionable.h.


The documentation for this class was generated from the following file:

, generated on Tue Sep 26 2023.