CMS 3D CMS Logo

IgRepSet Class Reference

The set of known representations of an object. More...

#include <Iguana/Framework/interface/IgRepSet.h>

List of all members.

Public Member Functions

void add (IgRepContext *context)
 Add a new rep context context to the set.
IgRepContextcontexts (void) const
 Get the circular list of rep contexts.
IgRepContextlookup (IgModel *model) const
 Look for a context for the object and model in this set.
IgRepresentableobject (void) const
 Get the object that this set belongs to.
void remove (IgRepContext *context)
 Remove the context from this set.
 ~IgRepSet (void)
 Destroy the representation set, and thus all rep contexts and reps attached to it.

Static Public Member Functions

static IgRepSetassociate (IgRepresentable *object, bool create=false)
 Get a rep set for the object.
static void invalidate (IgRepresentable *object, IgModel *model, unsigned field)
 Invalidate representations of object only in model.
static void invalidate (IgRepContext *context, unsigned field)
 Invalidate representations of object in all other models except the one context belongs to.
static void invalidate (IgRepresentable *object, unsigned field)
 Invalidate all representations of object.
static IgReplookup (IgRepContext *context, IgModel *model, bool create=false)
 Look up a for a context matching model, starting from context but ignoring context itself.
static IgReplookup (IgRepresentable *object, IgModel *model, bool create=false)
 Look up a representation for object in model.
static void update (IgRepresentable *object, IgModel *model, unsigned field)
 Update the object rep for model if one exists.
static void update (IgRepContext *context, unsigned field)
 Update all existing reps in the same chain as context, except context itself.
static void update (IgRepresentable *object, unsigned field)
 Update all existing representations of object, using field as details (arbitrary information).

Protected Member Functions

 IgRepSet (IgRepresentable *object)
 Create a new empty representation set for the object.

Private Types

typedef std::map
< IgRepresentable *, IgRepSet * > 
LookupTable

Private Member Functions

 IgRepSet (const IgRepSet &)
IgRepSetoperator= (const IgRepSet &)

Static Private Member Functions

static LookupTabletable (void)
 Return the rep set table.

Private Attributes

IgRepContextm_first
 Pointer to the first context in the circular singly-linked list.
IgRepresentablem_object
 Pointer to the IgRepresentable this set describes.


Detailed Description

The set of known representations of an object.

The set consists of a singly linked circular list of IgRepContext objects. The contexts record the representations that have been created for the IgRepresentable, connecting the object and the location of its representation in a browsing model. The context list establishes the back bone of navigation across models and of communication across browsers.

Note:
IgRepSet is never created directly. It comes to existence only when a IgReprsentable is associated with a IgRep.

Definition at line 33 of file IgRepSet.h.


Member Typedef Documentation

typedef std::map<IgRepresentable *, IgRepSet *> IgRepSet::LookupTable [private]

Definition at line 73 of file IgRepSet.h.


Constructor & Destructor Documentation

IgRepSet::~IgRepSet ( void   ) 

Destroy the representation set, and thus all rep contexts and reps attached to it.

Definition at line 34 of file IgRepSet.cc.

References m_first, m_object, table(), and VERIFY.

00035 {
00036     VERIFY (table ().erase (m_object) == 1);
00037 
00038     // Get rid of contexts
00039     while (m_first)
00040         delete m_first;
00041 }

IgRepSet::IgRepSet ( IgRepresentable object  )  [protected]

Create a new empty representation set for the object.

Definition at line 27 of file IgRepSet.cc.

Referenced by associate().

00028     : m_object (object),
00029       m_first (0)
00030 {}

IgRepSet::IgRepSet ( const IgRepSet  )  [private]


Member Function Documentation

void IgRepSet::add ( IgRepContext context  ) 

Add a new rep context context to the set.

Adds context to the circular list of contexts.

Definition at line 46 of file IgRepSet.cc.

References ASSERT, IgRepContext::chain(), prof2calltree::last, m_first, and IgRepContext::next().

