From: <ob...@us...> - 2012-03-10 00:30:13
|
Revision: 1339 http://scstudio.svn.sourceforge.net/scstudio/?rev=1339&view=rev Author: obouda Date: 2012-03-10 00:30:07 +0000 (Sat, 10 Mar 2012) Log Message: ----------- refactored out EventArea::m_previous Modified Paths: -------------- branches/refactoring/src/data/msc.cpp branches/refactoring/src/data/msc.h Modified: branches/refactoring/src/data/msc.cpp =================================================================== --- branches/refactoring/src/data/msc.cpp 2012-03-10 00:20:17 UTC (rev 1338) +++ branches/refactoring/src/data/msc.cpp 2012-03-10 00:30:07 UTC (rev 1339) @@ -558,10 +558,6 @@ void Instance::add_area(EventAreaPtr area) { - if(!is_empty()) - { - area->m_previous = get_last().get(); - } m_event_areas.push_back(boost::intrusive_ptr<EventArea>(area)); area->set_instance(this); } Modified: branches/refactoring/src/data/msc.h =================================================================== --- branches/refactoring/src/data/msc.h 2012-03-10 00:20:17 UTC (rev 1338) +++ branches/refactoring/src/data/msc.h 2012-03-10 00:30:07 UTC (rev 1339) @@ -2427,14 +2427,6 @@ */ class SCMSC_EXPORT EventArea : public MscElementTmpl<EventArea> { -public: - /** - * Previous EventArea - * - * @warning boost::intrusive_ptr mustn't be used because of possible cyclic dependency - */ - EventArea* m_previous; - protected: Coordinate m_begin_height; @@ -2452,7 +2444,6 @@ public: EventArea() : MscElementTmpl<EventArea>(), - m_previous(NULL), m_begin_height(0), m_end_height(0), m_width(10), @@ -2464,7 +2455,6 @@ * Constructor. */ EventArea(EventArea* original) : MscElementTmpl<EventArea>(original), - m_previous(NULL), m_begin_height(original->m_begin_height), m_end_height(original->m_end_height), m_width(original->m_width), @@ -2499,10 +2489,24 @@ /** * Returns the previous event area on the same instance, or intrusive NULL-pointer if this is the first one. + * TODO: refactor out usages of this method where possible, use iteration instead */ EventArea* get_previous_area() const { - return m_previous; + const EventAreaPtrList event_areas = get_instance()->get_areas(); + for (EventAreaPtrList::const_reverse_iterator i = event_areas.rbegin(); i != event_areas.rend(); ++i) { + if (i->get() == this) { + ++i; + if (i == event_areas.rend()) { + return NULL; // this is the first event area on the instance + } + else { + return i->get(); + } + } + } + assert(false); // the event area should always be present in the event area list of the instance + return NULL; } /** @@ -2569,7 +2573,7 @@ /** * Adds event into this area. The added event is returned. */ - virtual EventPtr add_event()=0; + virtual EventPtr add_event() = 0; }; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |