CMS 3D CMS Logo

Public Types | Public Member Functions | Protected Member Functions | Protected Attributes

DDDefaultNumberingScheme Class Reference

Default numbering scheme. More...

#include <DDNumberingScheme.h>

Inheritance diagram for DDDefaultNumberingScheme:
DDNumberingScheme

List of all members.

Public Types

typedef DDNumberingScheme::nav_type nav_type

Public Member Functions

 DDDefaultNumberingScheme (const DDExpandedView &e)
 DDDefaultNumberingScheme (const DDFilteredView &f)
virtual int id (const DDExpandedView &) const
 calculate the id of a given node
virtual int id (const DDNumberingScheme::nav_type &) const
 calculate the id of a given node
virtual int id (const DDFilteredView &) const
 calculate the id of a given node
virtual bool node (int id, DDFilteredView &view) const
 calculate the node given an id
virtual bool node (int id, DDExpandedView &view) const
 calculate the node given an id
virtual ~DDDefaultNumberingScheme ()

Protected Member Functions

DDNumberingScheme::nav_type idToNavType (int id) const

Protected Attributes

std::vector< std::map
< nav_type, int >::iterator > 
id2path_
std::map< nav_type, int > path2id_

Detailed Description

Default numbering scheme.

implements a default - numbering scheme throws an DDException when it fails ...

Definition at line 54 of file DDNumberingScheme.h.


Member Typedef Documentation

Reimplemented from DDNumberingScheme.

Definition at line 57 of file DDNumberingScheme.h.


Constructor & Destructor Documentation

DDDefaultNumberingScheme::DDDefaultNumberingScheme ( const DDExpandedView e)

Definition at line 11 of file DDNumberingScheme.cc.

References prof2calltree::count, alignCSCRings::e, id2path_, DDExpandedView::navPos(), DDExpandedView::next(), path2id_, and DDExpandedView::reset().

{ 
  // extremely memory consuming & slow.
  
  /* - assign a node-number (from 0, ...) to every node in the view
     - save the node-number in a map, key is the stack of sibling-numbers of the node
       -> enables node to id calculation (slow O(log(max. node-number))).
     - save in a std::vector the stack of sibling-numbers; index in the std::vector is the
       assigned node number -> enables id to node calculation (fast)  
  */   
  typedef std::map<nav_type,int>::iterator m_it;
  
  DDExpandedView e = ex;
  e.reset();
  bool go = true;
  int count = 0;
  while (go) {
    std::pair<m_it,bool> res = path2id_.insert(std::make_pair(e.navPos(),count));
    id2path_.push_back(res.first);
    ++count;
    go = e.next();
  }
}
DDDefaultNumberingScheme::DDDefaultNumberingScheme ( const DDFilteredView f)

Definition at line 36 of file DDNumberingScheme.cc.

References prof2calltree::count, f, id2path_, DDFilteredView::navPos(), DDFilteredView::next(), path2id_, and DDFilteredView::reset().

{ 
  // very memory consuming & slow, depending on the amount of nodes
  // selected by the FilteredView; same algorithm then in ctor above
  typedef std::map<nav_type,int>::iterator m_it;
  
  DDFilteredView f = fv;
  f.reset();
  bool go = true;
  int count = 0;
  while (go) {
    std::pair<m_it,bool> res = path2id_.insert(std::make_pair(f.navPos(),count));
    id2path_.push_back(res.first);
    ++count;
    go = f.next();
  }
}
DDDefaultNumberingScheme::~DDDefaultNumberingScheme ( ) [virtual]

Definition at line 55 of file DDNumberingScheme.cc.

{ }

Member Function Documentation

int DDDefaultNumberingScheme::id ( const DDExpandedView e) const [virtual]

calculate the id of a given node

Implements DDNumberingScheme.

Definition at line 59 of file DDNumberingScheme.cc.

References DDExpandedView::navPos().

Referenced by id(), and idToNavType().

{
  return id(e.navPos());
}
int DDDefaultNumberingScheme::id ( const DDNumberingScheme::nav_type n) const [virtual]

calculate the id of a given node

Implements DDNumberingScheme.

Definition at line 71 of file DDNumberingScheme.cc.

References path2id_, and query::result.

{
  std::map<nav_type,int>::const_iterator it = path2id_.find(n);
  int result = -1;
  if (it != path2id_.end())
    result = it->second;
  return result;  
}
int DDDefaultNumberingScheme::id ( const DDFilteredView f) const [virtual]

calculate the id of a given node

Implements DDNumberingScheme.

Definition at line 65 of file DDNumberingScheme.cc.

References id(), and DDFilteredView::navPos().

{
 return id(f.navPos());
}
DDNumberingScheme::nav_type DDDefaultNumberingScheme::idToNavType ( int  id) const [protected]

Definition at line 95 of file DDNumberingScheme.cc.

References id(), id2path_, pos, and query::result.

Referenced by node().

{ 
  std::vector<int>::size_type pos = id;
  nav_type result;
  if ( (id>=(int)id2path_.size()) || ( id < 0) ) 
    ;
     
  else {
    std::map<nav_type,int>::iterator it = id2path_[pos];
    result = it->first;
  }
  return result;
}
bool DDDefaultNumberingScheme::node ( int  id,
DDFilteredView view 
) const [virtual]

calculate the node given an id

returns true, if a node was found. view then corresponds to this node.

Implements DDNumberingScheme.

Definition at line 87 of file DDNumberingScheme.cc.

References DDFilteredView::goTo(), and idToNavType().

{
 edm::LogError("DDNumberingScheme") << "DDDefaultNumberingScheme::node(int,DDFilteredView&) NOT IMPLEMENTED!" 
           << std::endl;
 return view.goTo(idToNavType(id));
}
bool DDDefaultNumberingScheme::node ( int  id,
DDExpandedView view 
) const [virtual]

calculate the node given an id

returns true, if a node was found. view then corresponds to this node.

Implements DDNumberingScheme.

Definition at line 81 of file DDNumberingScheme.cc.

References DDExpandedView::goTo(), and idToNavType().

{
 return view.goTo(idToNavType(id));
}

Member Data Documentation

std::vector<std::map<nav_type,int>::iterator> DDDefaultNumberingScheme::id2path_ [protected]

Definition at line 88 of file DDNumberingScheme.h.

Referenced by DDDefaultNumberingScheme(), and idToNavType().

std::map<nav_type,int> DDDefaultNumberingScheme::path2id_ [protected]

Definition at line 87 of file DDNumberingScheme.h.

Referenced by DDDefaultNumberingScheme(), and id().