Referenced by IgRepContext::IgRepContext().

00047 {
00048     ASSERT (context);
00049     ASSERT (context != m_first);
00050 
00051     if (! m_first)
00052     {
00053         context->chain (context);
00054         m_first = context;
00055     }
00056     else
00057     {
00058         IgRepContext *last = m_first;
00059         while (last->next () != m_first)
00060         {
00061             ASSERT (last->next () != context);
00062             last = last->next ();
00063         }
00064         context->chain (m_first);
00065         last->chain (context);
00066     }
00067 }

IgRepSet * IgRepSet::associate ( IgRepresentable object,
bool  create = false 
) [static]

Get a rep set for the object.

Returns the set if it exists. Otherwise, if create is true, makes a new set and returns that. Otherwise returns a null pointer.

Definition at line 132 of file IgRepSet.cc.

References ASSERT, IgRepSet(), and table().

Referenced by lookup(), update(), and IgRepresentable::~IgRepresentable().

00133 {
00134     LookupTable &lookup_table = table ();
00135     LookupTable::iterator pos = lookup_table.find (object);
00136 
00137     if (pos != lookup_table.end ())
00138     {
00139         ASSERT (pos->second);
00140         return pos->second;
00141     }
00142     else if (create)
00143     {
00144         IgRepSet *&set = lookup_table [object];
00145         set = new IgRepSet (object);
00146         return set;
00147     }
00148     else
00149         return 0;
00150 }

IgRepContext * IgRepSet::contexts ( void   )  const [inline]

Get the circular list of rep contexts.

Definition at line 100 of file IgRepSet.h.

References m_first.

00101 { return m_first; }

void IgRepSet::invalidate ( IgRepresentable object,
IgModel model,
unsigned  field 
) [static]

Invalidate representations of object only in model.

See the other invalidate() methods for more details.

Definition at line 272 of file IgRepSet.cc.

References IgBrowserMethods::invalidate().

00273 {
00274     IgBrowserMethods::invalidate (object, model, field);
00275 }

void IgRepSet::invalidate ( IgRepContext context,
unsigned  field 
) [static]

Invalidate representations of object in all other models except the one context belongs to.

See the other invalidate() methods for more details.

Definition at line 260 of file IgRepSet.cc.

References IgBrowserMethods::invalidate(), IgRepContext::model(), IgRepContext::next(), and IgRepContext::object().

00261 {
00262     IgRepContext        *next = context->next ();
00263     IgRepresentable     *object = context->object ();
00264 
00265     for ( ; next != context; next = next->next ())
00266         IgBrowserMethods::invalidate (object, next->model (), field);
00267 }

void IgRepSet::invalidate ( IgRepresentable object,
unsigned  field 
) [static]

Invalidate all representations of object.

Use this method to indicate that object has been changed in ways that require reps to be updated. Unlike update(), this method does the right thing by processing the object, recursively if necessary, to make sure every existing outdated representation is updated, and new ones are created as necessary. The main difference is that update() only handles reps that already exists -- it will not handle hierarchical objects correctly. invalidate() will call update() on all objects as necessary. It is recommended to always use this method to flag object updates. The field is arbitrary information passed down to IgBrowserMethods::invalidate() and eventually to IgBrowserMethods::update().

Definition at line 251 of file IgRepSet.cc.

References IgBrowserMethods::invalidate().

