![]() |
![]() |
#include <Iguana/Framework/interface/IgRepContext.h>
Public Member Functions | |
void | erase (bool zap) |
Disengage the rep context from both the IgRep and the IgRepSet, optionally deleting the IgRep. | |
IgRepContext (IgRepresentable *object, IgRep *rep) | |
IgRepContext (IgRepSet *set, IgRep *rep) | |
Construct a new representation context. | |
IgModel * | model (void) const |
Get the model in which the rep belongs to. | |
IgRepContext * | next (void) const |
Get the next context in the circular list. | |
IgRepresentable * | object (void) const |
Get the object the rep belongs to. | |
IgRep * | rep (void) const |
Get the rep owned by the context. | |
IgRepSet * | set (void) const |
Get the set belonging to the object that rep represents. | |
~IgRepContext (void) | |
Destruct a rep context. | |
Private Member Functions | |
void | chain (IgRepContext *next) |
Chain or unchain the context in the circular list. | |
IgRepContext (const IgRepContext &) | |
IgRepContext & | operator= (const IgRepContext &) |
Private Attributes | |
IgRepContext * | m_next |
Pointer to the next context in the chain. | |
IgRep * | m_rep |
Pointer to the IgRep. | |
IgRepSet * | m_set |
Pointer to the set owning this context. | |
Friends | |
class | IgRepSet |
IgRepSet for a IgRepresentable consists of circular list of these context objects, one for each distinct IgModel in which the representable object is represented. This object is the multi-way association linking IgRep, IgModel and IgRepSet together. Through the IgRepSet link the original application object is also accessible.
The client must create a rep and a context exactly as follows to guarantee that the rep and context are properly registered in the IgRepSet of the application object:
If the IgRepresentable or the IgRepSet are destroyed, all their IgRepContext objects are also destroyed. This will cause the IgRep to be destroyed as well. If the IgRep is destroyed for any other reason, it must take care to destroy its context object as well. The exact patterns in which these must be done are described in IgRep documentation.
Note that it is not permissible to create a rep that inherits both IgRep and IgRepContext. (FIXME: Killed by non-virtual destructor which is invoked by the IgRepSet -- need to arrange for more flexible erasure patterns.)
Definition at line 54 of file IgRepContext.h.
Construct a new representation context.
You can specify either the object that the rep belongs to, or its IgRepSet.
Definition at line 96 of file IgRepContext.h.
References ASSERT, IgRep::context(), m_next, and IgRep::model().
00097 : m_next (0), 00098 m_set (set), 00099 m_rep (rep) 00100 { 00101 ASSERT (set); 00102 ASSERT (rep); 00103 ASSERT (rep->model ()); 00104 00105 set->add (this); 00106 ASSERT (m_next); 00107 rep->context (this); 00108 }
IgRepContext::IgRepContext | ( | IgRepresentable * | object, | |
IgRep * | rep | |||
) | [inline] |
Definition at line 112 of file IgRepContext.h.
References IgRepSet::add(), ASSERT, IgRep::context(), m_next, m_set, and IgRep::model().
00113 : m_next (0), 00114 m_set (IgRepSet::associate (object, true)), 00115 m_rep (rep) 00116 { 00117 ASSERT (m_set); 00118 ASSERT (rep); 00119 ASSERT (rep->model ()); 00120 00121 m_set->add (this); 00122 ASSERT (m_next); 00123 rep->context (this); 00124 }
IgRepContext::~IgRepContext | ( | void | ) | [inline] |
Destruct a rep context.
See the class documentation for the destruction protocol.
The internals are as follows. If IgRepSet is destroying the context (the application object is dying), m_set is set and we remove ourselves from it; this will cause chain() to be invoked in a manner that clears m_set. We also delete the IgRep; see the destruction protocol documentation in IgRep for more details on writing the destructor correctly. If the IgRep is destroying the context, it will already have invoked erase(), which has detached myself from the IgRepSet, m_set is null and there is nothing to do here.
Definition at line 140 of file IgRepContext.h.
References ASSERT, erase(), m_next, m_rep, and m_set.
00141 { 00142 if (m_set) erase (true); 00143 ASSERT (! m_set); 00144 ASSERT (! m_next); 00145 ASSERT (! m_rep); 00146 }
IgRepContext::IgRepContext | ( | const IgRepContext & | ) | [private] |
void IgRepContext::chain | ( | IgRepContext * | next | ) | [inline, private] |
Chain or unchain the context in the circular list.
This method is used both internally and by the IgRepSet.
next | If null, indicates that the context is being detached from the set. If set, just sets the next pointer to that value. Note that since the list is singly linked, the caller must ensure that previous context is updated appropriately. The caller must also ensure that the list remains circular. |
Definition at line 234 of file IgRepContext.h.
Referenced by IgRepSet::add(), and IgRepSet::remove().
Disengage the rep context from both the IgRep and the IgRepSet, optionally deleting the IgRep.
This method is used both internally (see the for details) and by #IgRep implementations. The latter must call this method with false
argument before destroying the context. zap Pass true
if the #IgRep should be destroyed. Otherwise the context will just disengage from it.
Definition at line 158 of file IgRepContext.h.
References ASSERT, m_next, m_rep, m_set, IgRepSet::remove(), and rep().
Referenced by Ig3DBaseRep::~Ig3DBaseRep(), IgQtTreeRep::~IgQtTreeRep(), IgQtTwigRep::~IgQtTwigRep(), ~IgRepContext(), IgSimpleTextRep::~IgSimpleTextRep(), IgUIDRep::~IgUIDRep(), IgXMLRep::~IgXMLRep(), and VisRootRep::~VisRootRep().
00159 { 00160 // If we are being killed by the IgRepresentable, on first call 00161 // (called from ~IgRepContext) zap will be true, we disengage from 00162 // the set; on the second call (from ~IgRep) zap will be false, do 00163 // nothing. 00164 // 00165 // If we are getting called from ~IgRep, zap will be false, we 00166 // disengage from the set and do not destroy the rep. 00167 00168 // Check that we are indeed in one of the three above cases. 00169 ASSERT ((m_set && !zap && m_rep) // From ~IgRep: must still have rep 00170 || (m_set && zap && m_rep) // 1st round: must zap and have rep 00171 || (!m_set && !zap && !m_rep)); // 2nd round: no zap, no rep 00172 00173 // Remove from the set if still necessary 00174 if (m_set) 00175 m_set->remove (this); 00176 ASSERT (! m_set); 00177 ASSERT (! m_next); 00178 00179 // Get rid of rep -- null it out and possibly also delete it 00180 IgRep *rep = m_rep; 00181 m_rep = 0; 00182 if (zap) 00183 delete rep; 00184 }
Get the model in which the rep belongs to.
Definition at line 211 of file IgRepContext.h.
References m_rep, and IgRep::model().
Referenced by IgRepSet::invalidate(), and IgRepSet::lookup().
IgRepContext * IgRepContext::next | ( | void | ) | const [inline] |
Get the next context in the circular list.
Definition at line 188 of file IgRepContext.h.
References m_next.
Referenced by IgRepSet::add(), IgRepSet::invalidate(), IgRepSet::lookup(), IgRepSet::remove(), and IgRepSet::update().
00189 { 00190 return m_next; 00191 }
IgRepresentable * IgRepContext::object | ( | void | ) | const [inline] |
Get the object the rep belongs to.
Definition at line 218 of file IgRepContext.h.
References m_set, and IgRepSet::object().
Referenced by IgWebTreeService::browse(), IgQtTwigRep::check(), IgRepSet::invalidate(), IgRepSet::lookup(), IgQtTreeRep::setOpen(), IgQtTwigRep::setOpen(), IgWebTreeService::twigMenu(), and IgRepSet::update().
IgRepContext& IgRepContext::operator= | ( | const IgRepContext & | ) | [private] |
Get the rep owned by the context.
Definition at line 204 of file IgRepContext.h.
References m_rep.
Referenced by erase(), IgRepSet::lookup(), IgRepSet::update(), Ig3DBaseRep::~Ig3DBaseRep(), IgQtTreeRep::~IgQtTreeRep(), IgQtTwigRep::~IgQtTwigRep(), IgSimpleTextRep::~IgSimpleTextRep(), IgUIDRep::~IgUIDRep(), IgXMLRep::~IgXMLRep(), and VisRootRep::~VisRootRep().
00205 { 00206 return m_rep; 00207 }
Get the set belonging to the object that rep represents.
The set is the owner of this object.
Definition at line 197 of file IgRepContext.h.
References m_set.
00198 { 00199 return m_set; 00200 }
friend class IgRepSet [friend] |
Definition at line 70 of file IgRepContext.h.
IgRepContext* IgRepContext::m_next [private] |
Pointer to the next context in the chain.
Note that the list is circular so it may point back to this object, meaning that there are no other contexts in the list.
Definition at line 73 of file IgRepContext.h.
Referenced by chain(), erase(), IgRepContext(), next(), and ~IgRepContext().
IgRep* IgRepContext::m_rep [private] |
Pointer to the IgRep.
Definition at line 83 of file IgRepContext.h.
Referenced by erase(), model(), rep(), and ~IgRepContext().
IgRepSet* IgRepContext::m_set [private] |
Pointer to the set owning this context.
The set is uniquely linked with actual IgRepresentable.
Definition at line 79 of file IgRepContext.h.
Referenced by chain(), erase(), IgRepContext(), object(), set(), and ~IgRepContext().