|
From: <ma...@us...> - 2011-03-02 13:17:25
|
Revision: 1054
http://scstudio.svn.sourceforge.net/scstudio/?rev=1054&view=rev
Author: madzin
Date: 2011-03-02 13:17:18 +0000 (Wed, 02 Mar 2011)
Log Message:
-----------
Fix bug in diff algorithm concretly with crossing messages. Corect visio output messages.
Modified Paths:
--------------
trunk/src/membership/diff_impl.cpp
trunk/src/membership/membership_additional.cpp
trunk/src/membership/membership_base.h
trunk/src/view/visio/addon/document.cpp
trunk/tests/diff/CMakeLists.txt
Added Paths:
-----------
trunk/tests/diff/flow05_3.mpr
trunk/tests/diff/flow05_3.mpr.result
trunk/tests/diff/flow06_3.mpr
trunk/tests/diff/flow06_3.mpr.result
trunk/tests/diff/flow08_1.mpr
trunk/tests/diff/flow08_1.mpr.result
trunk/tests/diff/spec08.mpr
Modified: trunk/src/membership/diff_impl.cpp
===================================================================
--- trunk/src/membership/diff_impl.cpp 2011-02-28 17:35:32 UTC (rev 1053)
+++ trunk/src/membership/diff_impl.cpp 2011-03-02 13:17:18 UTC (rev 1054)
@@ -20,7 +20,8 @@
void process_diffrences(MembershipContext* c, BMscPtr dup_flow, const std::map<std::wstring, Difference*>& diff_map);
bool check_attributes(MembershipContext* c, BMscPtr specification, BMscPtr dup_flow);
bool check_matching_event_creation(std::map<std::wstring, std::list<Difference*> > insert_map, Difference* diff);
-std::map<std::wstring, std::list<Difference*> > create_insert_map(const std::map<std::wstring, Difference*>& diff_map);
+std::map<std::wstring, std::list<Difference*> > create_insert_map(MembershipContext* c,
+ const std::map<std::wstring, Difference*>& diff_map);
void print_result(BMscPtr msc)
{
@@ -87,6 +88,7 @@
//TODO refactoring flow BMSC get to MembershipContext and start to use it (not as the parameter)
MembershipContext* c = new MembershipContext();
c->set_mem(this);
+ c->set_diff_type(MESSAGE);
if (bmsc == NULL)
{
@@ -380,6 +382,8 @@
bool flow_found = false;
bool spec_found = false;
+for(int i = 0; i < 2; i++)
+{
for(all_inst_it = all_instances.begin(); all_inst_it != all_instances.end(); all_inst_it++)
{
spec_found = false;
@@ -473,10 +477,12 @@
//when the instance of proper name was found in both MSCs (specification, flow)
Difference* diff = instance_diff(c, *flow_it, *spec_it);
- if(diff != NULL)
+ if(i == 1 && diff != NULL)
diff_map.insert(std::make_pair((*flow_it)->get_label(), diff));
}
+}
+
if(!diff_map.empty())
{
process_diffrences(c, dup_flow, diff_map);
@@ -568,7 +574,7 @@
return s_e_a;
}
-void set_event_position(StrictEventPtr e, Difference* diff, std::wstring inst_name, BMscPtr flow)
+void set_event_position(StrictEventPtr e, StrictEventPtr location, std::wstring inst_name, BMscPtr flow)
{
InstancePtrList insts = flow->get_instances();
InstancePtrList::iterator it;
@@ -588,7 +594,7 @@
if(inst == NULL)
throw std::runtime_error("Error: unexpected behaviour");
- if(diff->getLocation() == NULL)
+ if(location == NULL)
{
start_p = MscPoint(0,0);
@@ -602,13 +608,13 @@
}
else
{
- start_p = diff->getLocation()->get_position();
- StrictEventPtr original_successor = diff->getLocation()->get_successor();
+ start_p = location->get_position();
+ StrictEventPtr original_successor = location->get_successor();
if(original_successor != NULL)
end_p = original_successor->get_position();
else
- end_p = MscPoint(start_p.get_x(), start_p.get_y()+10);
+ end_p = MscPoint(0, inst->get_line_end().get_y()-inst->get_line_begin().get_y());
}
double x = start_p.get_x() + (end_p.get_x() - start_p.get_x())/2;
@@ -629,7 +635,7 @@
void add_incomplete_message(MembershipContext* c, BMscPtr dup_flow, Difference* diff, IncompleteMessagePtr msg, std::wstring ins_name)
{
StrictEventPtr new_e = new StrictEvent();
- set_event_position(new_e, diff, ins_name, dup_flow);
+ set_event_position(new_e, diff->getLocation(), ins_name, dup_flow);
IncompleteMessagePtr new_msg = new IncompleteMessage(
msg->is_lost() ? LOST : FOUND,
@@ -646,60 +652,6 @@
set_identification(c, new_e.get(), msg->get_event());
}
-void add_complete_message(BMscPtr dup_flow, Difference* diff, Difference* match_diff,
- CompleteMessagePtr msg, std::wstring inst_name,
- std::wstring match_inst_name)
-{
- StrictEventPtr predecessor1 = diff->getLocation();
- StrictEventPtr predecessor2 = match_diff->getLocation();
-
- StrictOrderAreaPtr strict_e_a1, strict_e_a2;
-
- if(predecessor1 == NULL)
- strict_e_a1 = get_proper_area(dup_flow, diff, inst_name);
- else
- strict_e_a1 = predecessor1->get_area();
-
- if(predecessor2 == NULL)
- strict_e_a2 = get_proper_area(dup_flow, diff, match_inst_name);
- else
- strict_e_a2 = predecessor2->get_area();
-
- StrictEventPtr new_e1 = new StrictEvent();
- set_event_position(new_e1, diff, inst_name, dup_flow);
-
- StrictEventPtr new_e2 = new StrictEvent();
- set_event_position(new_e2, match_diff, match_inst_name, dup_flow);
-
- new_e1->set_area(strict_e_a1.get());
- new_e2->set_area(strict_e_a2.get());
-
- new_e1->set_marked(ADDED);
- new_e2->set_marked(ADDED);
-
- CompleteMessagePtr new_msg = new CompleteMessage(msg->get_label());
- new_msg->set_marked(ADDED);
-
- if(diff->getDirection() == SEND)
- new_msg->glue_events(new_e1, new_e2);
- else
- new_msg->glue_events(new_e2, new_e1);
-
- if(predecessor1 == NULL)
- {
- strict_e_a1->set_first(new_e1);
- }
- else
- predecessor1->set_successor(new_e1);
-
- if(predecessor2 == NULL)
- {
- strict_e_a2->set_first(new_e2);
- }
- else
- predecessor2->set_successor(new_e2);
-}
-
StrictEventPtr create_event(BMscPtr dup_flow, Difference* diff, std::wstring inst_name)
{
StrictEventPtr predecessor = diff->getLocation();
@@ -711,7 +663,7 @@
strict_e_a = predecessor->get_area();
StrictEventPtr new_e = new StrictEvent();
- set_event_position(new_e, diff, inst_name, dup_flow);
+ set_event_position(new_e, diff->getLocation(), inst_name, dup_flow);
new_e->set_area(strict_e_a.get());
new_e->set_marked(ADDED);
@@ -727,7 +679,7 @@
void process_diffrences(MembershipContext* c, BMscPtr dup_flow, const std::map<std::wstring, Difference*>& diff_map)
{
std::map<std::wstring, std::list<Difference*> > insert_map;
- insert_map = create_insert_map(diff_map);
+ insert_map = create_insert_map(c, diff_map);
std::map<std::wstring, std::list<Difference*> >::iterator ins_map_it;
std::map<std::wstring, std::set<Unmatched*> > unmatched_map;
@@ -915,39 +867,9 @@
if(!diff_map.empty())
{
//TODO much of the following code was copied from proccess diffrences
- std::map<std::wstring, Difference*>::const_iterator it;
std::map<std::wstring, std::list<Difference*> > insert_map;
- Difference* diff;
+ insert_map = create_insert_map(c, diff_map);
- for (it = diff_map.begin(); it != diff_map.end(); it++)
- {
- std::list<Difference*> insert_list;
- diff = it->second;
-
- if (diff == NULL)
- continue;
-
- while (diff != NULL)
- {
- if (diff->getOperation() == REMOVE)
- {
- diff->getLocation()->set_marked(REMOVED);
- EventPtr match_e = diff->getLocation()->get_matching_event();
-
- if(match_e != NULL)
- match_e->set_marked(REMOVED);
-
- diff->getLocation()->get_message()->set_marked(REMOVED);
- }
- else
- insert_list.push_back(diff);
-
- diff = diff->getPrevious();
- }
-
- insert_map.insert(std::make_pair(it->first, insert_list));
- }
-
std::map<std::wstring, std::list<Difference*> >::iterator ins_map_it;
for (ins_map_it = insert_map.begin(); ins_map_it != insert_map.end(); ins_map_it++)
@@ -988,7 +910,8 @@
throw std::runtime_error("Error: unexpected behaviour");
StrictEventPtr new_match_e = new StrictEvent();
-//TODO set position
+ set_event_position(new_match_e, match_se, match_inst, dup_flow);
+
new_match_e->set_area(match_se->get_area());
new_match_e->set_marked(ADDED);
@@ -1065,7 +988,8 @@
return false;
}
-std::map<std::wstring, std::list<Difference*> > create_insert_map(const std::map<std::wstring, Difference*>& diff_map)
+std::map<std::wstring, std::list<Difference*> > create_insert_map(MembershipContext* c,
+ const std::map<std::wstring, Difference*>& diff_map)
{
std::map<std::wstring, Difference*>::const_iterator it;
std::map<std::wstring, std::list<Difference*> > insert_map;
@@ -1083,7 +1007,7 @@
{
if (diff->getOperation() == REMOVE)
{
- if(diff->getLocation()->is_send())
+ if(c->get_diff_type() == ATTRIBUTE || diff->getLocation()->is_send())
{
diff->getLocation()->set_marked(REMOVED);
EventPtr match_e = diff->getLocation()->get_matching_event();
Modified: trunk/src/membership/membership_additional.cpp
===================================================================
--- trunk/src/membership/membership_additional.cpp 2011-02-28 17:35:32 UTC (rev 1053)
+++ trunk/src/membership/membership_additional.cpp 2011-03-02 13:17:18 UTC (rev 1054)
@@ -53,6 +53,20 @@
}
}
+ if(c->get_diff_type() != NOT_DIFF)
+ {
+ switch(a->is_attribute_set("identification") + b->is_attribute_set("identification"))
+ {
+ case 0: return true;
+ case 1: return false;
+ case 2: if(a->get_attribute("identification", -1) == b->get_attribute("identification", -1))
+ return true;
+ else
+ return false;
+ default: throw std::runtime_error("Error: unexpected behaviour");
+ }
+ }
+
return true;
}
@@ -165,7 +179,6 @@
c->add_attributed_event(event);
c->increase_max_id();
}
-
}
}
Modified: trunk/src/membership/membership_base.h
===================================================================
--- trunk/src/membership/membership_base.h 2011-02-28 17:35:32 UTC (rev 1053)
+++ trunk/src/membership/membership_base.h 2011-03-02 13:17:18 UTC (rev 1054)
@@ -36,7 +36,7 @@
class CoregionOrdering;
enum check_type {membership, receive_ordering};
enum TopBottom {top, bottom};
-enum DiffType {MESSAGE, ATTRIBUTE};
+enum DiffType {NOT_DIFF, MESSAGE, ATTRIBUTE};
typedef boost::intrusive_ptr<Position> PositionPtr;
typedef boost::intrusive_ptr<Configuration> ConfigurationPtr;
@@ -74,7 +74,7 @@
print_path = true;
relative_time = false;
absolut_time = false;
- diff_type = MESSAGE;
+ diff_type = NOT_DIFF;
}
void set_mem(MembershipAlg* m)
Modified: trunk/src/view/visio/addon/document.cpp
===================================================================
--- trunk/src/view/visio/addon/document.cpp 2011-02-28 17:35:32 UTC (rev 1053)
+++ trunk/src/view/visio/addon/document.cpp 2011-03-02 13:17:18 UTC (rev 1054)
@@ -1120,15 +1120,25 @@
if (result != NULL)
{
- m_reportView->Print(RS_NOTICE, stringize()
- << "Flow(s) " << flows << " in drawing " << msc_haystack->get_label()
- << " found.", result);
+ if(dlg.m_diffEnabled)
+ m_reportView->Print(RS_NOTICE, stringize()
+ << "Flow(s) " << flows << " and specification " << msc_haystack->get_label()
+ << " are not same. Have a look at diffrences", result);
+ else
+ m_reportView->Print(RS_NOTICE, stringize()
+ << "Flow(s) " << flows << " in drawing " << msc_haystack->get_label()
+ << " found.", result);
}
else
{
- m_reportView->Print(RS_NOTICE, stringize()
- << "Flow(s) " << flows << " in drawing " << msc_haystack->get_label()
- << " not found.");
+ if(dlg.m_diffEnabled)
+ m_reportView->Print(RS_NOTICE, stringize()
+ << "Flow(s) " << flows << " and specification " << msc_haystack->get_label()
+ << " are same.");
+ else
+ m_reportView->Print(RS_NOTICE, stringize()
+ << "Flow(s) " << flows << " in drawing " << msc_haystack->get_label()
+ << " not found.");
}
return VAORC_SUCCESS;
Modified: trunk/tests/diff/CMakeLists.txt
===================================================================
--- trunk/tests/diff/CMakeLists.txt 2011-02-28 17:35:32 UTC (rev 1053)
+++ trunk/tests/diff/CMakeLists.txt 2011-03-02 13:17:18 UTC (rev 1054)
@@ -31,8 +31,11 @@
ADD_DIFF_TEST(spec04.mpr flow04_6.mpr 1)
ADD_DIFF_TEST(spec05.mpr flow05_1.mpr 1)
ADD_DIFF_TEST(spec05.mpr flow05_2.mpr 1)
+ADD_DIFF_TEST(spec05.mpr flow05_3.mpr 1)
ADD_DIFF_TEST(spec06.mpr flow06_1.mpr 1)
ADD_DIFF_TEST(spec06.mpr flow06_2.mpr 1)
+ADD_DIFF_TEST(spec06.mpr flow06_3.mpr 1)
ADD_DIFF_TEST(spec07.mpr flow07_1.mpr 1)
ADD_DIFF_TEST(spec07.mpr flow07_2.mpr 1)
+ADD_DIFF_TEST(spec08.mpr flow08_1.mpr 1)
Added: trunk/tests/diff/flow05_3.mpr
===================================================================
--- trunk/tests/diff/flow05_3.mpr (rev 0)
+++ trunk/tests/diff/flow05_3.mpr 2011-03-02 13:17:18 UTC (rev 1054)
@@ -0,0 +1,11 @@
+mscdocument Drawing1;
+msc Page_1;
+inst A;
+inst B;
+A: instance;
+out a,3 to B;
+endinstance;
+B: instance;
+in a,3 from A;
+endinstance;
+endmsc;
Added: trunk/tests/diff/flow05_3.mpr.result
===================================================================
--- trunk/tests/diff/flow05_3.mpr.result (rev 0)
+++ trunk/tests/diff/flow05_3.mpr.result 2011-03-02 13:17:18 UTC (rev 1054)
@@ -0,0 +1,19 @@
+OK: HMSC contains bMSC
+
+mscdocument msc_diff;
+msc Page_1;
+inst A;
+inst B;
+A: instance;
+out a,0 to B;
+/* ADDED */
+/* ADDED */
+out a,1 to B;
+endinstance;
+B: instance;
+in a,0 from A;
+/* ADDED */
+/* ADDED */
+in a,1 from A;
+endinstance;
+endmsc;
Added: trunk/tests/diff/flow06_3.mpr
===================================================================
--- trunk/tests/diff/flow06_3.mpr (rev 0)
+++ trunk/tests/diff/flow06_3.mpr 2011-03-02 13:17:18 UTC (rev 1054)
@@ -0,0 +1,11 @@
+mscdocument Drawing1;
+msc Page_1;
+inst A;
+inst B;
+A: instance;
+out a,0 to B;
+endinstance;
+B: instance;
+in a,0 from A;
+endinstance;
+endmsc;
Added: trunk/tests/diff/flow06_3.mpr.result
===================================================================
--- trunk/tests/diff/flow06_3.mpr.result (rev 0)
+++ trunk/tests/diff/flow06_3.mpr.result 2011-03-02 13:17:18 UTC (rev 1054)
@@ -0,0 +1,19 @@
+OK: HMSC contains bMSC
+
+mscdocument msc_diff;
+msc Page_1;
+inst A;
+inst B;
+A: instance;
+out a,0 to B;
+/* ADDED */
+/* ADDED */
+out a,1 to B;
+endinstance;
+B: instance;
+/* ADDED */
+/* ADDED */
+in a,1 from A;
+in a,0 from A;
+endinstance;
+endmsc;
Added: trunk/tests/diff/flow08_1.mpr
===================================================================
--- trunk/tests/diff/flow08_1.mpr (rev 0)
+++ trunk/tests/diff/flow08_1.mpr 2011-03-02 13:17:18 UTC (rev 1054)
@@ -0,0 +1,11 @@
+mscdocument Drawing1;
+msc Page_1;
+inst A;
+inst B;
+A: instance;
+in a,0 from B;
+endinstance;
+B: instance;
+out a,0 to A;
+endinstance;
+endmsc;
Added: trunk/tests/diff/flow08_1.mpr.result
===================================================================
--- trunk/tests/diff/flow08_1.mpr.result (rev 0)
+++ trunk/tests/diff/flow08_1.mpr.result 2011-03-02 13:17:18 UTC (rev 1054)
@@ -0,0 +1,19 @@
+OK: HMSC contains bMSC
+
+mscdocument msc_diff;
+msc Page_1;
+inst A;
+inst B;
+A: instance;
+/* ADDED */
+/* ADDED */
+in a,0 from B;
+in a,1 from B;
+endinstance;
+B: instance;
+out a,1 to A;
+/* ADDED */
+/* ADDED */
+out a,0 to A;
+endinstance;
+endmsc;
Added: trunk/tests/diff/spec08.mpr
===================================================================
--- trunk/tests/diff/spec08.mpr (rev 0)
+++ trunk/tests/diff/spec08.mpr 2011-03-02 13:17:18 UTC (rev 1054)
@@ -0,0 +1,13 @@
+mscdocument Drawing1;
+msc Page_1;
+inst A;
+inst B;
+A: instance;
+in a,3 from B;
+in a,0 from B;
+endinstance;
+B: instance;
+out a,0 to A;
+out a,3 to A;
+endinstance;
+endmsc;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|