Referenced by VisG4TwigOps::actionAppearance(), VisG4TwigOps::actionApplyFilter(), VisG4TwigOps::actionColour(), IgTwigOps::actionEnable(), VisEventContentTwigOps::actionExpand(), IgTwigOps::actionHide(), VisG4TwigOps::actionLogical(), VisG4TwigOps::actionShowCategory(), VisG4TwigOps::actionShowMaterial(), VisG4TwigOps::actionTransparency(), IgTwigOps::actionVisible(), VisMuonEnergyTwig::configChanged(), VisEventIdTwig::configChanged(), VisTrackTwig::configChanged(), VisMuonTwig::configChanged(), VisTkRecTracksTwig::configChanged(), VisRefitTrackTwig::configChanged(), createThisTwig(), VisG4TrackPtTwig::cutChanged(), VisSimTrackTwig::cutChanged(), VisWebFrameworkService::doNextEvent(), VisG4TwigOps::doRender(), VisCuTkMapWindow::drawCluster(), VisCuTkMapWindow::drawDigi(), VisCuTkMapWindow::drawRechit(), VisCuTkMapWindow::drawSimHits(), VisG4MagFieldContent::init(), VisG4EventContent::init(), VisCuTkRecoContent::init(), VisG4GeomContent::init(), VisCMSMagFieldContent::init(), MMM_DEFUN_FUNC(), VisQueuedTwig::onBaseInvalidate(), VisPCaloHitTwig::onNewEvent(), VisTrackerRechit2DTwig::onNewEvent(), VisTkRecTracksTwig::onNewEvent(), VisCaloTowerTwig::onNewEvent(), VisTrackerClusterTwig::onNewEvent(), VisTrackerRechit2DMatchedTwig::onNewEvent(), VisPixelDigiTwig::onNewEvent(), VisCuTkGeometryTwig::onNewEvent(), VisTkSimHitTwig::onNewEvent(), VisPSimHitTwig::onNewEvent(), VisTrackerPiDigiTwig::onNewEvent(), VisCSCSeg2HETwig::onNewEvent(), VisBasicClusterCollectionTwig::onNewEvent(), VisGenJetCollectionTwig::onNewEvent(), VisSimVertexTwig::onNewEvent(), VisSuperClusterCollectionTwig::onNewEvent(), VisTrackerDigiTwig::onNewEvent(), VisGsfTrackTwig::onNewEvent(), VisRecoToolsTwig::onNewEvent(), VisCMSMagFieldTwig::onNewEvent(), VisMuonTwig::onNewEvent(), VisHepMCProductTwig::onNewEvent(), VisL1GlobalTriggerReadoutRecordTwig::onNewEvent(), VisHFDataFrameTwig::onNewEvent(), VisFEDRawDataCollectionTwig::onNewEvent(), VisEventContentTwig::onNewEvent(), VisCuTkSlWindow::repaintAll(), VisGenJetTwig::scaleChanged(), VisGenJetCollectionTwig::scaleChanged(), VisCandidateTwig::scaleChanged(), VisHcalDetTwig::scaleChanged(), Ig2DModel::setCutTransform(), VisApplicationMain::setup(), IgNTupleAppMain::setup(), VisSimMain::setup(), VisMagFieldDemoMain::setup(), VisGsfTrackTwig::twigChanged(), VisCaloJetTwig::twigChanged(), VisBasicClusterTwig::twigChanged(), VisTrackingRecHitTwig::twigChanged(), VisPSimHitTwig::twigChanged(), VisHORecHitTwig::twigChanged(), VisTrackerClusterTwig::twigChanged(), VisEcalUncalibratedRecHitTwig::twigChanged(), VisTrajectorySeedTwig::twigChanged(), VisTrackerRechit2DMatchedTwig::twigChanged(), VisTrackerRechit2DTwig::twigChanged(), VisHBHERecHitTwig::twigChanged(), VisSuperClusterTwig::twigChanged(), VisEcalRecHitTwig::twigChanged(), VisDetTextureTwig::twigChanged(), VisTrackerDigiTwig::twigChanged(), VisCaloTowerTwig::twigChanged(), VisHFRecHitTwig::twigChanged(), VisSuperClusterCollectionTwig::twigChanged(), VisBasicClusterCollectionTwig::twigChanged(), VisTkIdealHelixTracksTwig::twigChanged(), VisG4TracksTwig::update(), and VisG4GeometryTwig::update().

00252 {
00253     IgBrowserMethods::invalidate (object, 0, field);
00254 }

IgRepContext * IgRepSet::lookup ( IgModel model  )  const

Look for a context for the object and model in this set.

