CMS 3D CMS Logo

Public Types | Public Member Functions | Static Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes

DDObject< T > Class Template Reference

#include <DDObject.h>

List of all members.

Public Types

typedef
RegistryType::const_iterator 
const_iterator
typedef RegistryType::iterator iterator
 iterator
typedef Ptr< Tpointer
typedef DDRegistry< pointerRegistryType
 std::maps a DDName to the pointer to be wrapped

Public Member Functions

 DDObject ()
 unitialized, anonymous object
 DDObject (const DDName &name)
 initialized (named) object
 DDObject (DDName *)
 named object, implemenation derived from DDName & thus provides the name
 DDObject (const DDName &, T *)
 initialized (named) object, implementation provided by T*
const DDNamename () const
 anonymous (un-named) object
 operator bool () const
Toperator* ()
const Toperator* () const
Toperator-> ()
const Toperator-> () const

Static Public Member Functions

static iterator begin ()
static iterator end ()

Private Member Functions

void init ()
void registerAnoObject (const DDName &name, T *object)
void registerObject (const DDName &name, T *object)

Static Private Member Functions

static RegistryTypeanoRegistry ()
 static registry for anonymous pointers (un-named pointers)
static RegistryTyperegistry ()
 the static registry for the wrapped pointer

Private Attributes

RegistryType::iterator rep_
 representation of the wrapped object is a pointer into a registry-std::map

Detailed Description

template<class T>
class DDObject< T >

Definition at line 15 of file DDObject.h.


Member Typedef Documentation

template<class T >
typedef RegistryType::const_iterator DDObject< T >::const_iterator

Definition at line 24 of file DDObject.h.

template<class T >
typedef RegistryType::iterator DDObject< T >::iterator

iterator

Definition at line 22 of file DDObject.h.

template<class T >
typedef Ptr<T> DDObject< T >::pointer

Definition at line 18 of file DDObject.h.

template<class T >
typedef DDRegistry<pointer> DDObject< T >::RegistryType

std::maps a DDName to the pointer to be wrapped

Definition at line 20 of file DDObject.h.


Constructor & Destructor Documentation

template<class T >
DDObject< T >::DDObject ( )

unitialized, anonymous object

Definition at line 94 of file DDObject.h.

: rep_(registry().end()) 
 { }
template<class T >
DDObject< T >::DDObject ( const DDName name) [explicit]

initialized (named) object

Definition at line 100 of file DDObject.h.

{ 
  registerObject(name,(T*)0);
}
template<class T >
DDObject< T >::DDObject ( const DDName name,
T object 
)

initialized (named) object, implementation provided by T*

Definition at line 107 of file DDObject.h.

{ 
   registerObject(name,object);
}
template<class T >
DDObject< T >::DDObject ( DDName object) [explicit]

named object, implemenation derived from DDName & thus provides the name

Definition at line 124 of file DDObject.h.

{ 
  // Loki compile time check whether T is sub-classed from DDName
  //SUPERSUBCLASS(DDName,T);
  registerObject(*object,static_cast<T*>(object));
}

Member Function Documentation

template<class T >
static RegistryType& DDObject< T >::anoRegistry ( ) [inline, static, private]

static registry for anonymous pointers (un-named pointers)

Definition at line 81 of file DDObject.h.

  {
    static RegistryType reg_;
    return reg_;
  }
template<class T >
static iterator DDObject< T >::begin ( void  ) [inline, static]

Definition at line 61 of file DDObject.h.

References DDObject< T >::registry().

{ return registry().begin(); }
template<class T >
static iterator DDObject< T >::end ( void  ) [inline, static]

Definition at line 63 of file DDObject.h.

References DDObject< T >::registry().

Referenced by DDObject< T >::operator bool().

{ return registry().end();}
template<class T >
void DDObject< T >::init ( ) [private]
template<class T >
const DDName & DDObject< T >::name ( ) const

anonymous (un-named) object

the name of the wrapped object

Definition at line 156 of file DDObject.h.

{
  //static DDName name_;
  return rep_->first;   
}
template<class T >
DDObject< T >::operator bool ( ) const [inline]

Definition at line 53 of file DDObject.h.

References DDObject< T >::end(), DDObject< T >::registry(), and DDObject< T >::rep_.

  {
    if (rep_ != registry().end()) {
      return bool(rep_->second);
    }
    throw DDException("unbound DDObject, typeid.name="+std::string(typeid(*rep_->second).name()));
  }; 
template<class T >
const T & DDObject< T >::operator* ( void  ) const

Definition at line 164 of file DDObject.h.

{
   return *(rep_->second);      
}
template<class T >
T & DDObject< T >::operator* ( void  )

Definition at line 171 of file DDObject.h.

{
  return *(rep_->second);
}
template<class T >
const T * DDObject< T >::operator-> ( ) const

Definition at line 178 of file DDObject.h.

{
        return &(*rep_->second);
}
template<class T >
T * DDObject< T >::operator-> ( )

Definition at line 185 of file DDObject.h.

{
        return &(*rep_->second);
}
template<class T >
void DDObject< T >::registerAnoObject ( const DDName name,
T object 
) [private]

Definition at line 145 of file DDObject.h.

References query::result.

{
  std::pair<typename RegistryType::iterator,bool> result 
    = anoRegistry().insert(typename RegistryType::value_type(name,pointer(object)));
  if (!result.second) {
    result.first->second = pointer(object);
  }
  rep_ = result.first; 
}
template<class T >
void DDObject< T >::registerObject ( const DDName name,
T object 
) [private]

Definition at line 133 of file DDObject.h.

References PhysicsTools::registry, and query::result.

{
  std::pair<typename RegistryType::iterator,bool> result 
    = registry().insert(typename RegistryType::value_type(name,pointer(object)));
  if (!result.second) {
    result.first->second = pointer(object);
  }
  rep_ = result.first; 
}
template<class T >
static RegistryType& DDObject< T >::registry ( ) [inline, static, private]

the static registry for the wrapped pointer

Definition at line 74 of file DDObject.h.

Referenced by DDObject< T >::begin(), DDObject< T >::end(), and DDObject< T >::operator bool().

  {
    static RegistryType reg_;
    return reg_;
  };

Member Data Documentation

template<class T >
RegistryType::iterator DDObject< T >::rep_ [private]

representation of the wrapped object is a pointer into a registry-std::map

Definition at line 88 of file DDObject.h.

Referenced by DDObject< T >::operator bool().