Returns the context object if one exists, otherwise null.

Definition at line 110 of file IgRepSet.cc.

References ASSERT, python::TagTree::context, m_first, IgRepContext::model(), and IgRepContext::next().

00111 {
00112     ASSERT (model);
00113 
00114     IgRepContext *context = m_first;
00115     do {
00116         if (! context)
00117             return 0;
00118 
00119         if (context->model () == model)
00120             return context;
00121 
00122         context = context->next ();
00123     } while (context != m_first);
00124 
00125     return 0;
00126 }

IgRep * IgRepSet::lookup ( IgRepContext context,
IgModel model,
bool  create = false 
) [static]

Look up a for a context matching model, starting from context but ignoring context itself.

Returns the IgRep if one exists. Otherwise if create is true, tries to make one for the object owning context with IgBrowserMethods::represent(). If that succeeds, returns the IgRep. Otherwise returns null.

Definition at line 174 of file IgRepSet.cc.

References ASSERT, IgRepContext::model(), IgRepContext::next(), IgRepContext::object(), IgRepContext::rep(), and IgBrowserMethods::represent().

00175 {
00176     IgRepContext *other = context->next ();
00177 
00178     while (other != context && other->model () != model)
00179         other = other->next ();
00180 
00181     if (other->model () == model)
00182         return other->rep ();
00183     else if (create)
00184     {
00185         other = IgBrowserMethods::represent (context->object (), model);
00186         ASSERT (! other || other->model () == model);
00187         ASSERT (! other || other->rep ());
00188 
00189     }
00190 
00191     return other ? other->rep () : 0;
00192 }

IgRep * IgRepSet::lookup ( IgRepresentable object,
IgModel model,
bool  create = false 
) [static]

Look up a representation for object in model.

Returns the IgRep if one exists. Otherwise if create is true, tries to make one with IgBrowserMethods::represent(). If that succeeds, returns the IgRep. Otherwise returns null.

Definition at line 157 of file IgRepSet.cc.

References associate(), python::TagTree::context, IgRepContext::rep(), and IgBrowserMethods::represent().

Referenced by IgQtTwigBrowser::browse(), IgWebTreeService::browse(), IgQtTextBrowser::browse(), Ig3DBaseBrowser::browse(), VisRootBrowser::browse(), VisHtmlRootBrowser::browse(), IgOIVBrowser::browse(), IgQtTreeBrowser::browse(), findRepresentedAncestor(), IgWebTreeService::getRepID(), MMM_DEFUN_FUNC(), postMake3DRep(), postMakeXMLRep(), preMake3DRep(), preMakeXMLRep(), Ig3DBaseBrowser::repMenu(), IgSpareWindow::repMenu(), IgLegoWindow::repMenu(), IgRPhiWindow::repMenu(), Ig3DWindow::repMenu(), IgRZWindow::repMenu(), IgQtTextBrowser::selectMessage(), Ig3DBaseBrowser::selectMessage(), IgQtTwigBrowser::selectMessage(), VisRootBrowser::selectMessage(), IgQtTreeBrowser::selectMessage(), VisQueuedTwig::update(), and update().

00158 {
00159     IgRepSet     *set = IgRepSet::associate (object, create);
00160     IgRepContext *context = set ? set->lookup (model) : 0;
00161 
00162     if (! context && create)
00163         context = IgBrowserMethods::represent (object, model);
00164 
00165     return context ? context->rep () : 0;
00166 }

IgRepresentable * IgRepSet::object ( void   )  const [inline]

Get the object that this set belongs to.

Definition at line 95 of file IgRepSet.h.

References m_object.

Referenced by IgRepContext::object().

00096 { return m_object; }

IgRepSet& IgRepSet::operator= ( const IgRepSet  )  [private]

void IgRepSet::remove ( IgRepContext context  ) 

Remove the context from this set.

Definition at line 71 of file IgRepSet.cc.

References ASSERT, IgRepContext::chain(), m_first, and IgRepContext::next().

Referenced by IgRepContext::erase().

00072 {
00073     ASSERT (m_first);
00074     ASSERT (context);
00075 
00076     IgRepContext *previous = m_first;
00077     IgRepContext *pos = m_first->next ();
00078 
00079     while (pos != context)
00080     {
00081         ASSERT (pos);
00082         previous = pos;
00083         pos = pos->next ();
00084     }
00085 
00086     ASSERT (pos == context);
00087     ASSERT (previous->next () == context);
00088 
00089     IgRepContext *next = pos->next ();
00090     if (previous == context)
00091     {
00092         // the list is only context long, and `context' is its only element
00093         ASSERT (m_first == context);
00094         ASSERT (m_first->next () == m_first);
00095         m_first = 0;
00096     }
00097     else
00098     {
00099         // unchain this context
00100         previous->chain (next);
00101         if (m_first == context)
00102             m_first = next;
00103     }
00104     context->chain (0);
00105 }

IgRepSet::LookupTable & IgRepSet::table ( void   )  [static, private]

Return the rep set table.

Definition at line 20 of file IgRepSet.cc.

Referenced by associate(), and ~IgRepSet().

00021 {
00022     static LookupTable table;
00023     return table;
00024 }

void IgRepSet::update ( IgRepresentable object,
IgModel model,
unsigned  field 
) [static]

Update the object rep for model if one exists.

The field is arbitrary information passed down to IgBrowserMethods::update(). You should normally use invalidate() methods instead of this one.

Definition at line 233 of file IgRepSet.cc.

References lookup(), and IgBrowserMethods::update().

00234 {
00235     if (IgRep *rep = lookup (object, model, false))
00236         IgBrowserMethods::update (object, rep, field);
00237 }

void IgRepSet::update ( IgRepContext context,
unsigned  field 
) [static]

Update all existing reps in the same chain as context, except context itself.

Each is updated using IgBrowserMethods::update(). The field is arbitrary information passed down to that method. You should normally use invalidate() methods instead of this one.

Definition at line 220 of file IgRepSet.cc.

References IgRepContext::next(), IgRepContext::object(), IgRepContext::rep(), and IgBrowserMethods::update().

00221 {
00222     IgRepContext        *next = context->next ();
00223     IgRepresentable     *object = context->object ();
00224 
00225     for ( ; next != context; next = next->next ())
00226         IgBrowserMethods::update (object, next->rep (), field);
00227 }

void IgRepSet::update ( IgRepresentable object,
unsigned  field 
) [static]

Update all existing representations of object, using field as details (arbitrary information).

Every existing rep of the object is updated using IgBrowserMethods::update(). You should normally use invalidate() methods instead of this one.

Definition at line 199 of file IgRepSet.cc.

References associate(), python::TagTree::context, first, IgRepContext::next(), IgRepContext::rep(), and IgBrowserMethods::update().

Referenced by IgWebTreeService::browse(), VisWebRootService::browse(), MMM_DEFUN_FUNC(), and VisG4ExampleSetup::setup().

00200 {
00201     // Check if the object has any representations
00202     IgRepSet *set = associate (object);
00203     if (! set)
00204         return;
00205 
00206     // Update all contexts
00207     IgRepContext *first = set->contexts ();
00208     IgRepContext *context = first;
00209 
00210     do
00211         IgBrowserMethods::update (object, context->rep (), field);
00212     while ((context = context->next ()) != first);
00213 }


Member Data Documentation

IgRepContext* IgRepSet::m_first [private]

Pointer to the first context in the circular singly-linked list.

Definition at line 79 of file IgRepSet.h.

Referenced by add(), contexts(), lookup(), remove(), and ~IgRepSet().

IgRepresentable* IgRepSet::m_object [private]

Pointer to the IgRepresentable this set describes.

Definition at line 76 of file IgRepSet.h.

Referenced by object(), and ~IgRepSet().


The documentation for this class was generated from the following files:
Generated on Tue Jun 9 18:25:37 2009 for CMSSW by  doxygen 1.5.4