|
From: <ma...@us...> - 2010-12-08 20:34:56
|
Revision: 1006
http://scstudio.svn.sourceforge.net/scstudio/?rev=1006&view=rev
Author: madzin
Date: 2010-12-08 20:34:49 +0000 (Wed, 08 Dec 2010)
Log Message:
-----------
Add lexer error handling and comment recognition.
Modified Paths:
--------------
trunk/src/data/Z120/Context.cpp
trunk/src/data/Z120/Context.h
trunk/src/data/Z120/Context_Impl.h
trunk/src/data/Z120/Z120.g
trunk/src/data/Z120/display_error.cpp
trunk/src/data/Z120/display_error.h
trunk/src/data/Z120/z120_save.cpp
trunk/tests/z120_test/CMakeLists.txt
trunk/tests/z120_test/z120_test01.mpr.result
trunk/tests/z120_test/z120_test02.mpr.result
Added Paths:
-----------
trunk/tests/z120_test/z120_test90.mpr
trunk/tests/z120_test/z120_test90.mpr.result
Modified: trunk/src/data/Z120/Context.cpp
===================================================================
--- trunk/src/data/Z120/Context.cpp 2010-12-08 16:18:24 UTC (rev 1005)
+++ trunk/src/data/Z120/Context.cpp 2010-12-08 20:34:49 UTC (rev 1006)
@@ -1640,6 +1640,39 @@
context->time_second = time_relation_type;
}
+void add_global_comment(struct Context* context, char* text)
+{
+ std::string complete = text;
+
+ complete = complete.substr(complete.find("'")+1, complete.size());
+ complete = complete.substr(0, complete.rfind("'"));
+
+ CommentPtr comment = new Comment(TOWSTRING(complete));
+
+ if(context->myBmsc != NULL)
+ context->myBmsc->add_comment(comment);
+
+ if(context->myHmsc != NULL)
+ context->myHmsc->add_comment(comment);
+}
+
+void add_element_comment(struct Context* context, char* text)
+{
+ std::string complete = text;
+
+ complete = complete.substr(complete.find("'")+1, complete.size());
+ complete = complete.substr(0, complete.rfind("'"));
+
+ CommentPtr comment = new Comment(TOWSTRING(complete));
+
+ if(context->myBmsc != NULL && context->current_event != NULL)
+ context->current_event->add_comment(comment);
+
+ if(context->myHmsc != NULL && context->current_node != NULL)
+ context->current_node->add_comment(comment);
+
+}
+
#endif
// $Id$
Modified: trunk/src/data/Z120/Context.h
===================================================================
--- trunk/src/data/Z120/Context.h 2010-12-08 16:18:24 UTC (rev 1005)
+++ trunk/src/data/Z120/Context.h 2010-12-08 20:34:49 UTC (rev 1006)
@@ -161,6 +161,12 @@
void set_second_time_rel_kind_fun(struct Context* context, enum time_relation_kind kind);
+
+//Comment
+void add_global_comment(struct Context* context, char* text);
+
+void add_element_comment(struct Context* context, char* text);
+
#ifdef __cplusplus
}
#endif
Modified: trunk/src/data/Z120/Context_Impl.h
===================================================================
--- trunk/src/data/Z120/Context_Impl.h 2010-12-08 16:18:24 UTC (rev 1005)
+++ trunk/src/data/Z120/Context_Impl.h 2010-12-08 20:34:49 UTC (rev 1006)
@@ -139,7 +139,6 @@
~Context() {}
};
-
void create_future_connections_fun(struct Context* context, SuccessorNode* succ);
#endif // _Context_Impl_
Modified: trunk/src/data/Z120/Z120.g
===================================================================
--- trunk/src/data/Z120/Z120.g 2010-12-08 16:18:24 UTC (rev 1005)
+++ trunk/src/data/Z120/Z120.g 2010-12-08 20:34:49 UTC (rev 1006)
@@ -30,31 +30,53 @@
k=3;
}
-@header
+@lexer::includes
{
#include "data/Z120/Context.h"
#include "data/Z120/display_error.h"
- void scstudio_error_reporting(pANTLR3_BASE_RECOGNIZER recognizer, pANTLR3_UINT8 *tokenNames);
+ struct s_Z120* printer;
+ void scstudio_lexer_error_reporting(pANTLR3_BASE_RECOGNIZER recognizer, pANTLR3_UINT8 *tokenNames);
}
-@members
+@lexer::apifuncs
{
- struct Context* context;
+ RECOGNIZER->displayRecognitionError = &scstudio_lexer_error_reporting;
+}
- void scstudio_error_reporting(pANTLR3_BASE_RECOGNIZER recognizer, pANTLR3_UINT8 *tokenNames)
+@lexer::members
+{
+ void scstudio_lexer_error_reporting(pANTLR3_BASE_RECOGNIZER recognizer, pANTLR3_UINT8 *tokenNames)
{
- display_error(context, recognizer, tokenNames);
+ lexer_error(printer, recognizer, tokenNames);
}
}
+@parser::includes
+{
+ #include "data/Z120/Context.h"
+ #include "data/Z120/display_error.h"
+ #include "data/Z120/Z120Lexer.h"
+
+ void scstudio_error_reporting(pANTLR3_BASE_RECOGNIZER recognizer, pANTLR3_UINT8 *tokenNames);
+}
+
@parser::apifuncs
{
- RECOGNIZER->reportError = &reportError;
+// RECOGNIZER->reportError = &reportError;
RECOGNIZER->displayRecognitionError = &scstudio_error_reporting;
}
+@members
+{
+ struct Context* context;
+ void scstudio_error_reporting(pANTLR3_BASE_RECOGNIZER recognizer, pANTLR3_UINT8 *tokenNames)
+ {
+ display_error(context, recognizer, tokenNames);
+ }
+}
+
/*
* removed due to: Z120.g:40:1: syntax error: antlr: Z120.g:40:1: unexpected token: tokens
tokens
@@ -152,10 +174,12 @@
comment:
'comment' Character_String
+ {add_element_comment(context, (char*) $Character_String.text->chars);}
;
text_definition:
'text' Character_String end
+ {add_global_comment(context, (char*) $Character_String.text->chars);}
;
NOTE:
@@ -172,10 +196,10 @@
textual_msc_file [struct s_Z120* my_z120] returns [struct s_Msc** my_msc]:
{
context = new_context();
+ printer = my_z120;
+
if(my_z120 != NULL)
- {
add_z_fun(context, $my_z120);
- }
}
(document_head)? (message_sequence_chart)*
{
Modified: trunk/src/data/Z120/display_error.cpp
===================================================================
--- trunk/src/data/Z120/display_error.cpp 2010-12-08 16:18:24 UTC (rev 1005)
+++ trunk/src/data/Z120/display_error.cpp 2010-12-08 20:34:49 UTC (rev 1006)
@@ -231,4 +231,30 @@
context->z->print_report(RS_ERROR, report);
}
+void lexer_error(struct s_Z120* z, pANTLR3_BASE_RECOGNIZER recognizer, pANTLR3_UINT8 *tokenNames)
+{
+ Z120* printer = static_cast<Z120*> (z);
+ stringize report;
+
+ pANTLR3_LEXER lexer;
+ pANTLR3_EXCEPTION ex;
+ pANTLR3_STRING ftext;
+
+ lexer = (pANTLR3_LEXER)(recognizer->super);
+ ex = lexer->rec->state->exception;
+
+ // See if there is a 'filename' we can use
+ if(ex->name == NULL)
+ report << "-unknown source-[";
+ else
+ {
+ ftext = ex->streamName->to8(ex->streamName);
+ report << (char*) ftext->chars << "[";
+ }
+
+ report << recognizer->state->exception->line << "," << ex->charPositionInLine+1 << "]: Lexer error";
+
+ printer->print_report(RS_ERROR, report);
+}
+
// $Id$
Modified: trunk/src/data/Z120/display_error.h
===================================================================
--- trunk/src/data/Z120/display_error.h 2010-12-08 16:18:24 UTC (rev 1005)
+++ trunk/src/data/Z120/display_error.h 2010-12-08 20:34:49 UTC (rev 1006)
@@ -11,6 +11,8 @@
void display_error(struct Context* context, pANTLR3_BASE_RECOGNIZER recognizer, pANTLR3_UINT8 *tokenNames);
+void lexer_error(struct s_Z120* z, pANTLR3_BASE_RECOGNIZER recognizer, pANTLR3_UINT8 *tokenNames);
+
#ifdef __cplusplus
}
#endif
Modified: trunk/src/data/Z120/z120_save.cpp
===================================================================
--- trunk/src/data/Z120/z120_save.cpp 2010-12-08 16:18:24 UTC (rev 1005)
+++ trunk/src/data/Z120/z120_save.cpp 2010-12-08 20:34:49 UTC (rev 1006)
@@ -215,8 +215,17 @@
if(*pos == '\'')
{
- // double the apostrophe
- os << "''";
+ if((pos == value.m_text.begin() && *(pos+1) != '\'')
+ || (pos == value.m_text.end() && *(pos-1) != '\'')
+ || (*(pos+1) != '\'' && *(pos-1) != '\''))
+ {
+//TODO print warning that the comment is not valid
+// print_report(RS_WARNING, stringize() << L"Comment text \"" << TOWSTRING(value) << L"\" is not allowed");
+
+ // double the apostrophe
+ os << "''";
+ }
+
was_replacement = false;
}
else if(*pos == '\r')
@@ -445,8 +454,6 @@
print_element_attributes(stream, bmsc);
stream << "msc " << VALID_NAME(bmsc->get_label()) << ";" << std::endl;
- // print global comments
- print_texts(stream, bmsc);
// declare instances
for(InstancePtrList::const_iterator ipos = bmsc->get_instances().begin();
@@ -455,6 +462,9 @@
stream << "inst " << VALID_NAME((*ipos)->get_label()) << ";" << std::endl;
}
+ // print global comments
+ print_texts(stream, bmsc);
+
// define instances
for(InstancePtrList::const_iterator ipos = bmsc->get_instances().begin();
ipos != bmsc->get_instances().end(); ipos++)
Modified: trunk/tests/z120_test/CMakeLists.txt
===================================================================
--- trunk/tests/z120_test/CMakeLists.txt 2010-12-08 16:18:24 UTC (rev 1005)
+++ trunk/tests/z120_test/CMakeLists.txt 2010-12-08 20:34:49 UTC (rev 1006)
@@ -97,6 +97,7 @@
ADD_Z120_TEST(z120_test87.mpr 1)
ADD_Z120_TEST(z120_test88.mpr 1)
ADD_Z120_TEST(z120_test89.mpr 1)
+ADD_Z120_TEST(z120_test90.mpr 1)
ADD_Z120_TEST(z120_time01.mpr 1)
ADD_Z120_TEST(z120_time02.mpr 1)
Modified: trunk/tests/z120_test/z120_test01.mpr.result
===================================================================
--- trunk/tests/z120_test/z120_test01.mpr.result 2010-12-08 16:18:24 UTC (rev 1005)
+++ trunk/tests/z120_test/z120_test01.mpr.result 2010-12-08 20:34:49 UTC (rev 1006)
@@ -5,6 +5,7 @@
msc z120_test01;
inst ONE;
inst TWO;
+text 'Comment';
ONE: instance;
in LEFT,0 from found;
out NAME,1 to TWO;
Modified: trunk/tests/z120_test/z120_test02.mpr.result
===================================================================
--- trunk/tests/z120_test/z120_test02.mpr.result 2010-12-08 16:18:24 UTC (rev 1005)
+++ trunk/tests/z120_test/z120_test02.mpr.result 2010-12-08 20:34:49 UTC (rev 1006)
@@ -3,6 +3,7 @@
mscdocument z120_test02;
msc z120_test02;
+text 'Comment';
initial connect L0;
L0: connect L1, L2;
L1: condition STATE1 connect L3;
Added: trunk/tests/z120_test/z120_test90.mpr
===================================================================
--- trunk/tests/z120_test/z120_test90.mpr (rev 0)
+++ trunk/tests/z120_test/z120_test90.mpr 2010-12-08 20:34:49 UTC (rev 1006)
@@ -0,0 +1,21 @@
+mscdocument Drawing5;
+msc Page_1;
+inst a;
+inst c;
+inst b;
+text 'text';
+a: instance;
+out 1,0 to b;
+in 4,1 from b;
+endinstance;
+c: instance;
+in 2,2 from b;
+out 3,3 to b;
+endinstance;
+b: instance;
+in 1,0 from a comment 'Event ';
+out 2,2 to c;
+in 3,3 from c;
+out 4,1 to a;
+endinstance;
+endmsc;
Added: trunk/tests/z120_test/z120_test90.mpr.result
===================================================================
--- trunk/tests/z120_test/z120_test90.mpr.result (rev 0)
+++ trunk/tests/z120_test/z120_test90.mpr.result 2010-12-08 20:34:49 UTC (rev 1006)
@@ -0,0 +1,23 @@
+OK: z120_test90 is correct, should be correct
+
+mscdocument z120_test90;
+msc Page_1;
+inst a;
+inst c;
+inst b;
+text 'text';
+a: instance;
+out 1,0 to b;
+in 4,1 from b;
+endinstance;
+c: instance;
+in 2,2 from b;
+out 3,3 to b;
+endinstance;
+b: instance;
+in 1,0 from a comment 'Event ';
+out 2,2 to c;
+in 3,3 from c;
+out 4,1 to a;
+endinstance;
+endmsc;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ma...@us...> - 2010-12-09 17:49:15
|
Revision: 1010
http://scstudio.svn.sourceforge.net/scstudio/?rev=1010&view=rev
Author: madzin
Date: 2010-12-09 17:49:09 +0000 (Thu, 09 Dec 2010)
Log Message:
-----------
Add test and repair small bug in the export
Modified Paths:
--------------
trunk/src/data/Z120/z120_save.cpp
trunk/tests/z120_test/CMakeLists.txt
Added Paths:
-----------
trunk/tests/z120_test/z120_test91.mpr
trunk/tests/z120_test/z120_test91.mpr.result
trunk/tests/z120_test/z120_test92.mpr
trunk/tests/z120_test/z120_test92.mpr.result
Modified: trunk/src/data/Z120/z120_save.cpp
===================================================================
--- trunk/src/data/Z120/z120_save.cpp 2010-12-09 16:19:51 UTC (rev 1009)
+++ trunk/src/data/Z120/z120_save.cpp 2010-12-09 17:49:09 UTC (rev 1010)
@@ -225,6 +225,8 @@
// double the apostrophe
os << "''";
}
+ else
+ os << "'";
was_replacement = false;
}
Modified: trunk/tests/z120_test/CMakeLists.txt
===================================================================
--- trunk/tests/z120_test/CMakeLists.txt 2010-12-09 16:19:51 UTC (rev 1009)
+++ trunk/tests/z120_test/CMakeLists.txt 2010-12-09 17:49:09 UTC (rev 1010)
@@ -98,6 +98,8 @@
ADD_Z120_TEST(z120_test88.mpr 1)
ADD_Z120_TEST(z120_test89.mpr 1)
ADD_Z120_TEST(z120_test90.mpr 1)
+ADD_Z120_TEST(z120_test91.mpr 1)
+ADD_Z120_TEST(z120_test92.mpr 1)
ADD_Z120_TEST(z120_time01.mpr 1)
ADD_Z120_TEST(z120_time02.mpr 1)
Added: trunk/tests/z120_test/z120_test91.mpr
===================================================================
--- trunk/tests/z120_test/z120_test91.mpr (rev 0)
+++ trunk/tests/z120_test/z120_test91.mpr 2010-12-09 17:49:09 UTC (rev 1010)
@@ -0,0 +1,20 @@
+/*****************************************************
+Simple test of bmsc (event driven notification)
+
+******************************************************/
+
+ms!cdocument bbb;
+msc pok2;
+A: instance;
+B: instance;
+A: in A,1 from found;
+A: out jedna,2 to B;
+B: in jedna,2 from A;
+A: concurrent;
+A: out B1,3 to B;
+B: in B1,3 from A;
+A: out B,4 to lost;
+A: endconcurrent;
+A: endinstance;
+B: endinstance;
+endmsc;
Added: trunk/tests/z120_test/z120_test91.mpr.result
===================================================================
--- trunk/tests/z120_test/z120_test91.mpr.result (rev 0)
+++ trunk/tests/z120_test/z120_test91.mpr.result 2010-12-09 17:49:09 UTC (rev 1010)
@@ -0,0 +1,2 @@
+z120_test91.mpr[6,3]: Lexer error
+Error 22: Syntax error
Added: trunk/tests/z120_test/z120_test92.mpr
===================================================================
--- trunk/tests/z120_test/z120_test92.mpr (rev 0)
+++ trunk/tests/z120_test/z120_test92.mpr 2010-12-09 17:49:09 UTC (rev 1010)
@@ -0,0 +1,21 @@
+mscdocument z120_test90;
+msc Page_1;
+inst a;
+inst c;
+inst b;
+text 'text';
+a: instance;
+out 1,0 to b;
+in 4,1 from b;
+endinstance;
+c: instance;
+in 2,2 from b;
+out 3,3 to b;
+endinstance;
+b: instance;
+in 1,0 from a comment 'Ev''ent ';
+out 2,2 to c;
+in 3,3 from c;
+out 4,1 to a;
+endinstance;
+endmsc;
Added: trunk/tests/z120_test/z120_test92.mpr.result
===================================================================
--- trunk/tests/z120_test/z120_test92.mpr.result (rev 0)
+++ trunk/tests/z120_test/z120_test92.mpr.result 2010-12-09 17:49:09 UTC (rev 1010)
@@ -0,0 +1,23 @@
+OK: z120_test92 is correct, should be correct
+
+mscdocument z120_test92;
+msc Page_1;
+inst a;
+inst c;
+inst b;
+text 'text';
+a: instance;
+out 1,0 to b;
+in 4,1 from b;
+endinstance;
+c: instance;
+in 2,2 from b;
+out 3,3 to b;
+endinstance;
+b: instance;
+in 1,0 from a comment 'Ev''ent ';
+out 2,2 to c;
+in 3,3 from c;
+out 4,1 to a;
+endinstance;
+endmsc;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ma...@us...> - 2010-12-13 16:34:58
|
Revision: 1013
http://scstudio.svn.sourceforge.net/scstudio/?rev=1013&view=rev
Author: madzin
Date: 2010-12-13 16:34:52 +0000 (Mon, 13 Dec 2010)
Log Message:
-----------
Modify lexer error output message.
Modified Paths:
--------------
trunk/src/data/Z120/display_error.cpp
trunk/tests/z120_test/z120_test93.mpr.result
Modified: trunk/src/data/Z120/display_error.cpp
===================================================================
--- trunk/src/data/Z120/display_error.cpp 2010-12-12 11:05:38 UTC (rev 1012)
+++ trunk/src/data/Z120/display_error.cpp 2010-12-13 16:34:52 UTC (rev 1013)
@@ -236,24 +236,36 @@
Z120* printer = static_cast<Z120*> (z);
stringize report;
- pANTLR3_LEXER lexer;
- pANTLR3_EXCEPTION ex;
- pANTLR3_STRING ftext;
+ // Retrieve some info for easy reading.
+ pANTLR3_LEXER lexer = (pANTLR3_LEXER)(recognizer->super);
+ pANTLR3_EXCEPTION ex = lexer->rec->state->exception;
- lexer = (pANTLR3_LEXER)(recognizer->super);
- ex = lexer->rec->state->exception;
-
// See if there is a 'filename' we can use
if(ex->name == NULL)
- report << "-unknown source-[";
+ report << "-unknown source-";
else
{
- ftext = ex->streamName->to8(ex->streamName);
- report << (char*) ftext->chars << "[";
+ pANTLR3_STRING ftext = ex->streamName->to8(ex->streamName);
+
+ char* last_slash = (char *)ftext->chars;
+ bool slash_present = false;
+ // strip file path
+ for(char *ch = (char *)ftext->chars; *ch != 0; ch++)
+ {
+ if(*ch == '\\' || *ch == '/')
+ {
+ last_slash = ch;
+ slash_present = true;
+ }
+ }
+
+ if(slash_present)
+ report << last_slash+1;
+ else
+ report << last_slash;
}
+ report << "[" << recognizer->state->exception->line << "," << ex->charPositionInLine+1 << "] Lexer error.";
- report << recognizer->state->exception->line << "," << ex->charPositionInLine+1 << "]: Lexer error";
-
printer->print_report(RS_ERROR, report);
}
Modified: trunk/tests/z120_test/z120_test93.mpr.result
===================================================================
--- trunk/tests/z120_test/z120_test93.mpr.result 2010-12-12 11:05:38 UTC (rev 1012)
+++ trunk/tests/z120_test/z120_test93.mpr.result 2010-12-13 16:34:52 UTC (rev 1013)
@@ -1,4 +1,4 @@
-z120_test93.mpr[20,4]: Lexer error
+z120_test93.mpr[20,4] Lexer error.
z120_test93.mpr[20,0] Cannot match to any predicted input.
Warning 16: Multiple instances with the same name: b
Warning 20: MSC (Page_1) has unterminated 2 instance
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ma...@us...> - 2011-02-02 23:58:04
|
Revision: 1030
http://scstudio.svn.sourceforge.net/scstudio/?rev=1030&view=rev
Author: madzin
Date: 2011-02-02 23:57:58 +0000 (Wed, 02 Feb 2011)
Log Message:
-----------
Add Diff algorithm
Modified Paths:
--------------
trunk/src/membership/CMakeLists.txt
trunk/src/membership/membership_base.h
trunk/tests/CMakeLists.txt
Added Paths:
-----------
trunk/src/membership/diff_impl.cpp
trunk/src/membership/diff_impl.h
trunk/tests/diff/
trunk/tests/diff/CMakeLists.txt
trunk/tests/diff/diff_test.cpp
trunk/tests/diff/flow01.mpr
trunk/tests/diff/flow02_1.mpr
trunk/tests/diff/flow02_2.mpr
trunk/tests/diff/flow02_3.mpr
trunk/tests/diff/spec01.mpr
trunk/tests/diff/spec02.mpr
Modified: trunk/src/membership/CMakeLists.txt
===================================================================
--- trunk/src/membership/CMakeLists.txt 2011-02-02 22:17:59 UTC (rev 1029)
+++ trunk/src/membership/CMakeLists.txt 2011-02-02 23:57:58 UTC (rev 1030)
@@ -8,6 +8,8 @@
membership_additional.cpp
membership_additional.h
membership_base.h
+ diff_impl.h
+ diff_impl.cpp
)
TARGET_LINK_LIBRARIES(scmembership
Added: trunk/src/membership/diff_impl.cpp
===================================================================
--- trunk/src/membership/diff_impl.cpp (rev 0)
+++ trunk/src/membership/diff_impl.cpp 2011-02-02 23:57:58 UTC (rev 1030)
@@ -0,0 +1,487 @@
+/*
+ * scstudio - Sequence Chart Studio
+ * http://scstudio.sourceforge.net
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * Copyright (c) 2008 Matus Madzin <go...@ma...>
+ *
+ */
+
+#include "membership/diff_impl.h"
+
+void process_diffrences(BMscPtr dup_flow, const std::map<std::wstring, Difference*>& diff_map);
+
+/**
+ * Find diffrences on instance between flow and specification
+ *
+ * parameters: a - flow
+ * b - specification
+ */
+Difference* instance_diff(InstancePtr a, InstancePtr b);
+
+BMscPtr bmsc_bmsc_diff(BMscPtr specification, BMscPtr flow);
+BMscPtr hmsc_bmsc_diff(HMscPtr specification, BMscPtr flow);
+
+/**
+ * Find msc diffrences between flow and specification
+ *
+ * parameters: a - specification
+ * b - flow
+ */
+MscPtr MembershipAlg::diff(MscPtr specification, BMscPtr flow)
+{
+ BMscPtr bmsc = boost::dynamic_pointer_cast<BMsc > (specification);
+
+ if (bmsc == NULL)
+ {
+ HMscPtr hmsc = boost::dynamic_pointer_cast<HMsc > (specification);
+
+ return hmsc_bmsc_diff(hmsc, flow);
+ }
+ else
+ return bmsc_bmsc_diff(bmsc, flow);
+}
+
+Difference* instance_diff(InstancePtr a, InstancePtr b)
+{
+ std::vector<StrictEventPtr> a_ordering;
+ std::vector<StrictEventPtr> b_ordering;
+ int row = 0;
+ int col = 0;
+
+ EventAreaPtr a_area = a->get_first();
+ EventAreaPtr b_area = b->get_first();
+
+ StrictOrderAreaPtr a_soa = boost::dynamic_pointer_cast<StrictOrderArea > (a_area);
+ StrictOrderAreaPtr b_soa = boost::dynamic_pointer_cast<StrictOrderArea > (b_area);
+
+ StrictEventPtr event_a = a_soa->get_first();
+ StrictEventPtr event_b = b_soa->get_first();
+
+ StrictEventPtr start_a, start_b;
+
+ if (event_a != NULL)
+ start_a = event_a;
+ if (event_b != NULL)
+ start_b = event_b;
+
+ //TODO check what is in context, maybe it is necessary to replace it.
+ MembershipContext* c = new MembershipContext();
+
+ while (event_a != NULL || event_b != NULL)
+ {
+ if (!compare_events(c, event_a.get(), event_b.get()))
+ break;
+
+ row++;
+ event_a = event_a->get_successor();
+ event_b = event_b->get_successor();
+ }
+
+ int lower, upper;
+
+ if (event_a == NULL)
+ lower = 1;
+ else
+ lower = -1;
+
+ if (event_b == NULL)
+ upper = -1;
+ else
+ upper = 1;
+
+ if (lower > upper)
+ //instances are same
+ return NULL;
+
+ int d; //current edit distance
+ std::map<int, Distance*> last_d;
+ std::map<int, Difference*> script;
+
+ last_d[0] = new Distance(event_a, row);
+ script[0] = NULL;
+ col = row;
+
+ for (d = 1; d < 100; d++)
+ {
+ for (int k = lower; k <= upper; k += 2)
+ {
+ Difference* diff = new Difference();
+ std::map<int, Distance*>::iterator down, up;
+ down = last_d.find(k - 1);
+ up = last_d.find(k + 1);
+ bool result = false;
+
+ if (down == last_d.end() || (up != last_d.end() && up->second->getLine() >= down->second->getLine()))
+ result = true;
+
+ StrictEventPtr old_a;
+ if ((k == -d || k != d) && result)
+ {
+ // moving down from the last d-1 on diagonal k+1
+ // puts you farther along diagonal k than does
+ // moving right from the last d-1 on diagonal k-1
+ if (up != last_d.end())
+ {
+ old_a = up->second->getEvent();
+ event_a = up->second->getEvent()->get_successor();
+ row = up->second->getLine() + 1;
+ }
+ else
+ {
+ row = 1;
+
+ if (start_a != NULL)
+ event_a = start_a->get_successor();
+ else
+ {
+ //TODO cover the error message
+ throw std::runtime_error("Error: unexpected behaviour");
+ }
+ old_a = event_a;
+ }
+
+ if (script.find(k + 1) != script.end())
+ diff->setPrevious(script[k + 1]);
+
+ diff->setOperation(DELETE);
+ diff->setLocation(old_a);
+ diff->setMessage(old_a->get_message(), old_a->is_send());
+ }
+ else
+ {
+ // move right from the last d-1 on diagonal k-1
+ if (down != last_d.end())
+ {
+ old_a = down->second->getEvent();
+ event_a = down->second->getEvent();
+ row = down->second->getLine();
+ }
+ else
+ {
+ row = 1;
+
+ if (start_a != NULL)
+ event_a = start_a->get_successor();
+ else
+ {
+ //TODO cover the error message
+ throw std::runtime_error("Error: unexpected behaviour");
+ }
+ old_a = event_a;
+ }
+
+ if (script.find(k - 1) != script.end())
+ diff->setPrevious(script[k - 1]);
+
+ diff->setOperation(INSERT);
+
+ //TODO nemozem takto prechadzat eventy od zaciatku
+ StrictEventPtr s = start_b;
+ for (int i = 0; i < (row + k - 1); i++)
+ {
+ s = s->get_successor();
+ }
+
+ //TODO nemozem takto prechadzat eventy od zaciatku
+ StrictEventPtr r = start_a;
+ for (int i = 0; i < row - 1; i++)
+ {
+ r = r->get_successor();
+ }
+ if(row - 1 <= 0)
+ r = NULL;
+
+ diff->setLocation(r);
+ diff->setMessage(s->get_message(), s->is_send());
+ }
+
+ int old_col = col;
+ col = row + k;
+ int rest = col - old_col;
+
+ if (rest > 0)
+ {
+ for (int i = 0; i < rest; i++)
+ {
+ if (event_b != NULL)
+ event_b = event_b->get_successor();
+ }
+ }
+ else
+ {
+ for (int i = rest; i < 0; i++)
+ {
+ if (event_b != NULL)
+ event_b = event_b->get_predecessor();
+ else
+ event_b = b_soa->get_last();
+ }
+ }
+
+ diff->setLine1(row);
+ diff->setLine2(col);
+ script[k] = diff;
+
+
+ while (event_a != NULL && event_b != NULL && compare_events(c, event_a.get(), event_b.get()))
+ {
+ event_a = event_a->get_successor();
+ event_b = event_b->get_successor();
+ row++;
+ col++;
+ }
+
+ last_d[k] = new Distance(event_a, row);
+
+ if (event_a == NULL && event_b == NULL)
+ // hit southeast corner, have the answer
+ return script[k];
+
+ if (event_a == NULL)
+ // hit the last row, don't look to the left
+ lower = k + 2;
+
+ if (event_b == NULL)
+ // hit the last column, don't look to the right
+ upper = k - 2;
+ }
+
+ --lower;
+ ++upper;
+ }
+
+ //TODO pridane lebo warning, overit ci sa niekedy mozme dostat do tohto miesta v korektnom behu
+ throw std::runtime_error("Error: I don't know");
+}
+
+BMscPtr bmsc_bmsc_diff(BMscPtr specification, BMscPtr flow)
+{
+ BMscDuplicator duplicator;
+ BMscPtr dup_flow;
+
+ dup_flow = duplicator.duplicate(flow);
+
+ InstancePtrList spec_inst = specification->get_instances();
+ InstancePtrList flow_inst = dup_flow->get_instances();
+
+ std::map<std::wstring, Difference*> diff_map;
+
+ InstancePtrList::iterator spec_it;
+ InstancePtrList::iterator flow_it;
+
+ for (spec_it = spec_inst.begin(); spec_it != spec_inst.end(); spec_it++)
+ {
+ for (flow_it = flow_inst.begin(); flow_it != flow_inst.end(); flow_it++)
+ {
+ if ((*spec_it)->get_label() == (*flow_it)->get_label())
+ {
+ Difference* diff = instance_diff(*flow_it, *spec_it);
+
+ if(diff != NULL)
+ diff_map.insert(std::make_pair((*flow_it)->get_label(), diff));
+ }
+ }
+ }
+
+ if(!diff_map.empty())
+ {
+ process_diffrences(dup_flow, diff_map);
+ return dup_flow;
+ }
+ else
+ return NULL;
+}
+
+BMscPtr hmsc_bmsc_diff(HMscPtr specification, BMscPtr flow)
+{
+ std::cerr << "Error: this feature is not supported yet" << std::endl;
+ return NULL;
+}
+
+StrictOrderAreaPtr get_proper_area(BMscPtr flow, std::wstring inst_name)
+{
+ InstancePtrList instances = flow->get_instances();
+ InstancePtrList::iterator instances_it;
+
+ for(instances_it = instances.begin(); instances_it != instances.end(); instances_it++)
+ {
+ if((*instances_it)->get_label() == inst_name)
+ break;
+ }
+
+//TODO ak je to sprava na instanciu ktora sa vo flow nenachadza tak bude splnena podmienka a error to nie je
+ if(instances_it == instances.end())
+ throw std::runtime_error("Error: unexpected behaviour");
+
+ EventAreaPtr e_a = (*instances_it)->get_first();
+
+//TODO
+// if(e_a == NULL)
+
+ StrictOrderAreaPtr s_e_a = boost::dynamic_pointer_cast<StrictOrderArea> (e_a);
+
+ if(s_e_a == NULL)
+ throw std::runtime_error("Error: unexpected behaviour, check whether flow MSC does not contain coregion");
+
+ return s_e_a;
+}
+
+void process_diffrences(BMscPtr dup_flow, 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;
+ Difference* diff;
+
+ 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() == DELETE)
+ {
+ diff->getLocation()->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::set<Difference*> recently_processed;
+ 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++)
+ {
+ std::list<Difference*> insert_list = ins_map_it->second;
+ std::list<Difference*>::iterator ins_list_it;
+
+ for (ins_list_it = insert_list.begin(); ins_list_it != insert_list.end(); ins_list_it++)
+ {
+ if(recently_processed.find(*ins_list_it) != recently_processed.end())
+ continue;
+
+ MscMessagePtr message = (*ins_list_it)->getMessage();
+ CompleteMessagePtr com_msg = boost::dynamic_pointer_cast<CompleteMessage> (message);
+
+ //In case the message is incommplete, create new event, add it to the proper ordering
+ if (com_msg == NULL)
+ {
+ //TODO refactoring, get it to the separated function
+ IncompleteMessagePtr in_msg = boost::dynamic_pointer_cast<IncompleteMessage > (message);
+ StrictEventPtr new_e = new StrictEvent();
+
+ IncompleteMessagePtr new_msg = new IncompleteMessage(
+ in_msg->is_lost() ? LOST : FOUND,
+ in_msg->get_label(),
+ in_msg->get_instance_label());
+
+ new_msg->glue_event(new_e);
+
+ if((*ins_list_it)->getLocation() != NULL)
+ (*ins_list_it)->getLocation()->set_successor(new_e);
+ else
+ {
+ StrictOrderAreaPtr s_e_a = get_proper_area(dup_flow, ins_map_it->first);
+
+ new_e->set_successor(s_e_a->get_first());
+ s_e_a->set_first(new_e);
+ }
+
+ continue;
+ }
+
+ std::wstring match_inst;
+
+ if ((*ins_list_it)->getDirection() == SEND)
+ match_inst = com_msg->get_receiver()->get_label();
+ else
+ match_inst = com_msg->get_sender()->get_label();
+
+ std::list<Difference*> match_insert_list;
+
+ match_insert_list = insert_map.find(match_inst)->second;
+
+ std::list<Difference*>::iterator match_ins_list_it;
+ Difference* match_diff;
+
+ for (match_ins_list_it = match_insert_list.begin();
+ match_ins_list_it != match_insert_list.end();
+ match_ins_list_it++)
+ {
+ if ((*match_ins_list_it)->getMessage() == message)
+ {
+ match_diff = *match_ins_list_it;
+ break;
+ }
+ }
+
+ recently_processed.insert(match_diff);
+
+ StrictEventPtr predecessor1 = (*ins_list_it)->getLocation();
+ StrictEventPtr predecessor2 = match_diff->getLocation();
+
+ StrictEventPtr new_e1 = new StrictEvent();
+ StrictEventPtr new_e2 = new StrictEvent();
+
+
+ StrictOrderAreaPtr strict_e_a1, strict_e_a2;
+
+ if(predecessor1 == NULL)
+ strict_e_a1 = get_proper_area(dup_flow, ins_map_it->first);
+ else
+ strict_e_a1 = predecessor1->get_area();
+
+ if(predecessor2 == NULL)
+ strict_e_a2 = get_proper_area(dup_flow, ins_map_it->first);
+ else
+ strict_e_a2 = predecessor2->get_area();
+
+ 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(message->get_label());
+ new_msg->set_marked(ADDED);
+
+ if ((*ins_list_it)->getDirection() == SEND)
+ new_msg->glue_events(new_e1, new_e2);
+ else
+ new_msg->glue_events(new_e2, new_e1);
+
+ if(predecessor1 == NULL)
+ {
+ new_e1->set_successor(strict_e_a1->get_first());
+ strict_e_a1->set_first(new_e1);
+ }
+ else
+ predecessor1->set_successor(new_e1);
+
+ if(predecessor2 == NULL)
+ {
+ new_e2->set_successor(strict_e_a2->get_first());
+ strict_e_a2->set_first(new_e2);
+ }
+ else
+ predecessor2->set_successor(new_e2);
+ }
+ }
+}
Added: trunk/src/membership/diff_impl.h
===================================================================
--- trunk/src/membership/diff_impl.h (rev 0)
+++ trunk/src/membership/diff_impl.h 2011-02-02 23:57:58 UTC (rev 1030)
@@ -0,0 +1,156 @@
+/*
+ * scstudio - Sequence Chart Studio
+ * http://scstudio.sourceforge.net
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * Copyright (c) 2008 Matus Madzin <go...@ma...>
+ *
+ */
+
+#ifndef __DIFF_IMPL__
+#define __DIFF_IMPL__
+
+#include "membership_additional.h"
+
+enum Operation {INSERT, DELETE};
+enum Direction {SEND, RECEIVE};
+
+class Distance
+{
+private:
+ StrictEventPtr event;
+ int line;
+
+public:
+ Distance(StrictEventPtr e, int l)
+ {
+ event = e;
+ line = l;
+ }
+
+ StrictEventPtr getEvent()
+ {
+ return event;
+ }
+
+ void setEvent(StrictEventPtr e)
+ {
+ event = e;
+ }
+
+ int getLine()
+ {
+ return line;
+ }
+
+ void setLine(int l)
+ {
+ line = l;
+ }
+};
+
+class Difference
+{
+private:
+ Difference* previous;
+ StrictEventPtr location;
+ MscMessagePtr message;
+ enum Direction dir;
+ enum Operation op;
+ int line1;
+ int line2;
+
+public:
+ Difference()
+ {
+ previous = NULL;
+ }
+
+ void setPrevious(Difference* diff)
+ {
+ previous = diff;
+ }
+
+ Difference* getPrevious()
+ {
+ return previous;
+ }
+
+ void setOperation(enum Operation operation)
+ {
+ op = operation;
+ }
+
+ enum Operation getOperation()
+ {
+ return op;
+ }
+
+ void setLine1(int row)
+ {
+ line1 = row;
+ }
+
+ int getLine1()
+ {
+ return line1;
+ }
+
+ void setLine2(int col)
+ {
+ line2 = col;
+ }
+
+ int getLine2()
+ {
+ return line2;
+ }
+
+ void setLocation(StrictEventPtr e)
+ {
+ location = e;
+ }
+
+ StrictEventPtr getLocation()
+ {
+ return location;
+ }
+
+ /**
+ * parameter m - message connected with the event
+ * (DELETE - message of deleted event)
+ * (INSERT - message which is supposed to add)
+ * send - bool whether the event is supposed to be send.
+ */
+ void setMessage(MscMessagePtr m, bool send)
+ {
+ message = m;
+
+ if(send)
+ dir = SEND;
+ else
+ dir = RECEIVE;
+ }
+
+ MscMessagePtr getMessage()
+ {
+ return message;
+ }
+
+ enum Direction getDirection()
+ {
+ return dir;
+ }
+};
+
+void diff(InstancePtr first, InstancePtr second);
+
+#endif
Modified: trunk/src/membership/membership_base.h
===================================================================
--- trunk/src/membership/membership_base.h 2011-02-02 22:17:59 UTC (rev 1029)
+++ trunk/src/membership/membership_base.h 2011-02-02 23:57:58 UTC (rev 1030)
@@ -800,6 +800,9 @@
//! Finds the bmsc flow in hmsc specification
virtual MscPtr find(MscPtr hmsc, MscPtr bmsc);
+
+ //! Make diff between specification and flow
+ virtual MscPtr diff(MscPtr specification, BMscPtr flow);
//! Finds each bmsc flow from the vector in hmsc specification
virtual MscPtr find(MscPtr hmsc, std::vector<MscPtr>& bmscs);
Modified: trunk/tests/CMakeLists.txt
===================================================================
--- trunk/tests/CMakeLists.txt 2011-02-02 22:17:59 UTC (rev 1029)
+++ trunk/tests/CMakeLists.txt 2011-02-02 23:57:58 UTC (rev 1030)
@@ -113,6 +113,7 @@
ADD_SUBDIRECTORY(z120_test)
ADD_SUBDIRECTORY(membership)
+ADD_SUBDIRECTORY(diff)
ADD_SUBDIRECTORY(montecarlo)
ADD_EXECUTABLE(checker_test
Added: trunk/tests/diff/CMakeLists.txt
===================================================================
--- trunk/tests/diff/CMakeLists.txt (rev 0)
+++ trunk/tests/diff/CMakeLists.txt 2011-02-02 23:57:58 UTC (rev 1030)
@@ -0,0 +1,23 @@
+ADD_EXECUTABLE(diff_test
+ diff_test.cpp
+)
+
+TARGET_LINK_LIBRARIES(diff_test
+ scmembership
+ scpseudocode
+ scmsc
+ scZ120
+)
+
+#ADD_MEMBERSHIP_TEST(sctime "Correct Time Constraint Syntax" connector_correct0.mpr 1)
+
+#ADD_MEMBERSHIP_TEST(test_hmsc01 test_bmsc01 1)
+
+GET_TARGET_PROPERTY(DIFF_TEST_EXECUTABLE diff_test LOCATION)
+# Replace the "$(IntDir)", "$(OutDir)", or "$(CONFIGURATION)"
+# depending on the generator being used with the test-time variable.
+STRING(REGEX REPLACE "\\$\\(.*\\)" "\${CTEST_CONFIGURATION_TYPE}"
+ DIFF_TEST_EXECUTABLE "${DIFF_TEST_EXECUTABLE}")
+
+ADD_TEST(diff_test-01 ${DIFF_TEST_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/spec01.mpr ${CMAKE_CURRENT_SOURCE_DIR}/flow01.mpr 1)
+
Added: trunk/tests/diff/diff_test.cpp
===================================================================
--- trunk/tests/diff/diff_test.cpp (rev 0)
+++ trunk/tests/diff/diff_test.cpp 2011-02-02 23:57:58 UTC (rev 1030)
@@ -0,0 +1,142 @@
+/*
+ * scstudio - Sequence Chart Studio
+ * http://scstudio.sourceforge.net
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * Copyright (c) 2009 Matus Madzin <go...@ma...>
+ *
+ */
+
+#include <string.h>
+#include <iostream>
+
+#include "data/Z120/z120.h"
+#include "membership/membership_alg.h"
+
+char* extract_filename(char* filename)
+{
+ char *last_name = filename;
+ char *last_dot = NULL;
+
+ for(char *pos = filename; *pos != '\0'; pos++)
+ {
+ if(*pos == '.')
+ last_dot = pos;
+ else if(*pos == '\\' || *pos == '/')
+ last_name = pos+1;
+ }
+
+ if(last_dot != NULL)
+ *last_dot = '\0'; // strip the extension
+
+ return last_name;
+}
+
+int main(int argc, char** argv)
+{
+ if(argc < 4)
+ {
+ std::cerr << "Usage: " << argv[0] << " <filename> <filename> <satisfied>" << std::endl;
+ return 1;
+ }
+
+ std::vector<std::wstring> focused_instances;
+
+ for(int i = 4; i < argc; i++)
+ {
+ std::string s = argv[i];
+ std::wstring temp(s.length(),L' ');
+ std::copy(s.begin(), s.end(), temp.begin());
+
+ focused_instances.push_back(temp);
+ }
+
+ Z120 z120;
+
+ StreamReportPrinter printer(std::wcerr);
+ z120.set_printer(&printer);
+
+ int errors = 0;
+
+ char *endptr;
+ int satisfied = strtol(argv[3], &endptr, 10);
+ if(*argv[3] == '\0' || *endptr != '\0')
+ {
+ std::cerr << "ERROR: Not a boolean value: " << argv[3] << std::endl;
+ return 1;
+ }
+
+ std::vector<MscPtr> msc;
+ std::vector<MscPtr> msc_b;
+
+ try
+ {
+ msc = z120.load_msc(argv[1]);
+ }
+ catch(std::exception& exc)
+ {
+ std::cerr << "EXCEPTION: " << exc.what() << std::endl;
+ }
+
+ try
+ {
+ msc_b = z120.load_msc(argv[2]);
+ }
+ catch(std::exception& exc)
+ {
+ std::cerr << "EXCEPTION: " << exc.what() << std::endl;
+ }
+
+ MembershipAlg mem;
+ mem.set_printer(&printer);
+
+ BMscPtr bmsc = boost::dynamic_pointer_cast<BMsc>(msc_b[0]);
+
+ MscPtr result;
+
+ result = mem.diff(msc[0], bmsc);
+
+ if(result == NULL)
+ {
+std::cerr << "result was null" << std::endl;
+ if(satisfied)
+ {
+ std::cerr << "ERROR: HMSC should contain bMSC" << std::endl;
+ errors = 1;
+ }
+ else
+ std::cerr << "OK: HMSC doesn't contain bMSC" << std::endl;
+ }
+ else
+ {
+ if(satisfied)
+ std::cerr << "OK: HMSC contains bMSC" << std::endl;
+ else
+ {
+ std::cerr << "ERROR: HMSC should not contain bMSC" << std::endl;
+ errors = 1;
+ }
+
+ std::cout << std::endl;
+
+ try
+ {
+ z120.save_msc(std::cout, L"msc_diff", result);
+ }
+ catch(std::exception& exc)
+ {
+ std::cerr << "EXCEPTION: Cannot save the document: " << exc.what() << std::endl;
+ errors = 1;
+ }
+ }
+
+ return errors;
+}
Added: trunk/tests/diff/flow01.mpr
===================================================================
--- trunk/tests/diff/flow01.mpr (rev 0)
+++ trunk/tests/diff/flow01.mpr 2011-02-02 23:57:58 UTC (rev 1030)
@@ -0,0 +1,22 @@
+mscdocument Drawing1;
+msc Page_1;
+inst A;
+inst B;
+inst C;
+A: instance;
+out a,0 to B;
+out b,1 to B;
+out c,3 to B;
+endinstance;
+B: instance;
+in a,0 from A;
+in b,1 from A;
+in c,3 from A;
+in a,2 from C;
+in d,4 from C;
+endinstance;
+C: instance;
+out a,2 to B;
+out d,4 to B;
+endinstance;
+endmsc;
Added: trunk/tests/diff/flow02_1.mpr
===================================================================
--- trunk/tests/diff/flow02_1.mpr (rev 0)
+++ trunk/tests/diff/flow02_1.mpr 2011-02-02 23:57:58 UTC (rev 1030)
@@ -0,0 +1,13 @@
+mscdocument Drawing1;
+msc Page_1;
+inst A;
+inst B;
+A: instance;
+out a,0 to B;
+out c,3 to B;
+endinstance;
+B: instance;
+in a,0 from A;
+in c,3 from A;
+endinstance;
+endmsc;
Added: trunk/tests/diff/flow02_2.mpr
===================================================================
--- trunk/tests/diff/flow02_2.mpr (rev 0)
+++ trunk/tests/diff/flow02_2.mpr 2011-02-02 23:57:58 UTC (rev 1030)
@@ -0,0 +1,13 @@
+mscdocument Drawing1;
+msc Page_1;
+inst A;
+inst B;
+A: instance;
+out b,1 to B;
+out c,3 to B;
+endinstance;
+B: instance;
+in b,1 from A;
+in c,3 from A;
+endinstance;
+endmsc;
Added: trunk/tests/diff/flow02_3.mpr
===================================================================
--- trunk/tests/diff/flow02_3.mpr (rev 0)
+++ trunk/tests/diff/flow02_3.mpr 2011-02-02 23:57:58 UTC (rev 1030)
@@ -0,0 +1,13 @@
+mscdocument Drawing1;
+msc Page_1;
+inst A;
+inst B;
+A: instance;
+out a,0 to B;
+out b,1 to B;
+endinstance;
+B: instance;
+in a,0 from A;
+in b,1 from A;
+endinstance;
+endmsc;
Added: trunk/tests/diff/spec01.mpr
===================================================================
--- trunk/tests/diff/spec01.mpr (rev 0)
+++ trunk/tests/diff/spec01.mpr 2011-02-02 23:57:58 UTC (rev 1030)
@@ -0,0 +1,22 @@
+mscdocument Drawing1;
+msc Page_1;
+inst A;
+inst B;
+inst C;
+C: instance;
+out a,0 to B;
+out b,1 to B;
+out c,3 to B;
+endinstance;
+B: instance;
+in a,0 from C;
+in b,1 from C;
+in c,3 from C;
+in a,2 from A;
+in d,4 from A;
+endinstance;
+A: instance;
+out a,2 to B;
+out d,4 to B;
+endinstance;
+endmsc;
Added: trunk/tests/diff/spec02.mpr
===================================================================
--- trunk/tests/diff/spec02.mpr (rev 0)
+++ trunk/tests/diff/spec02.mpr 2011-02-02 23:57:58 UTC (rev 1030)
@@ -0,0 +1,15 @@
+mscdocument Drawing1;
+msc Page_1;
+inst A;
+inst B;
+A: instance;
+out a,0 to B;
+out b,1 to B;
+out c,3 to B;
+endinstance;
+B: instance;
+in a,0 from A;
+in b,1 from A;
+in c,3 from A;
+endinstance;
+endmsc;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ma...@us...> - 2011-02-09 19:47:07
|
Revision: 1037
http://scstudio.svn.sourceforge.net/scstudio/?rev=1037&view=rev
Author: madzin
Date: 2011-02-09 19:47:01 +0000 (Wed, 09 Feb 2011)
Log Message:
-----------
Change diff interface, set position of new elements in the flow
Modified Paths:
--------------
trunk/src/data/msc.h
trunk/src/membership/diff_impl.cpp
trunk/src/membership/membership_base.h
trunk/tests/diff/diff_test.cpp
Modified: trunk/src/data/msc.h
===================================================================
--- trunk/src/data/msc.h 2011-02-09 11:05:45 UTC (rev 1036)
+++ trunk/src/data/msc.h 2011-02-09 19:47:01 UTC (rev 1037)
@@ -1623,6 +1623,11 @@
void glue_event(const EventPtr& event);
+ Event* get_event()
+ {
+ return m_event;
+ }
+
virtual bool is_glued() const
{
return m_event != NULL;
Modified: trunk/src/membership/diff_impl.cpp
===================================================================
--- trunk/src/membership/diff_impl.cpp 2011-02-09 11:05:45 UTC (rev 1036)
+++ trunk/src/membership/diff_impl.cpp 2011-02-09 19:47:01 UTC (rev 1037)
@@ -58,9 +58,16 @@
* parameters: a - specification
* b - flow
*/
-MscPtr MembershipAlg::diff(MscPtr specification, MscPtr msc_flow)
+MscPtr MembershipAlg::diff(MscPtr specification, std::vector<MscPtr>& msc_flows)
{
- BMscPtr flow = boost::dynamic_pointer_cast<BMsc> (msc_flow);
+ //TODO redirect the output messages
+ if(msc_flows.size() > 1)
+ std::cerr << "Warning: in this version, it is supported for one flow, others is ignored" << std::endl;
+
+ if(msc_flows.size() == 0)
+ std::cerr << "Error: No flow was chosen for checking" << std::endl;
+
+ BMscPtr flow = boost::dynamic_pointer_cast<BMsc> (msc_flows[0]);
if(flow == NULL)
{
@@ -381,7 +388,7 @@
return NULL;
}
-StrictOrderAreaPtr get_proper_area(BMscPtr flow, std::wstring inst_name)
+StrictOrderAreaPtr get_proper_area(BMscPtr flow, Difference* diff, std::wstring inst_name)
{
InstancePtrList instances = flow->get_instances();
InstancePtrList::iterator instances_it;
@@ -396,8 +403,28 @@
StrictOrderAreaPtr s_e_a;
if(instances_it == instances.end())
- {
+ {
+ InstancePtr original;
+
+ CompleteMessagePtr com_msg = boost::dynamic_pointer_cast<CompleteMessage>(diff->getMessage());
+
+ if(com_msg != NULL)
+ {
+ if(diff->getDirection() == SEND)
+ original = com_msg->get_sender();
+ else
+ original = com_msg->get_receiver();
+ }
+ else
+ {
+ IncompleteMessagePtr incom_msg = boost::dynamic_pointer_cast<IncompleteMessage>(diff->getMessage());
+ original = incom_msg->get_event()->get_instance();
+ }
+
InstancePtr inst = new Instance(inst_name);
+ inst->set_line_begin(original->get_line_begin());
+ inst->set_line_end(original->get_line_end());
+
flow->add_instance(inst);
s_e_a = new StrictOrderArea();
s_e_a->set_instance(inst.get());
@@ -419,6 +446,54 @@
return s_e_a;
}
+void set_event_position(StrictEventPtr e, Difference* diff, std::wstring inst_name, BMscPtr flow)
+{
+ InstancePtrList insts = flow->get_instances();
+ InstancePtrList::iterator it;
+ InstancePtr inst = NULL;
+
+ for(it = insts.begin(); it != insts.end(); it++)
+ {
+ if((*it)->get_label() == inst_name)
+ {
+ inst = *it;
+ break;
+ }
+ }
+
+ MscPoint position, start_p, end_p;
+
+ if(inst == NULL)
+ throw std::runtime_error("Error: unexpected behaviour");
+
+ if(diff->getLocation() == NULL)
+ {
+ start_p = inst->get_line_begin();
+
+ StrictOrderAreaPtr s_e_a = boost::dynamic_pointer_cast<StrictOrderArea>(inst->get_first());
+
+ if(s_e_a == NULL || s_e_a->get_first() == NULL)
+ end_p = inst->get_line_end();
+ else
+ end_p = s_e_a->get_first()->get_position();
+ }
+ else
+ {
+ start_p = diff->getLocation()->get_position();
+ StrictEventPtr original_successor = diff->getLocation()->get_successor();
+
+ if(original_successor != NULL)
+ end_p = original_successor->get_position();
+ else
+ end_p = diff->getLocation()->get_instance()->get_line_end();
+ }
+
+ double x = start_p.get_x() + (end_p.get_x() - start_p.get_x())/2;
+ double y = start_p.get_y() + (end_p.get_y() - start_p.get_y())/2;
+ position = MscPoint(x,y);
+ e->set_position(position);
+}
+
/*
* create new event and incomplete message
* then add it to the proper ordering
@@ -426,6 +501,7 @@
void add_incomplete_message(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);
IncompleteMessagePtr new_msg = new IncompleteMessage(
msg->is_lost() ? LOST : FOUND,
@@ -437,7 +513,7 @@
if(diff->getLocation() != NULL)
diff->getLocation()->set_successor(new_e);
else
- get_proper_area(dup_flow, ins_name)->set_first(new_e);
+ get_proper_area(dup_flow, diff, ins_name)->set_first(new_e);
}
void add_complete_message(BMscPtr dup_flow, Difference* diff, Difference* match_diff,
@@ -447,21 +523,24 @@
StrictEventPtr predecessor1 = diff->getLocation();
StrictEventPtr predecessor2 = match_diff->getLocation();
- StrictEventPtr new_e1 = new StrictEvent();
- StrictEventPtr new_e2 = new StrictEvent();
-
StrictOrderAreaPtr strict_e_a1, strict_e_a2;
if(predecessor1 == NULL)
- strict_e_a1 = get_proper_area(dup_flow, inst_name);
+ 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, match_inst_name);
+ 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());
Modified: trunk/src/membership/membership_base.h
===================================================================
--- trunk/src/membership/membership_base.h 2011-02-09 11:05:45 UTC (rev 1036)
+++ trunk/src/membership/membership_base.h 2011-02-09 19:47:01 UTC (rev 1037)
@@ -802,7 +802,7 @@
virtual MscPtr find(MscPtr hmsc, MscPtr bmsc);
//! Make diff between specification and flow
- virtual MscPtr diff(MscPtr specification, MscPtr flow);
+ virtual MscPtr diff(MscPtr specification, std::vector<MscPtr>& flows);
//! Finds each bmsc flow from the vector in hmsc specification
virtual MscPtr find(MscPtr hmsc, std::vector<MscPtr>& bmscs);
Modified: trunk/tests/diff/diff_test.cpp
===================================================================
--- trunk/tests/diff/diff_test.cpp 2011-02-09 11:05:45 UTC (rev 1036)
+++ trunk/tests/diff/diff_test.cpp 2011-02-09 19:47:01 UTC (rev 1037)
@@ -100,11 +100,9 @@
MembershipAlg mem;
mem.set_printer(&printer);
- BMscPtr bmsc = boost::dynamic_pointer_cast<BMsc>(msc_b[0]);
-
MscPtr result;
- result = mem.diff(msc[0], bmsc);
+ result = mem.diff(msc[0], msc_b);
if(result == NULL)
{
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ma...@us...> - 2011-02-17 18:01:04
|
Revision: 1041
http://scstudio.svn.sourceforge.net/scstudio/?rev=1041&view=rev
Author: madzin
Date: 2011-02-17 18:00:58 +0000 (Thu, 17 Feb 2011)
Log Message:
-----------
Fix bug in message addition.
Modified Paths:
--------------
trunk/src/membership/diff_impl.cpp
trunk/src/membership/diff_impl.h
trunk/tests/diff/CMakeLists.txt
Modified: trunk/src/membership/diff_impl.cpp
===================================================================
--- trunk/src/membership/diff_impl.cpp 2011-02-15 17:34:51 UTC (rev 1040)
+++ trunk/src/membership/diff_impl.cpp 2011-02-17 18:00:58 UTC (rev 1041)
@@ -102,8 +102,8 @@
StrictOrderAreaPtr a_soa = boost::dynamic_pointer_cast<StrictOrderArea > (a_area);
StrictOrderAreaPtr b_soa = boost::dynamic_pointer_cast<StrictOrderArea > (b_area);
- StrictEventPtr event_a = a_soa->get_first();
- StrictEventPtr event_b = b_soa->get_first();
+ StrictEventPtr event_a = a_soa!=NULL ? a_soa->get_first() : NULL;
+ StrictEventPtr event_b = b_soa!=NULL ? b_soa->get_first() : NULL;
StrictEventPtr start_a, start_b;
@@ -435,9 +435,13 @@
EventAreaPtr e_a = (*instances_it)->get_first();
if(e_a == NULL)
- throw std::runtime_error("Error: unexpected behaviour");
-
- s_e_a = boost::dynamic_pointer_cast<StrictOrderArea> (e_a);
+ {
+ s_e_a = new StrictOrderArea();
+ s_e_a->set_instance(instances_it->get());
+ (*instances_it)->set_first(s_e_a);
+ }
+ else
+ s_e_a = boost::dynamic_pointer_cast<StrictOrderArea> (e_a);
}
if(s_e_a == NULL)
@@ -497,6 +501,11 @@
/*
* create new event and incomplete message
* then add it to the proper ordering
+ *
+ * parameters - bmsc
+ * - diff, difference to process
+ * - msg, original message which is supposed to add
+ * - ins_name
*/
void add_incomplete_message(BMscPtr dup_flow, Difference* diff, IncompleteMessagePtr msg, std::wstring ins_name)
{
@@ -574,6 +583,30 @@
predecessor2->set_successor(new_e2);
}
+StrictEventPtr create_event(BMscPtr dup_flow, Difference* diff, std::wstring inst_name)
+{
+ StrictEventPtr predecessor = diff->getLocation();
+ StrictOrderAreaPtr strict_e_a;
+
+ if(predecessor == NULL)
+ strict_e_a = get_proper_area(dup_flow, diff, inst_name);
+ else
+ strict_e_a = predecessor->get_area();
+
+ StrictEventPtr new_e = new StrictEvent();
+ set_event_position(new_e, diff, inst_name, dup_flow);
+
+ new_e->set_area(strict_e_a.get());
+ new_e->set_marked(ADDED);
+
+ if(predecessor == NULL)
+ strict_e_a->set_first(new_e);
+ else
+ predecessor->set_successor(new_e);
+
+ return new_e;
+}
+
void process_diffrences(BMscPtr dup_flow, const std::map<std::wstring, Difference*>& diff_map)
{
std::map<std::wstring, Difference*>::const_iterator it;
@@ -604,8 +637,10 @@
insert_map.insert(std::make_pair(it->first, insert_list));
}
- std::set<Difference*> recently_processed;
std::map<std::wstring, std::list<Difference*> >::iterator ins_map_it;
+ std::map<std::wstring, std::set<Unmatched*> > unmatched_map;
+ std::map<std::wstring, std::set<Unmatched*> >::iterator unmatched_map_it;
+
for (ins_map_it = insert_map.begin(); ins_map_it != insert_map.end(); ins_map_it++)
{
std::list<Difference*> insert_list = ins_map_it->second;
@@ -613,9 +648,6 @@
for (ins_list_it = insert_list.begin(); ins_list_it != insert_list.end(); ins_list_it++)
{
- if(recently_processed.find(*ins_list_it) != recently_processed.end())
- continue;
-
MscMessagePtr message = (*ins_list_it)->getMessage();
CompleteMessagePtr com_msg = boost::dynamic_pointer_cast<CompleteMessage> (message);
@@ -627,30 +659,70 @@
continue;
}
- std::wstring match_inst;
+ unmatched_map_it = unmatched_map.find(ins_map_it->first);
- if ((*ins_list_it)->getDirection() == SEND)
- match_inst = com_msg->get_receiver()->get_label();
- else
- match_inst = com_msg->get_sender()->get_label();
+ //create new record in unmatched_map
+ if(unmatched_map_it == unmatched_map.end())
+ {
+ std::wstring match_inst;
- std::list<Difference*> match_insert_list = insert_map.find(match_inst)->second;
- std::list<Difference*>::iterator match_ins_list_it;
- Difference* match_diff;
+ if ((*ins_list_it)->getDirection() == SEND)
+ match_inst = com_msg->get_receiver()->get_label();
+ else
+ match_inst = com_msg->get_sender()->get_label();
+
+ //create new event and add it as unmatched
+ StrictEventPtr new_e = create_event(dup_flow, *ins_list_it, ins_map_it->first);
+ Unmatched* unmatched = new Unmatched(new_e, message);
- for (match_ins_list_it = match_insert_list.begin();
- match_ins_list_it != match_insert_list.end();
- match_ins_list_it++)
+ std::map<std::wstring, std::set<Unmatched*> >::iterator match_it = unmatched_map.find(match_inst);
+
+ if(match_it == unmatched_map.end())
+ {
+ std::set<Unmatched*> unmatched_set;
+ unmatched_set.insert(unmatched);
+ unmatched_map.insert(std::make_pair(match_inst, unmatched_set));
+ }
+ else
+ match_it->second.insert(unmatched);
+ continue;
+ }
+
+ bool was_created = false;
+ std::set<Unmatched*> unmatched_set = unmatched_map_it->second;
+ std::set<Unmatched*>::iterator unmatched_set_it;
+
+ for(unmatched_set_it = unmatched_set.begin(); unmatched_set_it != unmatched_set.end(); unmatched_set_it++)
{
- if ((*match_ins_list_it)->getMessage() == message)
+ if(com_msg == (*unmatched_set_it)->getMessage())
{
- match_diff = *match_ins_list_it;
- break;
+ StrictEventPtr new_e = create_event(dup_flow, *ins_list_it, ins_map_it->first);
+
+ CompleteMessagePtr new_msg = new CompleteMessage(message->get_label());
+ new_msg->set_marked(ADDED);
+
+ if((*ins_list_it)->getDirection() == SEND)
+ new_msg->glue_events(new_e, (*unmatched_set_it)->getEvent());
+ else
+ new_msg->glue_events((*unmatched_set_it)->getEvent(), new_e);
+
+ was_created = true;
}
}
- recently_processed.insert(match_diff);
- add_complete_message(dup_flow, *ins_list_it, match_diff, com_msg, ins_map_it->first, match_inst);
+ if(!was_created)
+ {
+ std::wstring match_inst;
+
+ if ((*ins_list_it)->getDirection() == SEND)
+ match_inst = com_msg->get_receiver()->get_label();
+ else
+ match_inst = com_msg->get_sender()->get_label();
+
+ StrictEventPtr new_e = create_event(dup_flow, *ins_list_it, ins_map_it->first);
+ Unmatched* unmatched = new Unmatched(new_e, message);
+ unmatched_map_it->second.insert(unmatched);
+ }
}
}
}
Modified: trunk/src/membership/diff_impl.h
===================================================================
--- trunk/src/membership/diff_impl.h 2011-02-15 17:34:51 UTC (rev 1040)
+++ trunk/src/membership/diff_impl.h 2011-02-17 18:00:58 UTC (rev 1041)
@@ -57,6 +57,30 @@
}
};
+class Unmatched
+{
+private:
+ StrictEventPtr event;
+ MscMessagePtr original_message;
+
+public:
+ Unmatched(StrictEventPtr e, MscMessagePtr m)
+ {
+ event = e;
+ original_message = m;
+ }
+
+ StrictEventPtr getEvent()
+ {
+ return event;
+ }
+
+ MscMessagePtr getMessage()
+ {
+ return original_message;
+ }
+};
+
class Difference
{
private:
Modified: trunk/tests/diff/CMakeLists.txt
===================================================================
--- trunk/tests/diff/CMakeLists.txt 2011-02-15 17:34:51 UTC (rev 1040)
+++ trunk/tests/diff/CMakeLists.txt 2011-02-17 18:00:58 UTC (rev 1041)
@@ -27,4 +27,6 @@
ADD_DIFF_TEST(spec04.mpr flow04_2.mpr 1)
ADD_DIFF_TEST(spec04.mpr flow04_3.mpr 1)
ADD_DIFF_TEST(spec04.mpr flow04_4.mpr 1)
+ADD_DIFF_TEST(spec05.mpr flow05_1.mpr 1)
+ADD_DIFF_TEST(spec06.mpr flow06_1.mpr 1)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ma...@us...> - 2011-02-27 16:01:25
|
Revision: 1051
http://scstudio.svn.sourceforge.net/scstudio/?rev=1051&view=rev
Author: madzin
Date: 2011-02-27 16:01:18 +0000 (Sun, 27 Feb 2011)
Log Message:
-----------
Add attribute checking to the diff algorithm
Modified Paths:
--------------
trunk/src/membership/diff_impl.cpp
trunk/src/membership/diff_impl.h
trunk/src/membership/membership_additional.cpp
trunk/src/membership/membership_additional.h
trunk/src/membership/membership_base.h
trunk/tests/diff/CMakeLists.txt
Added Paths:
-----------
trunk/tests/diff/flow05_1.mpr
trunk/tests/diff/flow05_1.mpr.result
trunk/tests/diff/flow05_2.mpr
trunk/tests/diff/flow05_2.mpr.result
trunk/tests/diff/flow06_1.mpr
trunk/tests/diff/flow06_1.mpr.result
trunk/tests/diff/spec05.mpr
trunk/tests/diff/spec06.mpr
trunk/tests/diff/spec07.mpr
Modified: trunk/src/membership/diff_impl.cpp
===================================================================
--- trunk/src/membership/diff_impl.cpp 2011-02-23 19:26:36 UTC (rev 1050)
+++ trunk/src/membership/diff_impl.cpp 2011-02-27 16:01:18 UTC (rev 1051)
@@ -17,7 +17,8 @@
#include "membership/diff_impl.h"
-void process_diffrences(BMscPtr dup_flow, const std::map<std::wstring, Difference*>& diff_map);
+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);
void print_result(Difference* diff)
{
@@ -41,17 +42,41 @@
std::cerr << "===============================" << std::endl;
}
+void print_result(BMscPtr msc)
+{
+ InstancePtrList insts = msc->get_instances();
+ InstancePtrList::iterator it;
+ bool setting;
+
+ for(it = insts.begin(); it != insts.end(); it++)
+ {
+ std::wcerr << L"Instance " << (*it)->get_label() << std::endl;
+
+ StrictOrderAreaPtr area = boost::dynamic_pointer_cast<StrictOrderArea> ((*it)->get_first());
+ StrictEventPtr st = area->get_first();
+
+ while(st != NULL)
+ {
+ std::wcerr << st->get_message()->get_label() << L" id: " << st->get_attribute("identification", -3, setting) << L" ";
+ std::wcerr << L" removed: " << (st->get_marked()==REMOVED) << std::endl;
+ st = st->get_successor();
+ }
+ }
+}
+
/**
* Find diffrences on instance between flow and specification
*
* parameters: a - flow
* b - specification
*/
-Difference* instance_diff(InstancePtr a, InstancePtr b);
+Difference* instance_diff(MembershipContext* c, InstancePtr a, InstancePtr b);
-BMscPtr bmsc_bmsc_diff(BMscPtr specification, BMscPtr flow);
-BMscPtr hmsc_bmsc_diff(HMscPtr specification, BMscPtr flow);
+bool event_comparison(MembershipContext* c, StrictEventPtr& a, StrictEventPtr b);
+BMscPtr bmsc_bmsc_diff(MembershipContext* c, BMscPtr specification, BMscPtr flow);
+BMscPtr hmsc_bmsc_diff(MembershipContext* c, HMscPtr specification, BMscPtr flow);
+
/**
* Find msc diffrences between flow and specification
*
@@ -79,20 +104,24 @@
}
BMscPtr bmsc = boost::dynamic_pointer_cast<BMsc> (specification);
+
+ //TODO refactoring flow BMSC get to MembershipContext and start to use it (not as the parameter)
+ MembershipContext* c = new MembershipContext();
+ c->set_mem(this);
if (bmsc == NULL)
{
HMscPtr hmsc = boost::dynamic_pointer_cast<HMsc > (specification);
- return hmsc_bmsc_diff(hmsc, flow);
+ return hmsc_bmsc_diff(c, hmsc, flow);
}
else
- return bmsc_bmsc_diff(bmsc, flow);
+ return bmsc_bmsc_diff(c, bmsc, flow);
}
//Instance "a" - flow
//Instance "b" - specification
-Difference* instance_diff(InstancePtr a, InstancePtr b)
+Difference* instance_diff(MembershipContext* c, InstancePtr a, InstancePtr b)
{
std::vector<StrictEventPtr> a_ordering;
std::vector<StrictEventPtr> b_ordering;
@@ -115,17 +144,24 @@
if (event_b != NULL)
start_b = event_b;
- //TODO check what is in context, maybe it is necessary to replace it.
- MembershipContext* c = new MembershipContext();
-
- while (event_a != NULL || event_b != NULL)
+ while (event_a != NULL && event_b != NULL)
{
- if (!compare_events(c, event_a.get(), event_b.get()))
- break;
+ if (!event_comparison(c, event_a, event_b))
+ break;
row++;
+
+ if(c->get_diff_type() == MESSAGE)
+ set_identification(c, event_a.get(), event_b.get());
+
event_a = event_a->get_successor();
event_b = event_b->get_successor();
+
+ //the algorithm skips REMOVED events in attributes checking part
+ while(event_a != NULL && event_a->get_marked() == REMOVED)
+ {
+ event_a = event_a->get_successor();
+ }
}
int lower, upper;
@@ -245,6 +281,20 @@
diff->setLocation(location);
diff->setMessage(missing->get_message(), missing->is_send());
+
+ if(c->get_diff_type() == ATTRIBUTE)
+ {
+ EventPtr missing_match_event = missing->get_matching_event();
+
+ if(missing_match_event == NULL)
+ throw std::runtime_error("Error: unexpected bahaviour");
+
+ bool set_value = false;
+ diff->setAttribute(missing_match_event->get_attribute("identification", -1, set_value));
+
+ if(set_value)
+ throw std::runtime_error("Error: unexpected bahaviour");
+ }
}
int old_col = col;
@@ -275,8 +325,11 @@
script[k] = diff;
- while (event_a != NULL && event_b != NULL && compare_events(c, event_a.get(), event_b.get()))
+ while (event_a != NULL && event_b != NULL && event_comparison(c, event_a, event_b))
{
+ if(c->get_diff_type() == MESSAGE)
+ set_identification(c, event_a.get(), event_b.get());
+
event_a = event_a->get_successor();
event_b = event_b->get_successor();
row++;
@@ -288,10 +341,6 @@
if (event_a == NULL && event_b == NULL)
// hit southeast corner, have the answer
return script[k];
-//{
-//print_result(script[k]);
-//return NULL;
-//}
if (event_a == NULL)
// hit the last row, don't look to the left
@@ -310,12 +359,13 @@
throw std::runtime_error("Error: I don't know");
}
-BMscPtr bmsc_bmsc_diff(BMscPtr specification, BMscPtr flow)
+BMscPtr bmsc_bmsc_diff(MembershipContext* c, BMscPtr specification, BMscPtr flow)
{
BMscDuplicator duplicator;
BMscPtr dup_flow;
dup_flow = duplicator.duplicate(flow);
+ c->set_bmsc(dup_flow);
InstancePtrList spec_inst = specification->get_instances();
InstancePtrList flow_inst = dup_flow->get_instances();
@@ -335,7 +385,7 @@
{
if ((*spec_it)->get_label() == (*flow_it)->get_label())
{
- Difference* diff = instance_diff(*flow_it, *spec_it);
+ Difference* diff = instance_diff(c, *flow_it, *spec_it);
if(diff != NULL)
diff_map.insert(std::make_pair((*flow_it)->get_label(), diff));
@@ -378,16 +428,30 @@
if(!diff_map.empty())
{
- process_diffrences(dup_flow, diff_map);
+ process_diffrences(c, dup_flow, diff_map);
+ check_attributes(c, specification, dup_flow);
+
+ c->clear_attributed_events();
return dup_flow;
}
else
- return NULL;
+ {
+ if(check_attributes(c, specification, dup_flow))
+ {
+ c->clear_attributed_events();
+ return dup_flow;
+ }
+ else
+ {
+ c->clear_attributed_events();
+ return NULL;
+ }
+ }
}
-BMscPtr hmsc_bmsc_diff(HMscPtr specification, BMscPtr flow)
+BMscPtr hmsc_bmsc_diff(MembershipContext* c, HMscPtr specification, BMscPtr flow)
{
-// print_report(RS_ERROR, L"Error: this feature is not supported yet");
+ c->get_mem()->print_report(RS_ERROR, L"Error: this feature is not supported yet");
return NULL;
}
@@ -511,7 +575,7 @@
* - msg, original message which is supposed to add
* - ins_name
*/
-void add_incomplete_message(BMscPtr dup_flow, Difference* diff, IncompleteMessagePtr msg, std::wstring ins_name)
+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);
@@ -527,6 +591,8 @@
diff->getLocation()->set_successor(new_e);
else
get_proper_area(dup_flow, diff, ins_name)->set_first(new_e);
+
+ set_identification(c, new_e.get(), msg->get_event());
}
void add_complete_message(BMscPtr dup_flow, Difference* diff, Difference* match_diff,
@@ -570,8 +636,6 @@
if(predecessor1 == NULL)
{
-// new_e1->set_successor(strict_e_a1->get_first());
-// strict_e_a1->get_first()->set_predecessor(new_e1);
strict_e_a1->set_first(new_e1);
}
else
@@ -579,8 +643,6 @@
if(predecessor2 == NULL)
{
-// new_e2->set_successor(strict_e_a2->get_first());
-// strict_e_a2->get_first()->set_predecessor(new_e2);
strict_e_a2->set_first(new_e2);
}
else
@@ -611,7 +673,7 @@
return new_e;
}
-void process_diffrences(BMscPtr dup_flow, const std::map<std::wstring, Difference*>& diff_map)
+void process_diffrences(MembershipContext* c, BMscPtr dup_flow, 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;
@@ -659,7 +721,7 @@
{
IncompleteMessagePtr in_msg = boost::dynamic_pointer_cast<IncompleteMessage > (message);
- add_incomplete_message(dup_flow, (*ins_list_it), in_msg, ins_map_it->first);
+ add_incomplete_message(c, dup_flow, (*ins_list_it), in_msg, ins_map_it->first);
continue;
}
@@ -702,7 +764,7 @@
{
StrictEventPtr new_e = create_event(dup_flow, *ins_list_it, ins_map_it->first);
- CompleteMessagePtr new_msg = new CompleteMessage(message->get_label());
+ CompleteMessagePtr new_msg = new CompleteMessage(com_msg->get_label());
new_msg->set_marked(ADDED);
if((*ins_list_it)->getDirection() == SEND)
@@ -710,12 +772,29 @@
else
new_msg->glue_events((*unmatched_set_it)->getEvent(), new_e);
+ if(new_e->is_send())
+ {
+ set_identification(c, new_e.get(), com_msg->get_send_event());
+ set_identification(c, (*unmatched_set_it)->getEvent().get(), com_msg->get_receive_event());
+ }
+ else
+ {
+ set_identification(c, (*unmatched_set_it)->getEvent().get(), com_msg->get_send_event());
+ set_identification(c, new_e.get(), com_msg->get_receive_event());
+ }
+
was_created = true;
+ break;
}
}
- if(!was_created)
+ if(was_created)
{
+ unmatched_set.erase(unmatched_set_it);
+ unmatched_map_it->second = unmatched_set;
+ }
+ else
+ {
std::wstring match_inst;
if ((*ins_list_it)->getDirection() == SEND)
@@ -729,4 +808,170 @@
}
}
}
+
+
+ //check unmatched diffrences in unmatched map
+ for (unmatched_map_it = unmatched_map.begin(); unmatched_map_it != unmatched_map.end(); unmatched_map_it++)
+ {
+ std::set<Unmatched*> unmatched_set = unmatched_map_it->second;
+
+ if(!unmatched_set.empty())
+ std::wcerr << L"Warning: diff was not successfull" << std::endl;
+ }
+
}
+
+bool check_attributes(MembershipContext* c, BMscPtr specification, BMscPtr dup_flow)
+{
+ std::map<std::wstring, Difference*> diff_map;
+
+ InstancePtrList spec_insts = specification->get_instances();
+ InstancePtrList flow_insts = dup_flow->get_instances();
+ InstancePtrList::iterator flow_it;
+ InstancePtrList::iterator spec_it;
+ bool found = false;
+
+ c->set_diff_type(ATTRIBUTE);
+
+ for(spec_it = spec_insts.begin(); spec_it != spec_insts.end(); spec_it++)
+ {
+ for(flow_it = flow_insts.begin(); flow_it != flow_insts.end(); flow_it++)
+ {
+ if((*flow_it)->get_label() == (*spec_it)->get_label())
+ {
+ Difference* diff = instance_diff(c, *flow_it, *spec_it);
+
+ if(diff != NULL)
+ diff_map.insert(std::make_pair((*flow_it)->get_label(), diff));
+
+ found = true;
+ break;
+ }
+ }
+
+ if(!found)
+ throw std::runtime_error("Error: unexpected behaviour");
+ }
+
+ //process_diffrences
+ 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;
+
+ 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++)
+ {
+ std::list<Difference*> insert_list = ins_map_it->second;
+ std::list<Difference*>::iterator ins_list_it;
+
+ for (ins_list_it = insert_list.begin(); ins_list_it != insert_list.end(); ins_list_it++)
+ {
+ MscMessagePtr message = (*ins_list_it)->getMessage();
+ CompleteMessagePtr com_msg = boost::dynamic_pointer_cast<CompleteMessage> (message);
+
+ if (com_msg == NULL)
+ throw std::runtime_error("Error: unexpected behaviour");
+
+ std::wstring match_inst;
+ std::wstring inst;
+
+ if((*ins_list_it)->getDirection() == SEND)
+ {
+ inst = com_msg->get_sender()->get_label();
+ match_inst = com_msg->get_receiver()->get_label();
+ }
+ else
+ {
+ match_inst = com_msg->get_sender()->get_label();
+ inst = com_msg->get_receiver()->get_label();
+ }
+
+ MscMessagePtr m = (*ins_list_it)->getMessage();
+ CompleteMessagePtr commplete = boost::dynamic_pointer_cast<CompleteMessage>(m);
+ EventPtr e = commplete->get_send_event();
+ Event* match_e = find_event_on_instance_by_id(c, match_inst, (*ins_list_it)->getAttribute());
+
+ StrictEvent* match_se = dynamic_cast<StrictEvent*>(match_e);
+
+ if(match_se == NULL)
+ throw std::runtime_error("Error: unexpected behaviour");
+
+ //TODO skontrolovat ci sa eventu nastavi instancia a area atd.
+ StrictEventPtr new_match_e = new StrictEvent();
+//TODO set position
+ new_match_e->set_area(match_se->get_area());
+ new_match_e->set_marked(ADDED);
+
+ match_se->set_successor(new_match_e);
+
+ StrictEventPtr new_e = create_event(dup_flow, *ins_list_it, inst);
+
+ CompleteMessagePtr new_msg = new CompleteMessage((*ins_list_it)->getMessage()->get_label());
+ new_msg->set_marked(ADDED);
+
+ new_msg->glue_events(new_match_e, new_e);
+ }
+ }
+
+//-------------------------------------------------------------------
+ return true;
+ }
+ return false;
+}
+
+bool event_comparison(MembershipContext* c, StrictEventPtr& event_a, StrictEventPtr event_b)
+{
+ if(c->get_diff_type() == MESSAGE)
+ return compare_events(c, event_a.get(), event_b.get());
+ else
+ {
+ while(event_a != NULL && event_a->get_marked() == REMOVED)
+ {
+ event_a = event_a->get_successor();
+ }
+
+ int sum = (event_a == NULL) + (event_b == NULL);
+
+ switch (sum)
+ {
+ case 0: break;
+ case 1: return false;
+ case 2: return true;
+ }
+
+ return compare_events_attribute(c, event_a.get(), event_b.get());
+ }
+}
Modified: trunk/src/membership/diff_impl.h
===================================================================
--- trunk/src/membership/diff_impl.h 2011-02-23 19:26:36 UTC (rev 1050)
+++ trunk/src/membership/diff_impl.h 2011-02-27 16:01:18 UTC (rev 1051)
@@ -18,7 +18,7 @@
#ifndef __DIFF_IMPL__
#define __DIFF_IMPL__
-#include "membership_additional.h"
+#include "membership_alg.h"
enum Operation {ADD, REMOVE};
enum Direction {SEND, RECEIVE};
@@ -89,6 +89,7 @@
MscMessagePtr message;
enum Direction dir;
enum Operation op;
+ int attribute; //! ATTRIBUTE part, INSERT operation: attribute of matching event of missing event.
int line1;
int line2;
@@ -118,6 +119,16 @@
return op;
}
+ void setAttribute(int i)
+ {
+ attribute = i;
+ }
+
+ int getAttribute()
+ {
+ return attribute;
+ }
+
void setLine1(int row)
{
line1 = row;
Modified: trunk/src/membership/membership_additional.cpp
===================================================================
--- trunk/src/membership/membership_additional.cpp 2011-02-23 19:26:36 UTC (rev 1050)
+++ trunk/src/membership/membership_additional.cpp 2011-02-27 16:01:18 UTC (rev 1051)
@@ -136,6 +136,7 @@
return true;
}
+//TODO I don't like the time of increasing max id
void set_identification(MembershipContext* c, Event* node_e, Event* b_e)
{
if (node_e->is_send())
@@ -391,6 +392,7 @@
StrictOrderAreaPtr strict = boost::dynamic_pointer_cast<StrictOrderArea>(first);
+ //TODO check whether it could fall down (SEGFAULT)
StrictEventPtr str = strict->get_first();
//function finds event only in bMSC which is looked for, so coregion area is not allowed
Modified: trunk/src/membership/membership_additional.h
===================================================================
--- trunk/src/membership/membership_additional.h 2011-02-23 19:26:36 UTC (rev 1050)
+++ trunk/src/membership/membership_additional.h 2011-02-27 16:01:18 UTC (rev 1051)
@@ -35,6 +35,8 @@
*/
bool compare_events_attribute(MembershipContext* c, Event* a, Event* b);
+void compare_events_attribute_diff(MembershipContext* c, Event* spec_e, Event* flow_e);
+
//! tries to find configuration into map of seared configuration
bool look_at_checked_conf(MembershipContext* c, ReferenceNodePtr node, ConfigurationPtr b);
@@ -72,5 +74,4 @@
* id - id of event which is looked for
*/
Event* find_event_on_instance_by_id(MembershipContext* c, std::wstring label, int id, StrictEventPtr start_event = NULL);
-
#endif
Modified: trunk/src/membership/membership_base.h
===================================================================
--- trunk/src/membership/membership_base.h 2011-02-23 19:26:36 UTC (rev 1050)
+++ trunk/src/membership/membership_base.h 2011-02-27 16:01:18 UTC (rev 1051)
@@ -36,6 +36,7 @@
class CoregionOrdering;
enum check_type {membership, receive_ordering};
enum TopBottom {top, bottom};
+enum DiffType {MESSAGE, ATTRIBUTE};
typedef boost::intrusive_ptr<Position> PositionPtr;
typedef boost::intrusive_ptr<Configuration> ConfigurationPtr;
@@ -63,6 +64,8 @@
bool print_path; //! store whether the path will be printed
bool relative_time;
bool absolut_time;
+
+ enum DiffType diff_type;
public:
MembershipContext()
@@ -71,6 +74,7 @@
print_path = true;
relative_time = false;
absolut_time = false;
+ diff_type = MESSAGE;
}
void set_mem(MembershipAlg* m)
@@ -303,6 +307,16 @@
{
return absolut_time;
}
+
+ enum DiffType get_diff_type()
+ {
+ return diff_type;
+ }
+
+ void set_diff_type(enum DiffType type)
+ {
+ diff_type = type;
+ }
};
//! store information about the position of checking algorithm on instance
Modified: trunk/tests/diff/CMakeLists.txt
===================================================================
--- trunk/tests/diff/CMakeLists.txt 2011-02-23 19:26:36 UTC (rev 1050)
+++ trunk/tests/diff/CMakeLists.txt 2011-02-27 16:01:18 UTC (rev 1051)
@@ -28,5 +28,6 @@
ADD_DIFF_TEST(spec04.mpr flow04_3.mpr 1)
ADD_DIFF_TEST(spec04.mpr flow04_4.mpr 1)
ADD_DIFF_TEST(spec05.mpr flow05_1.mpr 1)
+ADD_DIFF_TEST(spec05.mpr flow05_2.mpr 1)
ADD_DIFF_TEST(spec06.mpr flow06_1.mpr 1)
Added: trunk/tests/diff/flow05_1.mpr
===================================================================
--- trunk/tests/diff/flow05_1.mpr (rev 0)
+++ trunk/tests/diff/flow05_1.mpr 2011-02-27 16:01:18 UTC (rev 1051)
@@ -0,0 +1,9 @@
+mscdocument Drawing1;
+msc Page_1;
+inst A;
+inst B;
+A: instance;
+endinstance;
+B: instance;
+endinstance;
+endmsc;
Added: trunk/tests/diff/flow05_1.mpr.result
===================================================================
--- trunk/tests/diff/flow05_1.mpr.result (rev 0)
+++ trunk/tests/diff/flow05_1.mpr.result 2011-02-27 16:01:18 UTC (rev 1051)
@@ -0,0 +1,23 @@
+OK: HMSC contains bMSC
+
+mscdocument msc_diff;
+msc Page_1;
+inst A;
+inst B;
+A: instance;
+/* ADDED */
+/* ADDED */
+out a,0 to B;
+/* ADDED */
+/* ADDED */
+out a,1 to B;
+endinstance;
+B: instance;
+/* ADDED */
+/* ADDED */
+in a,0 from A;
+/* ADDED */
+/* ADDED */
+in a,1 from A;
+endinstance;
+endmsc;
Added: trunk/tests/diff/flow05_2.mpr
===================================================================
--- trunk/tests/diff/flow05_2.mpr (rev 0)
+++ trunk/tests/diff/flow05_2.mpr 2011-02-27 16:01:18 UTC (rev 1051)
@@ -0,0 +1,13 @@
+mscdocument Drawing1;
+msc Page_1;
+inst A;
+inst B;
+A: instance;
+out a,3 to B;
+out a,0 to B;
+endinstance;
+B: instance;
+in a,0 from A;
+in a,3 from A;
+endinstance;
+endmsc;
Added: trunk/tests/diff/flow05_2.mpr.result
===================================================================
--- trunk/tests/diff/flow05_2.mpr.result (rev 0)
+++ trunk/tests/diff/flow05_2.mpr.result 2011-02-27 16:01:18 UTC (rev 1051)
@@ -0,0 +1,25 @@
+OK: HMSC contains bMSC
+
+mscdocument msc_diff;
+msc Page_1;
+inst A;
+inst B;
+A: instance;
+out a,0 to B;
+/* REMOVED */
+/* REMOVED */
+out a,1 to B;
+/* ADDED */
+/* ADDED */
+out a,2 to B;
+endinstance;
+B: instance;
+/* REMOVED */
+/* REMOVED */
+in a,1 from A;
+in a,0 from A;
+/* ADDED */
+/* ADDED */
+in a,2 from A;
+endinstance;
+endmsc;
Added: trunk/tests/diff/flow06_1.mpr
===================================================================
--- trunk/tests/diff/flow06_1.mpr (rev 0)
+++ trunk/tests/diff/flow06_1.mpr 2011-02-27 16:01:18 UTC (rev 1051)
@@ -0,0 +1,9 @@
+mscdocument Drawing1;
+msc Page_1;
+inst A;
+inst B;
+A: instance;
+endinstance;
+B: instance;
+endinstance;
+endmsc;
Added: trunk/tests/diff/flow06_1.mpr.result
===================================================================
--- trunk/tests/diff/flow06_1.mpr.result (rev 0)
+++ trunk/tests/diff/flow06_1.mpr.result 2011-02-27 16:01:18 UTC (rev 1051)
@@ -0,0 +1,23 @@
+OK: HMSC contains bMSC
+
+mscdocument msc_diff;
+msc Page_1;
+inst A;
+inst B;
+A: instance;
+/* ADDED */
+/* ADDED */
+out a,0 to B;
+/* ADDED */
+/* ADDED */
+out a,1 to B;
+endinstance;
+B: instance;
+/* ADDED */
+/* ADDED */
+in a,1 from A;
+/* ADDED */
+/* ADDED */
+in a,0 from A;
+endinstance;
+endmsc;
Added: trunk/tests/diff/spec05.mpr
===================================================================
--- trunk/tests/diff/spec05.mpr (rev 0)
+++ trunk/tests/diff/spec05.mpr 2011-02-27 16:01:18 UTC (rev 1051)
@@ -0,0 +1,13 @@
+mscdocument Drawing1;
+msc Page_1;
+inst A;
+inst B;
+A: instance;
+out a,0 to B;
+out a,3 to B;
+endinstance;
+B: instance;
+in a,0 from A;
+in a,3 from A;
+endinstance;
+endmsc;
Added: trunk/tests/diff/spec06.mpr
===================================================================
--- trunk/tests/diff/spec06.mpr (rev 0)
+++ trunk/tests/diff/spec06.mpr 2011-02-27 16:01:18 UTC (rev 1051)
@@ -0,0 +1,13 @@
+mscdocument Drawing1;
+msc Page_1;
+inst A;
+inst B;
+A: instance;
+out a,0 to B;
+out a,3 to B;
+endinstance;
+B: instance;
+in a,3 from A;
+in a,0 from A;
+endinstance;
+endmsc;
Added: trunk/tests/diff/spec07.mpr
===================================================================
--- trunk/tests/diff/spec07.mpr (rev 0)
+++ trunk/tests/diff/spec07.mpr 2011-02-27 16:01:18 UTC (rev 1051)
@@ -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;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ma...@us...> - 2011-02-28 17:35:39
|
Revision: 1053
http://scstudio.svn.sourceforge.net/scstudio/?rev=1053&view=rev
Author: madzin
Date: 2011-02-28 17:35:32 +0000 (Mon, 28 Feb 2011)
Log Message:
-----------
Solve message crossing and fix some bugs about it. Add new tests
Modified Paths:
--------------
trunk/src/membership/diff_impl.cpp
trunk/src/membership/diff_impl.h
trunk/tests/diff/CMakeLists.txt
trunk/tests/diff/flow04_2.mpr.result
Added Paths:
-----------
trunk/tests/diff/flow01.mpr.result
trunk/tests/diff/flow04_4.mpr.result
trunk/tests/diff/flow04_5.mpr
trunk/tests/diff/flow04_5.mpr.result
trunk/tests/diff/flow04_6.mpr
trunk/tests/diff/flow04_6.mpr.result
trunk/tests/diff/flow06_2.mpr
trunk/tests/diff/flow06_2.mpr.result
trunk/tests/diff/flow07_1.mpr
trunk/tests/diff/flow07_1.mpr.result
trunk/tests/diff/flow07_2.mpr
trunk/tests/diff/flow07_2.mpr.result
Modified: trunk/src/membership/diff_impl.cpp
===================================================================
--- trunk/src/membership/diff_impl.cpp 2011-02-27 17:46:37 UTC (rev 1052)
+++ trunk/src/membership/diff_impl.cpp 2011-02-28 17:35:32 UTC (rev 1053)
@@ -19,29 +19,9 @@
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);
-void print_result(Difference* diff)
-{
- while(diff != NULL)
- {
- if(diff->getOperation() == ADD) std::cerr << "ADD" << std::endl;
- else std::cerr << "REMOVE" << std::endl;
- std::cerr << "line1: " << diff->getLine1() << " ";
-
- if(diff->getLocation() == NULL) std::cerr << "NULL";
- else std::wcout << diff->getLocation()->get_message()->get_label();
-
- std::cerr << std::endl;
-
-
- std::cerr << "line2: " << diff->getLine2() << " ";
- std::wcout << diff->getMessage()->get_label() << std::endl;
-
- diff = diff->getPrevious();
- }
- std::cerr << "===============================" << std::endl;
-}
-
void print_result(BMscPtr msc)
{
InstancePtrList insts = msc->get_instances();
@@ -85,7 +65,6 @@
*/
MscPtr MembershipAlg::diff(MscPtr specification, std::vector<MscPtr>& msc_flows)
{
- //TODO redirect the output messages
if(msc_flows.size() > 1)
print_report(RS_WARNING, L"Warning: in this version, it is supported for one flow, others is ignored");
@@ -275,6 +254,10 @@
for (int i = 0; i < row-1; i++)
{
location = location->get_successor();
+
+//TODO check this
+ if(location->get_marked() == REMOVED)
+ i--;
}
if(row <= 0)
location = NULL;
@@ -374,28 +357,87 @@
InstancePtrList::iterator spec_it;
InstancePtrList::iterator flow_it;
+
+ std::set<std::wstring> all_instances;
+ std::set<std::wstring>::iterator all_inst_it;
- bool found = false;
+ for(spec_it = spec_inst.begin(); spec_it != spec_inst.end(); spec_it++)
+ {
+ all_inst_it = all_instances.find((*spec_it)->get_label());
+
+ if(all_inst_it == all_instances.end())
+ all_instances.insert((*spec_it)->get_label());
+ }
- for (spec_it = spec_inst.begin(); spec_it != spec_inst.end(); spec_it++)
+ for (flow_it = flow_inst.begin(); flow_it != flow_inst.end(); flow_it++)
{
- found = false;
+ all_inst_it = all_instances.find((*flow_it)->get_label());
+ if(all_inst_it == all_instances.end())
+ all_instances.insert((*flow_it)->get_label());
+ }
+
+ bool flow_found = false;
+ bool spec_found = false;
+
+ for(all_inst_it = all_instances.begin(); all_inst_it != all_instances.end(); all_inst_it++)
+ {
+ spec_found = false;
+ flow_found = false;
+
+ //spec_it is pointing to the specification instance which has the proper name
+ for(spec_it = spec_inst.begin(); spec_it != spec_inst.end(); spec_it++)
+ {
+ if((*spec_it)->get_label() == *all_inst_it)
+ {
+ spec_found = true;
+ break;
+ }
+ }
+
+ //flow_it is pointing to the flow instance which has the proper name
for (flow_it = flow_inst.begin(); flow_it != flow_inst.end(); flow_it++)
{
- if ((*spec_it)->get_label() == (*flow_it)->get_label())
+ if((*flow_it)->get_label() == *all_inst_it)
{
- Difference* diff = instance_diff(c, *flow_it, *spec_it);
+ flow_found = true;
+ break;
+ }
+ }
- if(diff != NULL)
- diff_map.insert(std::make_pair((*flow_it)->get_label(), diff));
+ //when some instance of the flow is not comntained in the specification
+ if(!spec_found)
+ {
+ StrictOrderAreaPtr s_e_a = boost::dynamic_pointer_cast<StrictOrderArea> ((*flow_it)->get_first());
+ StrictEventPtr s_e = s_e_a==NULL ? NULL : s_e_a->get_first();
+ Difference* old_diff = NULL;
- found = true;
+ while(s_e != NULL)
+ {
+ Difference* diff = new Difference();
+
+ diff->setPrevious(old_diff);
+ diff->setOperation(REMOVE);
+ diff->setLocation(s_e);
+ diff->setMessage(s_e->get_message(), s_e->is_send());
+
+ old_diff = diff;
+
+ s_e = s_e->get_successor();
+
+ if(s_e == NULL)
+ {
+ s_e_a = boost::dynamic_pointer_cast<StrictOrderArea> (s_e_a->get_next());
+ s_e = s_e_a==NULL ? NULL : s_e_a->get_first();
+ }
}
+
+ if(old_diff != NULL)
+ diff_map.insert(std::make_pair(*all_inst_it, old_diff));
}
-
+
//when some instance of the specification is not contained in the flow
- if(!found)
+ if(!flow_found)
{
StrictOrderAreaPtr s_e_a = boost::dynamic_pointer_cast<StrictOrderArea> ((*spec_it)->get_first());
StrictEventPtr s_e = s_e_a==NULL ? NULL : s_e_a->get_first();
@@ -422,8 +464,17 @@
}
if (old_diff != NULL)
- diff_map.insert(std::make_pair((*spec_it)->get_label(), old_diff));
+ diff_map.insert(std::make_pair(*all_inst_it, old_diff));
}
+
+ if(!spec_found || !flow_found)
+ continue;
+
+ //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)
+ diff_map.insert(std::make_pair((*flow_it)->get_label(), diff));
}
if(!diff_map.empty())
@@ -675,34 +726,9 @@
void process_diffrences(MembershipContext* c, BMscPtr dup_flow, 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;
- Difference* diff;
+ insert_map = create_insert_map(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);
- 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;
std::map<std::wstring, std::set<Unmatched*> > unmatched_map;
std::map<std::wstring, std::set<Unmatched*> >::iterator unmatched_map_it;
@@ -725,6 +751,8 @@
continue;
}
+
+ //checks whether exists events which is supposed to be connected with instance
unmatched_map_it = unmatched_map.find(ins_map_it->first);
//create new record in unmatched_map
@@ -737,12 +765,21 @@
else
match_inst = com_msg->get_sender()->get_label();
- //create new event and add it as unmatched
- StrictEventPtr new_e = create_event(dup_flow, *ins_list_it, ins_map_it->first);
- Unmatched* unmatched = new Unmatched(new_e, message);
+ //check the matching instance, whether has a diffrence for creation of the matching event
+ //if the diffrence exist, create unmatched record
+ Unmatched* unmatched;
+ if(check_matching_event_creation(insert_map, *ins_list_it))
+ {
+ StrictEventPtr new_e = create_event(dup_flow, *ins_list_it, ins_map_it->first);
+ unmatched = new Unmatched(new_e, message);
+ }
+ else
+ continue;
+
std::map<std::wstring, std::set<Unmatched*> >::iterator match_it = unmatched_map.find(match_inst);
+ //add to unmatched
if(match_it == unmatched_map.end())
{
std::set<Unmatched*> unmatched_set;
@@ -763,23 +800,24 @@
if(com_msg == (*unmatched_set_it)->getMessage())
{
StrictEventPtr new_e = create_event(dup_flow, *ins_list_it, ins_map_it->first);
+ StrictEventPtr match_e = (*unmatched_set_it)->getEvent();
CompleteMessagePtr new_msg = new CompleteMessage(com_msg->get_label());
new_msg->set_marked(ADDED);
if((*ins_list_it)->getDirection() == SEND)
- new_msg->glue_events(new_e, (*unmatched_set_it)->getEvent());
+ new_msg->glue_events(new_e, match_e);
else
- new_msg->glue_events((*unmatched_set_it)->getEvent(), new_e);
+ new_msg->glue_events(match_e, new_e);
if(new_e->is_send())
{
set_identification(c, new_e.get(), com_msg->get_send_event());
- set_identification(c, (*unmatched_set_it)->getEvent().get(), com_msg->get_receive_event());
+ set_identification(c, match_e.get(), com_msg->get_receive_event());
}
else
{
- set_identification(c, (*unmatched_set_it)->getEvent().get(), com_msg->get_send_event());
+ set_identification(c, match_e.get(), com_msg->get_send_event());
set_identification(c, new_e.get(), com_msg->get_receive_event());
}
@@ -802,21 +840,40 @@
else
match_inst = com_msg->get_sender()->get_label();
- StrictEventPtr new_e = create_event(dup_flow, *ins_list_it, ins_map_it->first);
- Unmatched* unmatched = new Unmatched(new_e, message);
- unmatched_map_it->second.insert(unmatched);
+ Unmatched* unmatched;
+
+ if(check_matching_event_creation(insert_map, *ins_list_it))
+ {
+ StrictEventPtr new_e = create_event(dup_flow, *ins_list_it, ins_map_it->first);
+ unmatched = new Unmatched(new_e, message);
+ }
+ else
+ continue;
+
+ std::map<std::wstring, std::set<Unmatched*> >::iterator match_it = unmatched_map.find(match_inst);
+
+ if(match_it == unmatched_map.end())
+ {
+ std::set<Unmatched*> match_inst_unmatched_set;
+ match_inst_unmatched_set.insert(unmatched);
+ unmatched_map.insert(std::make_pair(match_inst, match_inst_unmatched_set));
+ }
+ else
+ match_it->second.insert(unmatched);
}
}
}
-
//check unmatched diffrences in unmatched map
for (unmatched_map_it = unmatched_map.begin(); unmatched_map_it != unmatched_map.end(); unmatched_map_it++)
{
std::set<Unmatched*> unmatched_set = unmatched_map_it->second;
+ std::set<Unmatched*>::iterator unmatched_set_it;
if(!unmatched_set.empty())
- std::wcerr << L"Warning: diff was not successfull" << std::endl;
+ throw std::runtime_error("Error: unexpected behaviour");
+
+ unmatched_set.clear();
}
}
@@ -833,6 +890,7 @@
c->set_diff_type(ATTRIBUTE);
+ //TODO prerobit ako pri prvej kontrole all_instances
for(spec_it = spec_insts.begin(); spec_it != spec_insts.end(); spec_it++)
{
for(flow_it = flow_insts.begin(); flow_it != flow_insts.end(); flow_it++)
@@ -929,7 +987,6 @@
if(match_se == NULL)
throw std::runtime_error("Error: unexpected behaviour");
- //TODO skontrolovat ci sa eventu nastavi instancia a area atd.
StrictEventPtr new_match_e = new StrictEvent();
//TODO set position
new_match_e->set_area(match_se->get_area());
@@ -975,3 +1032,76 @@
return compare_events_attribute(c, event_a.get(), event_b.get());
}
}
+
+bool check_matching_event_creation(std::map<std::wstring, std::list<Difference*> > insert_map, Difference* diff)
+{
+ std::wstring match_inst_name;
+
+ CompleteMessagePtr complete = boost::dynamic_pointer_cast<CompleteMessage>(diff->getMessage());
+
+ if(complete == NULL)
+ throw std::runtime_error("Error: unexpected behaviour");
+
+ if(diff->getDirection() == SEND)
+ match_inst_name = complete->get_receiver()->get_label();
+ else
+ match_inst_name = complete->get_sender()->get_label();
+
+ std::map<std::wstring, std::list<Difference*> >::iterator it;
+ it = insert_map.find(match_inst_name);
+
+ if(it != insert_map.end())
+ {
+ std::list<Difference*> insert_list = it->second;
+ std::list<Difference*>::iterator insert_list_it;
+
+ for(insert_list_it = insert_list.begin(); insert_list_it != insert_list.end(); insert_list_it++)
+ {
+ if((*insert_list_it)->getMessage() == diff->getMessage())
+ return true;
+ }
+ }
+
+ return false;
+}
+
+std::map<std::wstring, std::list<Difference*> > create_insert_map(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;
+ Difference* diff;
+
+ 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)
+ {
+ if(diff->getLocation()->is_send())
+ {
+ 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));
+ }
+
+ return insert_map;
+}
Modified: trunk/src/membership/diff_impl.h
===================================================================
--- trunk/src/membership/diff_impl.h 2011-02-27 17:46:37 UTC (rev 1052)
+++ trunk/src/membership/diff_impl.h 2011-02-28 17:35:32 UTC (rev 1053)
@@ -23,6 +23,10 @@
enum Operation {ADD, REMOVE};
enum Direction {SEND, RECEIVE};
+class Distance;
+class Unmatched;
+class Difference;
+
class Distance
{
private:
@@ -74,7 +78,7 @@
{
return event;
}
-
+
MscMessagePtr getMessage()
{
return original_message;
Modified: trunk/tests/diff/CMakeLists.txt
===================================================================
--- trunk/tests/diff/CMakeLists.txt 2011-02-27 17:46:37 UTC (rev 1052)
+++ trunk/tests/diff/CMakeLists.txt 2011-02-28 17:35:32 UTC (rev 1053)
@@ -27,7 +27,12 @@
ADD_DIFF_TEST(spec04.mpr flow04_2.mpr 1)
ADD_DIFF_TEST(spec04.mpr flow04_3.mpr 1)
ADD_DIFF_TEST(spec04.mpr flow04_4.mpr 1)
+ADD_DIFF_TEST(spec04.mpr flow04_5.mpr 1)
+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(spec06.mpr flow06_1.mpr 1)
+ADD_DIFF_TEST(spec06.mpr flow06_2.mpr 1)
+ADD_DIFF_TEST(spec07.mpr flow07_1.mpr 1)
+ADD_DIFF_TEST(spec07.mpr flow07_2.mpr 1)
Added: trunk/tests/diff/flow01.mpr.result
===================================================================
--- trunk/tests/diff/flow01.mpr.result (rev 0)
+++ trunk/tests/diff/flow01.mpr.result 2011-02-28 17:35:32 UTC (rev 1053)
@@ -0,0 +1,64 @@
+OK: HMSC contains bMSC
+
+mscdocument msc_diff;
+msc Page_1;
+inst A;
+inst B;
+inst C;
+A: instance;
+/* REMOVED */
+/* REMOVED */
+out a,0 to B;
+/* ADDED */
+/* ADDED */
+out a,1 to B;
+/* REMOVED */
+/* REMOVED */
+out b,2 to B;
+/* REMOVED */
+/* REMOVED */
+out c,3 to B;
+/* ADDED */
+/* ADDED */
+out d,4 to B;
+endinstance;
+B: instance;
+/* REMOVED */
+/* REMOVED */
+in a,0 from A;
+/* REMOVED */
+/* REMOVED */
+in b,2 from A;
+/* REMOVED */
+/* REMOVED */
+in c,3 from A;
+in a,5 from C;
+/* REMOVED */
+/* REMOVED */
+in d,6 from C;
+/* ADDED */
+/* ADDED */
+in b,7 from C;
+/* ADDED */
+/* ADDED */
+in c,8 from C;
+/* ADDED */
+/* ADDED */
+in a,1 from A;
+/* ADDED */
+/* ADDED */
+in d,4 from A;
+endinstance;
+C: instance;
+out a,5 to B;
+/* REMOVED */
+/* REMOVED */
+out d,6 to B;
+/* ADDED */
+/* ADDED */
+out b,7 to B;
+/* ADDED */
+/* ADDED */
+out c,8 to B;
+endinstance;
+endmsc;
Modified: trunk/tests/diff/flow04_2.mpr.result
===================================================================
--- trunk/tests/diff/flow04_2.mpr.result 2011-02-27 17:46:37 UTC (rev 1052)
+++ trunk/tests/diff/flow04_2.mpr.result 2011-02-28 17:35:32 UTC (rev 1053)
@@ -25,6 +25,7 @@
endinstance;
NAME: instance;
/* REMOVED */
+/* REMOVED */
out b,4 to A;
endinstance;
endmsc;
Added: trunk/tests/diff/flow04_4.mpr.result
===================================================================
--- trunk/tests/diff/flow04_4.mpr.result (rev 0)
+++ trunk/tests/diff/flow04_4.mpr.result 2011-02-28 17:35:32 UTC (rev 1053)
@@ -0,0 +1,28 @@
+OK: HMSC contains bMSC
+
+mscdocument msc_diff;
+msc Page_1;
+inst B;
+inst C;
+inst A;
+B: instance;
+out b,0 to A;
+in a,1 from C;
+out a,2 to C;
+/* REMOVED */
+/* REMOVED */
+out b,3 to A;
+endinstance;
+C: instance;
+out a,1 to B;
+in a,2 from B;
+in c,4 from A;
+endinstance;
+A: instance;
+out c,4 to C;
+/* REMOVED */
+/* REMOVED */
+in b,3 from B;
+in b,0 from B;
+endinstance;
+endmsc;
Added: trunk/tests/diff/flow04_5.mpr
===================================================================
--- trunk/tests/diff/flow04_5.mpr (rev 0)
+++ trunk/tests/diff/flow04_5.mpr 2011-02-28 17:35:32 UTC (rev 1053)
@@ -0,0 +1,24 @@
+mscdocument flow04_4.vsd;
+msc Page_1;
+inst B;
+inst C;
+inst A;
+B: instance;
+out b,0 to A;
+in a,1 from C;
+out a,2 to C;
+in a,10 from A;
+out b,3 to A;
+endinstance;
+C: instance;
+out a,1 to B;
+in a,2 from B;
+in c,4 from A;
+endinstance;
+A: instance;
+out c,4 to C;
+in b,3 from B;
+out a,10 to B;
+in b,0 from B;
+endinstance;
+endmsc;
Added: trunk/tests/diff/flow04_5.mpr.result
===================================================================
--- trunk/tests/diff/flow04_5.mpr.result (rev 0)
+++ trunk/tests/diff/flow04_5.mpr.result 2011-02-28 17:35:32 UTC (rev 1053)
@@ -0,0 +1,34 @@
+OK: HMSC contains bMSC
+
+mscdocument msc_diff;
+msc Page_1;
+inst B;
+inst C;
+inst A;
+B: instance;
+out b,0 to A;
+in a,1 from C;
+out a,2 to C;
+/* REMOVED */
+/* REMOVED */
+in a,3 from A;
+/* REMOVED */
+/* REMOVED */
+out b,4 to A;
+endinstance;
+C: instance;
+out a,1 to B;
+in a,2 from B;
+in c,5 from A;
+endinstance;
+A: instance;
+out c,5 to C;
+/* REMOVED */
+/* REMOVED */
+in b,4 from B;
+/* REMOVED */
+/* REMOVED */
+out a,3 to B;
+in b,0 from B;
+endinstance;
+endmsc;
Added: trunk/tests/diff/flow04_6.mpr
===================================================================
--- trunk/tests/diff/flow04_6.mpr (rev 0)
+++ trunk/tests/diff/flow04_6.mpr 2011-02-28 17:35:32 UTC (rev 1053)
@@ -0,0 +1,25 @@
+mscdocument flow04_2.vsd;
+msc Page_1;
+inst B;
+inst C;
+inst A;
+inst NAME;
+B: instance;
+out b,0 to A;
+in a,1 from C;
+out a,2 to C;
+endinstance;
+C: instance;
+out a,1 to B;
+in a,2 from B;
+in c,3 from A;
+endinstance;
+A: instance;
+out c,3 to C;
+in b,0 from B;
+out b,4 to NAME;
+endinstance;
+NAME: instance;
+in b,4 from A;
+endinstance;
+endmsc;
Added: trunk/tests/diff/flow04_6.mpr.result
===================================================================
--- trunk/tests/diff/flow04_6.mpr.result (rev 0)
+++ trunk/tests/diff/flow04_6.mpr.result 2011-02-28 17:35:32 UTC (rev 1053)
@@ -0,0 +1,31 @@
+OK: HMSC contains bMSC
+
+mscdocument msc_diff;
+msc Page_1;
+inst B;
+inst C;
+inst A;
+inst NAME;
+B: instance;
+out b,0 to A;
+in a,1 from C;
+out a,2 to C;
+endinstance;
+C: instance;
+out a,1 to B;
+in a,2 from B;
+in c,3 from A;
+endinstance;
+A: instance;
+out c,3 to C;
+in b,0 from B;
+/* REMOVED */
+/* REMOVED */
+out b,4 to NAME;
+endinstance;
+NAME: instance;
+/* REMOVED */
+/* REMOVED */
+in b,4 from A;
+endinstance;
+endmsc;
Added: trunk/tests/diff/flow06_2.mpr
===================================================================
--- trunk/tests/diff/flow06_2.mpr (rev 0)
+++ trunk/tests/diff/flow06_2.mpr 2011-02-28 17:35:32 UTC (rev 1053)
@@ -0,0 +1,13 @@
+mscdocument Drawing1;
+msc Page_1;
+inst A;
+inst B;
+A: instance;
+out a,0 to B;
+out a,3 to B;
+endinstance;
+B: instance;
+in a,0 from A;
+in a,3 from A;
+endinstance;
+endmsc;
Added: trunk/tests/diff/flow06_2.mpr.result
===================================================================
--- trunk/tests/diff/flow06_2.mpr.result (rev 0)
+++ trunk/tests/diff/flow06_2.mpr.result 2011-02-28 17:35:32 UTC (rev 1053)
@@ -0,0 +1,25 @@
+OK: HMSC contains bMSC
+
+mscdocument msc_diff;
+msc Page_1;
+inst A;
+inst B;
+A: instance;
+/* REMOVED */
+/* REMOVED */
+out a,0 to B;
+/* ADDED */
+/* ADDED */
+out a,1 to B;
+out a,2 to B;
+endinstance;
+B: instance;
+/* REMOVED */
+/* REMOVED */
+in a,0 from A;
+in a,2 from A;
+/* ADDED */
+/* ADDED */
+in a,1 from A;
+endinstance;
+endmsc;
Added: trunk/tests/diff/flow07_1.mpr
===================================================================
--- trunk/tests/diff/flow07_1.mpr (rev 0)
+++ trunk/tests/diff/flow07_1.mpr 2011-02-28 17:35:32 UTC (rev 1053)
@@ -0,0 +1,13 @@
+mscdocument Drawing1;
+msc Page_1;
+inst A;
+inst B;
+A: instance;
+out a,3 to B;
+out a,0 to B;
+endinstance;
+B: instance;
+in a,0 from A;
+in a,3 from A;
+endinstance;
+endmsc;
Added: trunk/tests/diff/flow07_1.mpr.result
===================================================================
--- trunk/tests/diff/flow07_1.mpr.result (rev 0)
+++ trunk/tests/diff/flow07_1.mpr.result 2011-02-28 17:35:32 UTC (rev 1053)
@@ -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;
+/* REMOVED */
+/* REMOVED */
+out a,1 to B;
+endinstance;
+B: instance;
+/* REMOVED */
+/* REMOVED */
+in a,1 from A;
+in a,0 from A;
+endinstance;
+endmsc;
Added: trunk/tests/diff/flow07_2.mpr
===================================================================
--- trunk/tests/diff/flow07_2.mpr (rev 0)
+++ trunk/tests/diff/flow07_2.mpr 2011-02-28 17:35:32 UTC (rev 1053)
@@ -0,0 +1,13 @@
+mscdocument Drawing1;
+msc Page_1;
+inst A;
+inst B;
+A: instance;
+out a,0 to B;
+out a,3 to B;
+endinstance;
+B: instance;
+in a,0 from A;
+in a,3 from A;
+endinstance;
+endmsc;
Added: trunk/tests/diff/flow07_2.mpr.result
===================================================================
--- trunk/tests/diff/flow07_2.mpr.result (rev 0)
+++ trunk/tests/diff/flow07_2.mpr.result 2011-02-28 17:35:32 UTC (rev 1053)
@@ -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;
+/* REMOVED */
+/* REMOVED */
+out a,1 to B;
+endinstance;
+B: instance;
+in a,0 from A;
+/* REMOVED */
+/* REMOVED */
+in a,1 from A;
+endinstance;
+endmsc;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
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.
|
|
From: <ma...@us...> - 2011-03-13 20:07:36
|
Revision: 1061
http://scstudio.svn.sourceforge.net/scstudio/?rev=1061&view=rev
Author: madzin
Date: 2011-03-13 20:07:29 +0000 (Sun, 13 Mar 2011)
Log Message:
-----------
Fix bug in MSC diff algorithm. The algorithm was set the identification during the matrix creation, which brings identification inconsistency when some event was multiple times compared with different events with the same properties.
Now the algorithm set identification after first run of diff part of the algorithm.
Modified Paths:
--------------
trunk/src/membership/diff_impl.cpp
trunk/src/membership/membership_base.h
trunk/tests/diff/CMakeLists.txt
Added Paths:
-----------
trunk/tests/diff/flow05_3.mpr.result2
trunk/tests/diff/flow06_3.mpr.result2
trunk/tests/diff/flow08_1.mpr.result2
trunk/tests/diff/flow09_1.mpr
trunk/tests/diff/flow09_1.mpr.result
trunk/tests/diff/spec09.mpr
Modified: trunk/src/membership/diff_impl.cpp
===================================================================
--- trunk/src/membership/diff_impl.cpp 2011-03-09 09:41:13 UTC (rev 1060)
+++ trunk/src/membership/diff_impl.cpp 2011-03-13 20:07:29 UTC (rev 1061)
@@ -22,6 +22,8 @@
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(MembershipContext* c,
const std::map<std::wstring, Difference*>& diff_map);
+void diff_identification_settings(MembershipContext* c, const std::map<std::wstring, Difference*>& diff_map);
+InstancePtr find_instance(BMscPtr bmsc, std::wstring name);
void print_result(BMscPtr msc)
{
@@ -85,7 +87,6 @@
BMscPtr bmsc = boost::dynamic_pointer_cast<BMsc> (specification);
- //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);
@@ -132,8 +133,8 @@
row++;
- if(c->get_diff_type() == MESSAGE)
- set_identification(c, event_a.get(), event_b.get());
+// if(c->get_diff_type() == MESSAGE)
+// set_identification(c, event_a.get(), event_b.get());
event_a = event_a->get_successor();
event_b = event_b->get_successor();
@@ -312,8 +313,8 @@
while (event_a != NULL && event_b != NULL && event_comparison(c, event_a, event_b))
{
- if(c->get_diff_type() == MESSAGE)
- set_identification(c, event_a.get(), event_b.get());
+// if(c->get_diff_type() == MESSAGE)
+// set_identification(c, event_a.get(), event_b.get());
event_a = event_a->get_successor();
event_b = event_b->get_successor();
@@ -351,6 +352,7 @@
dup_flow = duplicator.duplicate(flow);
c->set_bmsc(dup_flow);
+ c->set_specification(specification);
InstancePtrList spec_inst = specification->get_instances();
InstancePtrList flow_inst = dup_flow->get_instances();
@@ -384,6 +386,8 @@
for(int i = 0; i < 2; i++)
{
+ diff_map.clear();
+
for(all_inst_it = all_instances.begin(); all_inst_it != all_instances.end(); all_inst_it++)
{
spec_found = false;
@@ -477,9 +481,12 @@
//when the instance of proper name was found in both MSCs (specification, flow)
Difference* diff = instance_diff(c, *flow_it, *spec_it);
- if(i == 1 && diff != NULL)
+ if(diff != NULL)
diff_map.insert(std::make_pair((*flow_it)->get_label(), diff));
}
+
+ if(i == 0)
+ diff_identification_settings(c, diff_map);
}
@@ -1029,3 +1036,118 @@
return insert_map;
}
+
+void diff_identification_settings(MembershipContext* c, const std::map<std::wstring, Difference*>& diff_map)
+{
+ std::map<std::wstring, Difference*>::const_iterator map_it;
+ std::vector<Difference*> inst_diff;
+ InstancePtr spec_inst, flow_inst;
+ StrictEventPtr spec_e, flow_e;
+ Difference* diff;
+
+ BMscPtr specification = boost::dynamic_pointer_cast<BMsc> (c->get_specification());
+
+ if(specification == NULL)
+ return ;
+
+ InstancePtrList instances = specification->get_instances();
+ InstancePtrList::iterator instances_it;
+
+ for(instances_it = instances.begin(); instances_it != instances.end(); instances_it++)
+ {
+ inst_diff.clear();
+ diff = NULL;
+
+ map_it = diff_map.find((*instances_it)->get_label());
+
+ if(map_it != diff_map.end())
+ diff = map_it->second;
+
+ while(diff != NULL)
+ {
+ inst_diff.push_back(diff);
+ diff = diff->getPrevious();
+ }
+
+ spec_inst = find_instance(boost::dynamic_pointer_cast<BMsc> (c->get_specification()), (*instances_it)->get_label());
+ flow_inst = find_instance(c->get_bmsc(), (*instances_it)->get_label());
+
+ if(spec_inst == NULL || flow_inst == NULL)
+ continue;
+
+ StrictOrderAreaPtr spec_ea = boost::dynamic_pointer_cast<StrictOrderArea>(spec_inst->get_first());
+ StrictOrderAreaPtr flow_ea = boost::dynamic_pointer_cast<StrictOrderArea>(flow_inst->get_first());
+
+ if(spec_ea == NULL || flow_ea == NULL)
+ continue;
+
+ spec_e = spec_ea->get_first();
+ flow_e = flow_ea->get_first();
+
+ //set identification to proper events
+ std::vector<Difference*>::reverse_iterator vec_it = inst_diff.rbegin();
+ while(spec_e != NULL && flow_e != NULL)
+ {
+ if(vec_it != inst_diff.rend())
+ {
+ if((*vec_it)->getOperation() == REMOVE)
+ {
+ if((*vec_it)->getLocation() == flow_e)
+ {
+ //due to some differences (REMOVE and ADD) can have same location
+ //in case the following diffrence has the same location flow_e is not changing
+ if(vec_it + 1 == inst_diff.rend() ||
+ (vec_it + 1 != inst_diff.rend() && (*(vec_it+1))->getLocation() != (*vec_it)->getLocation()))
+ {
+ flow_e = flow_e->get_successor();
+ vec_it++;
+ continue;
+ }
+ }
+ }
+ else
+ {
+ if((*vec_it)->getLocation() == NULL || (*vec_it)->getLocation() == flow_e->get_predecessor())
+ {
+ spec_e = spec_e->get_successor();
+
+ //due to in some cases the flow_e was not changed
+ //in case that flow_e was not changed and the location of the following diffrence is not same
+ //it is neccessary to change the flow_e too
+ if(vec_it != inst_diff.rbegin() &&
+ (*(vec_it-1))->getLocation() == (*vec_it)->getLocation() &&
+ (*vec_it)->getLocation() != NULL &&
+ (vec_it+1 == inst_diff.rend() || (*vec_it)->getLocation() != (*(vec_it+1))->getLocation()))
+ {
+ flow_e = flow_e->get_successor();
+ }
+ vec_it++;
+ continue;
+ }
+ }
+ }
+
+
+ set_identification(c, spec_e.get(), flow_e.get());
+ spec_e = spec_e->get_successor();
+ flow_e = flow_e->get_successor();
+ }
+ }
+}
+
+InstancePtr find_instance(BMscPtr bmsc, std::wstring name)
+{
+ if(bmsc == NULL)
+ return NULL;
+
+ InstancePtrList insts = bmsc->get_instances();
+ InstancePtrList::iterator it;
+
+ for(it = insts.begin(); it != insts.end(); it++)
+ {
+ if((*it)->get_label() == name)
+ return *it;
+ }
+
+ return NULL;
+}
Modified: trunk/src/membership/membership_base.h
===================================================================
--- trunk/src/membership/membership_base.h 2011-03-09 09:41:13 UTC (rev 1060)
+++ trunk/src/membership/membership_base.h 2011-03-13 20:07:29 UTC (rev 1061)
@@ -50,6 +50,7 @@
MembershipAlg* mem; //! enable print_report
int max_id; //! identification for receive events
BMscPtr bmsc; //! bmsc which represents the flow
+ MscPtr msc; //! msc which represents the specification
std::vector<std::wstring> focused_instances; //! name of instances on which a user is focused on
std::map<CoregionAreaPtr, SnapshotContextPtr> snapshots; //! snapshots of context for each coregion
std::vector<Event*> attributed_events; //! events with attribute
@@ -106,7 +107,17 @@
{
return bmsc;
}
+
+ void set_specification(MscPtr m)
+ {
+ msc = m;
+ }
+ const MscPtr get_specification() const
+ {
+ return msc;
+ }
+
void set_focused_instances(std::vector<std::wstring> instances)
{
focused_instances.insert(focused_instances.begin(), instances.begin(), instances.end());
Modified: trunk/tests/diff/CMakeLists.txt
===================================================================
--- trunk/tests/diff/CMakeLists.txt 2011-03-09 09:41:13 UTC (rev 1060)
+++ trunk/tests/diff/CMakeLists.txt 2011-03-13 20:07:29 UTC (rev 1061)
@@ -38,4 +38,5 @@
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)
+ADD_DIFF_TEST(spec09.mpr flow09_1.mpr 1)
Added: trunk/tests/diff/flow05_3.mpr.result2
===================================================================
--- trunk/tests/diff/flow05_3.mpr.result2 (rev 0)
+++ trunk/tests/diff/flow05_3.mpr.result2 2011-03-13 20:07:29 UTC (rev 1061)
@@ -0,0 +1,19 @@
+OK: HMSC contains bMSC
+
+mscdocument msc_diff;
+msc Page_1;
+inst A;
+inst B;
+A: instance;
+/* ADDED */
+/* ADDED */
+out a,0 to B;
+out a,1 to B;
+endinstance;
+B: instance;
+/* ADDED */
+/* ADDED */
+in a,0 from A;
+in a,1 from A;
+endinstance;
+endmsc;
Added: trunk/tests/diff/flow06_3.mpr.result2
===================================================================
--- trunk/tests/diff/flow06_3.mpr.result2 (rev 0)
+++ trunk/tests/diff/flow06_3.mpr.result2 2011-03-13 20:07:29 UTC (rev 1061)
@@ -0,0 +1,19 @@
+OK: HMSC contains bMSC
+
+mscdocument msc_diff;
+msc Page_1;
+inst A;
+inst B;
+A: instance;
+/* ADDED */
+/* ADDED */
+out a,0 to B;
+out a,1 to B;
+endinstance;
+B: instance;
+in a,1 from A;
+/* ADDED */
+/* ADDED */
+in a,0 from A;
+endinstance;
+endmsc;
Added: trunk/tests/diff/flow08_1.mpr.result2
===================================================================
--- trunk/tests/diff/flow08_1.mpr.result2 (rev 0)
+++ trunk/tests/diff/flow08_1.mpr.result2 2011-03-13 20:07:29 UTC (rev 1061)
@@ -0,0 +1,19 @@
+OK: HMSC contains bMSC
+
+mscdocument msc_diff;
+msc Page_1;
+inst A;
+inst B;
+A: instance;
+in a,0 from B;
+/* ADDED */
+/* ADDED */
+in a,1 from B;
+endinstance;
+B: instance;
+/* ADDED */
+/* ADDED */
+out a,1 to A;
+out a,0 to A;
+endinstance;
+endmsc;
Added: trunk/tests/diff/flow09_1.mpr
===================================================================
--- trunk/tests/diff/flow09_1.mpr (rev 0)
+++ trunk/tests/diff/flow09_1.mpr 2011-03-13 20:07:29 UTC (rev 1061)
@@ -0,0 +1,18 @@
+msc Spec;
+inst A;
+inst B;
+text 'Diff algorithm bug: Flow Spec and specification Flow2';
+text 'Diff algorithm TODO: Set position to a new instance (Flow 3 and Spec)';
+A: instance;
+in n,0 from B;
+in n,1 from B;
+out m,2 to B;
+in n,3 from B;
+endinstance;
+B: instance;
+out n,0 to A;
+out n,1 to A;
+in m,2 from A;
+out n,3 to A;
+endinstance;
+endmsc;
Added: trunk/tests/diff/flow09_1.mpr.result
===================================================================
--- trunk/tests/diff/flow09_1.mpr.result (rev 0)
+++ trunk/tests/diff/flow09_1.mpr.result 2011-03-13 20:07:29 UTC (rev 1061)
@@ -0,0 +1,35 @@
+OK: HMSC contains bMSC
+
+mscdocument msc_diff;
+msc Spec;
+inst A;
+inst B;
+A: instance;
+/* ADDED */
+/* ADDED */
+out m,0 to B;
+/* ADDED */
+/* ADDED */
+out m,1 to B;
+in n,2 from B;
+in n,3 from B;
+out m,4 to B;
+/* REMOVED */
+/* REMOVED */
+in n,5 from B;
+endinstance;
+B: instance;
+/* ADDED */
+/* ADDED */
+in m,0 from A;
+/* ADDED */
+/* ADDED */
+in m,1 from A;
+out n,2 to A;
+out n,3 to A;
+in m,4 from A;
+/* REMOVED */
+/* REMOVED */
+out n,5 to A;
+endinstance;
+endmsc;
Added: trunk/tests/diff/spec09.mpr
===================================================================
--- trunk/tests/diff/spec09.mpr (rev 0)
+++ trunk/tests/diff/spec09.mpr 2011-03-13 20:07:29 UTC (rev 1061)
@@ -0,0 +1,18 @@
+msc Flow2;
+inst A;
+inst B;
+A: instance;
+out m,0 to B;
+out m,1 to B;
+in n,2 from B;
+in n,3 from B;
+out m,4 to B;
+endinstance;
+B: instance;
+in m,0 from A;
+in m,1 from A;
+out n,2 to A;
+out n,3 to A;
+in m,4 from A;
+endinstance;
+endmsc;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ma...@us...> - 2011-05-09 22:27:01
|
Revision: 1089
http://scstudio.svn.sourceforge.net/scstudio/?rev=1089&view=rev
Author: madzin
Date: 2011-05-09 22:26:55 +0000 (Mon, 09 May 2011)
Log Message:
-----------
Fix failed tests of membership absolut time. Absolute time is still not good tested
Modified Paths:
--------------
trunk/src/membership/membership_time.cpp
trunk/tests/membership/CMakeLists.txt
trunk/tests/membership/absolut_time_bmsc02_1.mpr
trunk/tests/membership/absolut_time_hmsc02.mpr
Modified: trunk/src/membership/membership_time.cpp
===================================================================
--- trunk/src/membership/membership_time.cpp 2011-05-09 21:57:12 UTC (rev 1088)
+++ trunk/src/membership/membership_time.cpp 2011-05-09 22:26:55 UTC (rev 1089)
@@ -348,14 +348,20 @@
//in case the absolut time constraints, it is necessary to compute interval
//TODO event has not to have list of the absolut times just one time constraints
if(c->get_absolut_time())
-{
+ {
+ if(first == NULL || second == NULL ||
+ first->get_absolut_times().size() == 0 || second->get_absolut_times().size() == 0)
+ {
+ return 3;
+ }
+
MscTimeIntervalSetD a = *(first->get_absolut_times().begin());
MscTimeIntervalSetD b = *(second->get_absolut_times().begin());
inter = get_continous_interval(c, a, b);
// inter = get_continous_interval(c, *(first->get_absolut_times().begin()), *(second->get_absolut_times().begin()));
std::cout << "time interval inter " << inter << std::endl;
-}
+ }
else
inter = c->get_time_matrix()->operator()(first, second);
@@ -413,6 +419,15 @@
{
bool time_node_b_id_set = true;
+ if((*it)->get_event_b() == NULL)
+ {
+ std::stringstream ss;
+ ss << (*it)->get_interval_set();
+ c->get_mem()->print_report(RS_ERROR, stringize() << L"Error: Unconnected time interval: "
+ << TOWSTRING(ss.str()) << L".");
+ return false;
+ }
+
//TODO i don't like it, probably better would be is_attribute_set or something similar
time_node_b_id = (*it)->get_event_b()->get_attribute("identification", -1, time_node_b_id_set);
Modified: trunk/tests/membership/CMakeLists.txt
===================================================================
--- trunk/tests/membership/CMakeLists.txt 2011-05-09 21:57:12 UTC (rev 1088)
+++ trunk/tests/membership/CMakeLists.txt 2011-05-09 22:26:55 UTC (rev 1089)
@@ -273,4 +273,4 @@
ADD_TEST(membership_test-121 ${MEMBERSHIP_TEST_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/absolut_time_hmsc02.mpr ${CMAKE_CURRENT_SOURCE_DIR}/absolut_time_bmsc02_1.mpr 1)
-ADD_TEST(membership_test-122 ${MEMBERSHIP_TEST_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/absolut_time_hmsc02.mpr ${CMAKE_CURRENT_SOURCE_DIR}/absolut_time_bmsc02_1.mpr 0)
+ADD_TEST(membership_test-122 ${MEMBERSHIP_TEST_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/absolut_time_hmsc02.mpr ${CMAKE_CURRENT_SOURCE_DIR}/absolut_time_bmsc02_2.mpr 0)
Modified: trunk/tests/membership/absolut_time_bmsc02_1.mpr
===================================================================
--- trunk/tests/membership/absolut_time_bmsc02_1.mpr 2011-05-09 21:57:12 UTC (rev 1088)
+++ trunk/tests/membership/absolut_time_bmsc02_1.mpr 2011-05-09 22:26:55 UTC (rev 1089)
@@ -7,6 +7,6 @@
endinstance;
B: instance;
out no,0 to A;
-time @[3];
+time [@3];
endinstance;
endmsc;
Modified: trunk/tests/membership/absolut_time_hmsc02.mpr
===================================================================
--- trunk/tests/membership/absolut_time_hmsc02.mpr 2011-05-09 21:57:12 UTC (rev 1088)
+++ trunk/tests/membership/absolut_time_hmsc02.mpr 2011-05-09 22:26:55 UTC (rev 1089)
@@ -9,6 +9,7 @@
inst A;
inst B;
A: instance;
+label e1;
in no,0 from B;
endinstance;
B: instance;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ma...@us...> - 2011-05-09 22:32:15
|
Revision: 1090
http://scstudio.svn.sourceforge.net/scstudio/?rev=1090&view=rev
Author: madzin
Date: 2011-05-09 22:32:09 +0000 (Mon, 09 May 2011)
Log Message:
-----------
Remove debugging outputs and corect the return value of membership test
Modified Paths:
--------------
trunk/src/membership/membership_time.cpp
trunk/tests/membership/CMakeLists.txt
Modified: trunk/src/membership/membership_time.cpp
===================================================================
--- trunk/src/membership/membership_time.cpp 2011-05-09 22:26:55 UTC (rev 1089)
+++ trunk/src/membership/membership_time.cpp 2011-05-09 22:32:09 UTC (rev 1090)
@@ -131,7 +131,6 @@
//TODO to nemoze byt list intervalov v evente pri absolutnom case, to nedava zmysel
MscTimeIntervalSetD a = *(min_a->get_absolut_times().begin());
MscTimeIntervalSetD b = *(max_b->get_absolut_times().begin());
-std::cout << "see 1 a " << a << " b " << b << std::endl;
bmsc_inter = get_continous_interval(c, a, b);
}
else
@@ -360,7 +359,6 @@
inter = get_continous_interval(c, a, b);
// inter = get_continous_interval(c, *(first->get_absolut_times().begin()), *(second->get_absolut_times().begin()));
-std::cout << "time interval inter " << inter << std::endl;
}
else
inter = c->get_time_matrix()->operator()(first, second);
@@ -571,7 +569,6 @@
MscTimeIntervalSetD a = *(min_a->get_absolut_times().begin());
MscTimeIntervalSetD b = *(max_b->get_absolut_times().begin());
//TODO to nemoze byt list intervalov v evente pri absolutnom case, to nedava zmysel
-std::cout << "see 2" << std::endl;
bmsc_inter = get_continous_interval(c, a, b);
}
else
@@ -599,7 +596,6 @@
MscTimeIntervalSetD a = *(min_a->get_absolut_times().begin());
MscTimeIntervalSetD b = *(max_b->get_absolut_times().begin());
//TODO to nemoze byt list intervalov v evente pri absolutnom case, to nedava zmysel
-std::cout << "see 3" << std::endl;
bmsc_inter = get_continous_interval(c, a, b);
}
else
@@ -644,7 +640,6 @@
MscTimeIntervalSetD a = *(min_a->get_absolut_times().begin());
MscTimeIntervalSetD b = *(min_b->get_absolut_times().begin());
//TODO to nemoze byt list intervalov v evente pri absolutnom case, to nedava zmysel
-std::cout << "see 4" << std::endl;
bmsc_inter = get_continous_interval(c, a, b);
}
else
Modified: trunk/tests/membership/CMakeLists.txt
===================================================================
--- trunk/tests/membership/CMakeLists.txt 2011-05-09 22:26:55 UTC (rev 1089)
+++ trunk/tests/membership/CMakeLists.txt 2011-05-09 22:32:09 UTC (rev 1090)
@@ -273,4 +273,4 @@
ADD_TEST(membership_test-121 ${MEMBERSHIP_TEST_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/absolut_time_hmsc02.mpr ${CMAKE_CURRENT_SOURCE_DIR}/absolut_time_bmsc02_1.mpr 1)
-ADD_TEST(membership_test-122 ${MEMBERSHIP_TEST_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/absolut_time_hmsc02.mpr ${CMAKE_CURRENT_SOURCE_DIR}/absolut_time_bmsc02_2.mpr 0)
+ADD_TEST(membership_test-122 ${MEMBERSHIP_TEST_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/absolut_time_hmsc02.mpr ${CMAKE_CURRENT_SOURCE_DIR}/absolut_time_bmsc02_2.mpr 1)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <lko...@us...> - 2011-07-09 03:25:56
|
Revision: 1122
http://scstudio.svn.sourceforge.net/scstudio/?rev=1122&view=rev
Author: lkorenciak
Date: 2011-07-09 03:25:49 +0000 (Sat, 09 Jul 2011)
Log Message:
-----------
added functionality for writing reports to visio from checkers
Modified Paths:
--------------
trunk/src/data/checker.h
trunk/src/data/reporter.h
trunk/src/view/visio/addon/document.cpp
trunk/tests/checker_test.cpp
Modified: trunk/src/data/checker.h
===================================================================
--- trunk/src/data/checker.h 2011-07-08 10:10:00 UTC (rev 1121)
+++ trunk/src/data/checker.h 2011-07-09 03:25:49 UTC (rev 1122)
@@ -26,6 +26,7 @@
#include "data/msc.h"
#include "data/prerequisite_check.h"
+#include "data/reporter.h"
class ChannelMapper;
class Checker;
@@ -40,7 +41,7 @@
/**
* Basic abstract class for all checking algorithms.
*/
-class SCMSC_EXPORT Checker
+class SCMSC_EXPORT Checker: public Reporter
{
public:
Modified: trunk/src/data/reporter.h
===================================================================
--- trunk/src/data/reporter.h 2011-07-08 10:10:00 UTC (rev 1121)
+++ trunk/src/data/reporter.h 2011-07-09 03:25:49 UTC (rev 1122)
@@ -54,7 +54,7 @@
std::wostream& m_stream;
};
-class Reporter
+class SCMSC_EXPORT Reporter
{
public:
Reporter() : m_printer(NULL) {}
Modified: trunk/src/view/visio/addon/document.cpp
===================================================================
--- trunk/src/view/visio/addon/document.cpp 2011-07-08 10:10:00 UTC (rev 1121)
+++ trunk/src/view/visio/addon/document.cpp 2011-07-09 03:25:49 UTC (rev 1122)
@@ -200,6 +200,8 @@
// append new checkers to the list
for(Checker **fpos = checkers; *fpos != NULL; fpos++)
{
+ (*fpos)->set_printer(m_reportView);
+
boost::shared_ptr<Checker> checker(*fpos);
m_checkers.push_back(checker);
}
Modified: trunk/tests/checker_test.cpp
===================================================================
--- trunk/tests/checker_test.cpp 2011-07-08 10:10:00 UTC (rev 1121)
+++ trunk/tests/checker_test.cpp 2011-07-09 03:25:49 UTC (rev 1122)
@@ -54,6 +54,9 @@
throw std::runtime_error("invalid checker");
}
+ StreamReportPrinter printer(std::wcerr);
+ checker->set_printer(&printer);
+
SRChannelMapperPtr srm(new SRChannelMapper());
BMscPtr bmsc = boost::dynamic_pointer_cast<BMsc>(msc);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ma...@us...> - 2011-07-11 11:49:06
|
Revision: 1129
http://scstudio.svn.sourceforge.net/scstudio/?rev=1129&view=rev
Author: madzin
Date: 2011-07-11 11:48:59 +0000 (Mon, 11 Jul 2011)
Log Message:
-----------
Change interface of find flow algorithm.
Modified Paths:
--------------
trunk/src/data/searcher.h
trunk/src/membership/membership_alg.cpp
trunk/src/membership/membership_base.h
trunk/src/view/visio/addon/document.cpp
trunk/tests/diff/diff_test.cpp
trunk/tests/membership/membership_test.cpp
Modified: trunk/src/data/searcher.h
===================================================================
--- trunk/src/data/searcher.h 2011-07-10 20:07:33 UTC (rev 1128)
+++ trunk/src/data/searcher.h 2011-07-11 11:48:59 UTC (rev 1129)
@@ -41,11 +41,11 @@
virtual PreconditionList get_preconditions(MscPtr msc) const = 0;
//! Find the first occurence of needle in haystack.
- virtual MscPtr find(MscPtr haystack, MscPtr needle) = 0;
- virtual MscPtr find(MscPtr msc, std::vector<MscPtr>& bmscs) = 0;
+// virtual std::map<std::wstring, std::vector<MscPtr> > find(MscPtr haystack, MscPtr needle) = 0;
+ virtual std::map<std::wstring, std::vector<MscPtr> > find(MscPtr msc, std::vector<MscPtr>& bmscs) = 0;
//! Make diff between specification and flow
- virtual MscPtr diff(MscPtr specification, std::vector<MscPtr>& flows) = 0;
+// virtual MscPtr diff(MscPtr specification, std::vector<MscPtr>& flows) = 0;
};
typedef boost::shared_ptr<Searcher> SearcherPtr;
Modified: trunk/src/membership/membership_alg.cpp
===================================================================
--- trunk/src/membership/membership_alg.cpp 2011-07-10 20:07:33 UTC (rev 1128)
+++ trunk/src/membership/membership_alg.cpp 2011-07-11 11:48:59 UTC (rev 1129)
@@ -35,9 +35,13 @@
}
/*
- * Tries finding bMsc in Msc
+ * Tries finding bMSC in MSC
+ *
+ * returns the cover of the specification, when the cover is not supposed to be shown it returns NULL.
+ * this occurs when concrete flow does not match the specification or the specification is bMSC.
*/
-MscPtr MembershipAlg::find(MscPtr msc, MscPtr bmsc, std::vector<std::wstring> instances)
+MscPtr MembershipAlg::find_flow(MscPtr msc, MscPtr bmsc, std::vector<std::wstring> instances,
+ std::map<std::wstring, std::vector<MscPtr> >& messages)
{
HMscPtr hmsc = boost::dynamic_pointer_cast<HMsc > (msc);
BMscPtr bmsc_f = boost::dynamic_pointer_cast<BMsc > (bmsc);
@@ -52,57 +56,110 @@
c->set_mem(this);
c->set_focused_instances(instances);
c->set_bmsc(bmsc_f);
+ c->set_result_messages(messages);
MscPtr result = NULL;
+ //the specification is HMSC
if (hmsc != NULL)
+ {
result = search_hmsc(c, hmsc, bmsc_f);
+ delete c;
+
+ if(result == NULL)
+ {
+ print_report(RS_ERROR, L"HMsc specification does not contain \"" + bmsc->get_label() + L"\" flow.");
+ return NULL;
+ }
+ else
+ {
+ print_report(RS_NOTICE, L"Flow \"" + bmsc->get_label() + L"\" meets the specification.");
+ return result;
+ }
+ }
+ //the specification is BMSC
else
{
BMscPtr bmsc = boost::dynamic_pointer_cast<BMsc > (msc);
+
if(bmsc != NULL)
+ {
result = search_bmsc(c, bmsc, bmsc_f);
- else
- {
- print_report(RS_ERROR, L"Find flow algorithm cannot recognize a type of browsed MSC.");
+ delete c;
+
+ if(result != NULL)
+ {
+ print_report(RS_NOTICE, L"Flow \"" + bmsc->get_label() + L"\" meets the specification.");
+ }
+ else
+ {
+ //TODO check the output message whether the message that the flow does not meet the specification is printed.
+ if(!instances.empty())
+ return NULL;
+
+ std::vector<MscPtr> flows;
+ flows.push_back(bmsc_f);
+
+ result = diff(bmsc, flows);
+
+ if(result == NULL)
+ print_report(RS_ERROR, L"Error: Internal Error.");
+ else
+ {
+ std::wstring message;
+ message = L"Msc \"" + bmsc_f->get_label() + L"\" does not meet the specification. Diff: ";
+
+ std::vector<MscPtr> diff_result;
+ diff_result.push_back(result);
+
+ messages.insert(std::make_pair(message, diff_result));
+ }
+ }
+
+ //the NULL value means that the specification cover will not be depicted
return NULL;
}
}
- delete c;
- return result;
+ print_report(RS_ERROR, L"Find flow algorithm cannot recognize a MSC type of specification.");
+ return NULL;
}
-MscPtr MembershipAlg::find(MscPtr msc, MscPtr bmsc)
+std::map<std::wstring, std::vector<MscPtr> > MembershipAlg::find(MscPtr msc, std::vector<MscPtr>& bmscs,
+ std::vector<std::wstring> instances)
{
- std::vector<std::wstring> instances;
- return this->find(msc, bmsc, instances);
-}
-
-MscPtr MembershipAlg::find(MscPtr msc, std::vector<MscPtr>& bmscs)
-{
MscPtr temp;
- bool found = false;
+ bool cover = false;
+ std::map<std::wstring, std::vector<MscPtr> > messages;
for(unsigned int i = 0; i < bmscs.size(); i++)
{
temp = NULL;
- temp = find(msc, bmscs[i]);
+ temp = find_flow(msc, bmscs[i], instances, messages);
- if(temp == NULL)
- print_report(RS_ERROR, L"HMsc specification does not contain \"" + bmscs[i]->get_label() + L"\" flow.");
+ if(temp != NULL)
+ cover = true;
+ }
+
+ if(cover)
+ {
+ std::vector<MscPtr> msc_cover;
+ msc_cover.push_back(msc);
+
+ if(bmscs.size() > 1)
+ messages.insert(std::make_pair(L"Flows coverege of the specification.", msc_cover));
else
- {
- print_report(RS_NOTICE, L"Flow \"" + bmscs[i]->get_label() + L"\" meets the specification.");
- found = true;
- }
+ messages.insert(std::make_pair(L"Flow coverege of the specification.", msc_cover));
}
- if(found)
- return msc;
- else
- return NULL;
+ return messages;
}
+std::map<std::wstring, std::vector<MscPtr> > MembershipAlg::find(MscPtr msc, std::vector<MscPtr>& bmscs)
+{
+ std::vector<std::wstring> instances;
+ return find(msc, bmscs, instances);
+}
+
/*
* Tries to find bMSC in HMSC
*/
Modified: trunk/src/membership/membership_base.h
===================================================================
--- trunk/src/membership/membership_base.h 2011-07-10 20:07:33 UTC (rev 1128)
+++ trunk/src/membership/membership_base.h 2011-07-11 11:48:59 UTC (rev 1129)
@@ -149,6 +149,9 @@
enum DiffType diff_type;
+ std::map<std::wstring, std::vector<MscPtr> > result_messages;
+// bool search_bmsc;
+
public:
MembershipContext()
{
@@ -581,6 +584,32 @@
{
diff_type = type;
}
+
+ void set_result_messages(std::map<std::wstring, std::vector<MscPtr> >& messages)
+ {
+ result_messages = messages;
+ }
+/*
+ std::map<string, std::vector<MscPtr> > get_result_messages()
+ {
+ return result_messages;
+ }
+*/
+ void add_result_message(std::wstring message, std::vector<MscPtr> results)
+ {
+ result_messages.insert(std::make_pair(message, results));
+ }
+/*
+ void set_search_bmsc()
+ {
+ search_bmsc = true;
+ }
+
+ bool get_search_bmsc()
+ {
+ return search_bmsc;
+ }
+*/
};
//! store information about the position of checking algorithm on instance
@@ -1056,6 +1085,10 @@
class SCMEMBERSHIP_EXPORT MembershipAlg: public Searcher
{
+private:
+ MscPtr find_flow(MscPtr msc, MscPtr bmsc, std::vector<std::wstring> instances,
+ std::map<std::wstring, std::vector<MscPtr> >& messages);
+ MscPtr diff(MscPtr specification, std::vector<MscPtr>& flows);
public:
@@ -1080,16 +1113,16 @@
virtual PreconditionList get_preconditions(MscPtr msc) const;
//! Finds the bmsc flow in hmsc specification
- virtual MscPtr find(MscPtr hmsc, MscPtr bmsc);
+// virtual MscPtr find(MscPtr hmsc, MscPtr bmsc);
//! Make diff between specification and flow
- virtual MscPtr diff(MscPtr specification, std::vector<MscPtr>& flows);
//! Finds each bmsc flow from the vector in hmsc specification
- virtual MscPtr find(MscPtr hmsc, std::vector<MscPtr>& bmscs);
+ virtual std::map<std::wstring, std::vector<MscPtr> > find(MscPtr hmsc, std::vector<MscPtr>& bmscs);
//! Finds the bmsc flow in hmsc specification, focusing on specified instances, DO NOT CHECKING TIME CONSTRAINTS
- virtual MscPtr find(MscPtr hmsc, MscPtr bmsc, std::vector<std::wstring> instances);
+// virtual std::map<std::wstring, std::vector<MscPtr> > find(MscPtr hmsc, MscPtr bmsc, std::vector<std::wstring> instances);
+ virtual std::map<std::wstring, std::vector<MscPtr> > find(MscPtr msc, std::vector<MscPtr>& bmscs, std::vector<std::wstring> instances);
MscPtr get_dp_msc(MscPtr msc);
Modified: trunk/src/view/visio/addon/document.cpp
===================================================================
--- trunk/src/view/visio/addon/document.cpp 2011-07-10 20:07:33 UTC (rev 1128)
+++ trunk/src/view/visio/addon/document.cpp 2011-07-11 11:48:59 UTC (rev 1129)
@@ -1157,13 +1157,11 @@
if (msc_haystack == NULL || msc_needles.empty())
return VAORC_FAILURE;
- MscPtr result;
+ std::map<std::wstring, std::vector<MscPtr> > result_messages;
+ std::map<std::wstring, std::vector<MscPtr> >::iterator result_it;
try
{
- if(dlg.m_diffEnabled)
- result = m_membership->diff(msc_haystack, msc_needles);
- else
result = m_membership->find(msc_haystack, msc_needles);
}
catch(std::exception &exc)
@@ -1173,37 +1171,11 @@
return VAORC_FAILURE;
}
- std::wstring flows;
- for(u_int i = 0; i < msc_needles.size(); i++)
+ for(result_it = result_messages.begin(); result_it != result_messages.end(); result_it++)
{
- if(i) flows += _T(", ");
- flows += msc_needles.at(i)->get_label();
- }
+ m_reportView->Print(RS_NOTICE, result_it->first, result_it->second);
+ }
- if (result != NULL)
- {
- if(dlg.m_diffEnabled)
- m_reportView->Print(RS_NOTICE, stringize()
- << "Flow \"" << flows << "\" differs from the speification \"" << msc_haystack->get_label()
- << "\".", result);
- else
- {
- if(msc_needles.size() > 1)
- m_reportView->Print(RS_NOTICE, stringize()
- << "Flows coverege of the specification \"" << msc_haystack->get_label() << "\".", result);
- else
- m_reportView->Print(RS_NOTICE, stringize()
- << "Flow coverege of the specification \"" << msc_haystack->get_label() << "\".", result);
- }
- }
- else
- {
- if(dlg.m_diffEnabled)
- m_reportView->Print(RS_NOTICE, stringize()
- << "Flow \"" << flows << "\" and specification " << msc_haystack->get_label()
- << " are same.");
- }
-
return VAORC_SUCCESS;
}
Modified: trunk/tests/diff/diff_test.cpp
===================================================================
--- trunk/tests/diff/diff_test.cpp 2011-07-10 20:07:33 UTC (rev 1128)
+++ trunk/tests/diff/diff_test.cpp 2011-07-11 11:48:59 UTC (rev 1129)
@@ -100,13 +100,12 @@
MembershipAlg mem;
mem.set_printer(&printer);
- MscPtr result;
+ std::map<std::wstring, std::vector<MscPtr> > result;
- result = mem.diff(msc[0], msc_b);
+ result = mem.find(msc[0], msc_b);
- if(result == NULL)
+ if(result.size() == 0)
{
-std::cerr << "result was null" << std::endl;
if(satisfied)
{
std::cerr << "ERROR: HMSC should contain bMSC" << std::endl;
@@ -129,7 +128,12 @@
try
{
- z120.save_msc(std::cout, L"msc_diff", result);
+ std::map<std::wstring, std::vector<MscPtr> >::iterator result_it;
+ for(result_it = result.begin(); result_it != result.end(); result_it++)
+ {
+ for(unsigned int i = 0; i < result_it->second.size(); i++)
+ z120.save_msc(std::cout, L"msc_diff", result_it->second.at(i));
+ }
}
catch(std::exception& exc)
{
Modified: trunk/tests/membership/membership_test.cpp
===================================================================
--- trunk/tests/membership/membership_test.cpp 2011-07-10 20:07:33 UTC (rev 1128)
+++ trunk/tests/membership/membership_test.cpp 2011-07-11 11:48:59 UTC (rev 1129)
@@ -102,13 +102,16 @@
BMscPtr bmsc = boost::dynamic_pointer_cast<BMsc>(msc_b[0]);
- MscPtr result;
+ std::map<std::wstring, std::vector<MscPtr> > result;
+ std::vector<MscPtr> bmscs;
+ bmscs.push_back(bmsc);
if(focused_instances.empty())
- result = mem.find(msc[0], bmsc);
+ result = mem.find(msc[0], bmscs);
else
- result = mem.find(msc[0], bmsc, focused_instances);
+ result = mem.find(msc[0], bmscs, focused_instances);
+/*
if(result == NULL)
{
std::cerr << "result was null" << std::endl;
@@ -142,6 +145,12 @@
errors = 1;
}
}
+*/
+
+if(result.empty())
+std::cerr << "Result messages are empty" << std::endl;
+else
+std::cerr << "Result messages are NOT empty" << std::endl;
return errors;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ma...@us...> - 2011-07-13 08:31:34
|
Revision: 1139
http://scstudio.svn.sourceforge.net/scstudio/?rev=1139&view=rev
Author: madzin
Date: 2011-07-13 08:31:27 +0000 (Wed, 13 Jul 2011)
Log Message:
-----------
Modify output of Find Flow algorithm. Add new visualization of a path and corupted time constraints.
Modified Paths:
--------------
trunk/src/data/Z120/z120_save.cpp
trunk/src/data/msc.h
trunk/src/membership/membership_alg.cpp
trunk/src/membership/membership_alg.h
trunk/src/membership/membership_base.h
trunk/src/membership/membership_time.cpp
trunk/src/membership/membership_time.h
trunk/src/view/visio/addon/visualize.cpp
trunk/tests/membership/membership_test.cpp
Modified: trunk/src/data/Z120/z120_save.cpp
===================================================================
--- trunk/src/data/Z120/z120_save.cpp 2011-07-12 21:33:15 UTC (rev 1138)
+++ trunk/src/data/Z120/z120_save.cpp 2011-07-13 08:31:27 UTC (rev 1139)
@@ -328,6 +328,9 @@
case MARKED: stream << "/* MARKED */" << std::endl; break;
case ADDED: stream << "/* ADDED */" << std::endl; break;
case REMOVED: stream << "/* REMOVED */" << std::endl; break;
+ case NOT_COVER: stream << "/* NOT_COVER */" << std::endl; break;
+ case NOT_FULL_COVER: stream << "/* NOT_FULL_COVER */" << std::endl; break;
+ case PATH: stream << "/* PATH */" << std::endl; break;
default: throw std::runtime_error("Error: unexpected behaviour");
}
Modified: trunk/src/data/msc.h
===================================================================
--- trunk/src/data/msc.h 2011-07-12 21:33:15 UTC (rev 1138)
+++ trunk/src/data/msc.h 2011-07-13 08:31:27 UTC (rev 1139)
@@ -143,7 +143,7 @@
#endif
-enum MarkType {NONE, MARKED, ADDED, REMOVED};
+enum MarkType {NONE, MARKED, ADDED, REMOVED, NOT_COVER, NOT_FULL_COVER, PATH};
/**
* \brief Common basic abstract class for all elements of MSC
Modified: trunk/src/membership/membership_alg.cpp
===================================================================
--- trunk/src/membership/membership_alg.cpp 2011-07-12 21:33:15 UTC (rev 1138)
+++ trunk/src/membership/membership_alg.cpp 2011-07-13 08:31:27 UTC (rev 1139)
@@ -16,8 +16,6 @@
*/
#include "membership/membership_alg.h"
-#include "check/time/time_pseudocode.h"
-#include "check/time/tightening.h"
#include <map>
/*
@@ -39,6 +37,9 @@
*
* returns the cover of the specification, when the cover is not supposed to be shown it returns NULL.
* this occurs when concrete flow does not match the specification or the specification is bMSC.
+ *
+ * return: in current version only NULL,
+ * NULL value means that the specification cover will not be depicted.
*/
MscPtr MembershipAlg::find_flow(MscPtr msc, MscPtr bmsc, std::vector<std::wstring> instances,
std::map<std::wstring, std::vector<MscPtr> >& messages)
@@ -63,16 +64,52 @@
if (hmsc != NULL)
{
result = search_hmsc(c, hmsc, bmsc_f);
- delete c;
if(result == NULL)
{
- print_report(RS_ERROR, L"HMsc specification does not contain \"" + bmsc->get_label() + L"\" flow.");
+ print_report(RS_ERROR, L"The specification does not contain \"" + bmsc->get_label() + L"\" flow.");
+ delete c;
return NULL;
}
else
{
- print_report(RS_NOTICE, L"Flow \"" + bmsc->get_label() + L"\" meets the specification.");
+ if(c->get_min_not_covered_intervals() != 0)
+ {
+ std::wstring msg = L"Some intervals does not satisfy the time constraints. ";
+ msg += L"For more information: ";
+
+ std::vector<MscPtr> result_vec;
+ result_vec.push_back(result);
+
+ messages.insert(std::make_pair(msg, result_vec));
+
+ delete c;
+ return NULL;
+ }
+
+ if(c->get_min_not_full_covered_intervals() != 0)
+ {
+ std::wstring msg = L"Some intervals could not satisfy the time constraints. ";
+ msg += L"For more information: ";
+
+ std::vector<MscPtr> result_vec;
+ result_vec.push_back(result);
+
+ messages.insert(std::make_pair(msg, result_vec));
+
+ delete c;
+ return NULL;
+ }
+
+ std::wstring msg = L"Flow \"" + bmsc->get_label() + L"\" meets the specification. ";
+ msg += L"The specification cover: ";
+
+ std::vector<MscPtr> result_vec;
+ result_vec.push_back(result);
+
+ messages.insert(std::make_pair(msg, result_vec));
+
+ delete c;
return result;
}
}
@@ -84,26 +121,33 @@
if(bmsc != NULL)
{
result = search_bmsc(c, bmsc, bmsc_f);
- delete c;
- if(result != NULL)
+ if(result == NULL)
{
- print_report(RS_NOTICE, L"Flow \"" + bmsc->get_label() + L"\" meets the specification.");
- }
- else
- {
- //TODO check the output message whether the message that the flow does not meet the specification is printed.
if(!instances.empty())
+ {
+ std::wstring instances_name;
+
+ for(unsigned int i = 0; i < instances.size(); i++)
+ {
+ if(i != 0)
+ instances_name += L",";
+
+ instances_name += instances[i];
+ }
+
+ print_report(RS_ERROR, L"Flow \"" + bmsc->get_label() + L"\" does not meet the specification on instances:" + instances_name);
+
+ delete c;
return NULL;
+ }
std::vector<MscPtr> flows;
flows.push_back(bmsc_f);
result = diff(bmsc, flows);
- if(result == NULL)
- print_report(RS_ERROR, L"Error: Internal Error.");
- else
+ if(result != NULL)
{
std::wstring message;
message = L"Msc \"" + bmsc_f->get_label() + L"\" does not meet the specification. Diff: ";
@@ -113,9 +157,44 @@
messages.insert(std::make_pair(message, diff_result));
}
+
+std::cerr << "som tuuuuuuuuuuuuu" << std::endl;
+
+ delete c;
+ return NULL;
}
- //the NULL value means that the specification cover will not be depicted
+ if(c->get_min_not_covered_intervals() != 0)
+ {
+ std::wstring msg = L"Some intervals does not satisfy the time constraints. ";
+ msg += L"For more information: ";
+
+ std::vector<MscPtr> result_vec;
+ result_vec.push_back(result);
+
+ messages.insert(std::make_pair(msg, result_vec));
+
+ delete c;
+ return NULL;
+ }
+
+ if(c->get_min_not_full_covered_intervals() != 0)
+ {
+ std::wstring msg = L"Some intervals could not satisfy the time constraints. ";
+ msg += L"For more information: ";
+
+ std::vector<MscPtr> result_vec;
+ result_vec.push_back(result);
+
+ messages.insert(std::make_pair(msg, result_vec));
+
+ delete c;
+ return NULL;
+ }
+
+ print_report(RS_NOTICE, L"Flow \"" + bmsc->get_label() + L"\" meets the specification.");
+
+ delete c;
return NULL;
}
}
@@ -146,9 +225,9 @@
msc_cover.push_back(msc);
if(bmscs.size() > 1)
- messages.insert(std::make_pair(L"Flows coverege of the specification.", msc_cover));
+ messages.insert(std::make_pair(L"Flows coverage of the specification.", msc_cover));
else
- messages.insert(std::make_pair(L"Flow coverege of the specification.", msc_cover));
+ messages.insert(std::make_pair(L"Flow coverage of the specification.", msc_cover));
}
return messages;
@@ -173,18 +252,19 @@
dup_hmsc = hmsc;
// dup_hmsc = dup_hmsc = duplicator.duplicate(hmsc);
+ c->set_hmsc(dup_hmsc);
+
//creates configuration of defined bMSC
ConfigurationPtr searched_conf = new Configuration(bmsc_f->get_instances());
StartNodePtr start_node = dup_hmsc->get_start();
- //strt of searching
- if (check_branch(c, start_node, searched_conf))
+ //strt of searching, make result in case the flow was found or message matching was found
+ //(not satisfied time constraints are marked in make_result function)
+ if (check_branch(c, start_node, searched_conf) || c->get_result_path_size() > 0)
return make_result(c, dup_hmsc);
else
return NULL;
-
- return NULL;
}
bool check_end_node(MembershipContext* c, EndNodePtr end, ConfigurationPtr b)
@@ -204,6 +284,29 @@
}
}
+bool store_result(MembershipContext* c)
+{
+ if(c->get_not_full_covered_intervals().size() == 0 && c->get_not_covered_intervals().size() == 0)
+ return true;
+
+ if(c->get_not_covered_intervals().size() < c->get_min_not_covered_intervals())
+ {
+ c->set_min_not_covered_intervals(c->get_not_covered_intervals().size());
+ c->set_min_not_full_covered_intervals(c->get_not_full_covered_intervals().size());
+ c->update_result_path();
+ }
+ else
+ {
+ if(c->get_not_covered_intervals().size() == c->get_min_not_covered_intervals() &&
+ c->get_not_full_covered_intervals().size() < c->get_min_not_full_covered_intervals())
+ {
+ c->set_min_not_full_covered_intervals(c->get_not_full_covered_intervals().size());
+ c->update_result_path();
+ }
+ }
+
+ return false;
+}
/*
* Checks branch if the communication is coressponding
*
@@ -223,7 +326,7 @@
if (end != NULL)
{
if(check_end_node(c, end, b) && check_time_constraints(c))
- return true;
+ return store_result(c);
else
return false;
}
@@ -983,54 +1086,35 @@
return false;
}
-MscPtr make_result(MembershipContext* c, HMscPtr msc)
+//! makes not full covered intervals colored
+void color_intervals(MembershipContext* c)
{
- if(c->get_not_covered_intervals().size() > 0)
- {
- if(c->get_not_covered_intervals().size() > 1)
- c->get_mem()->print_report(RS_ERROR, L"Marked time intervals in the specification is not full covered.");
- else
- c->get_mem()->print_report(RS_ERROR, L"Marked time interval in the specification is not full covered.");
+ std::vector<TimeRelationPtr> relations = c->get_not_full_covered_intervals();
- color_intervals(c);
- }
+ for(unsigned int i = 0; i < relations.size(); i++)
+ relations[i]->set_marked(NOT_FULL_COVER);
- if(c->get_print_path())
- return color_path(c, msc);
- else
- {
- HMscNodePtr start = msc->get_start();
+ relations = c->get_not_covered_intervals();
- if(start == NULL)
- throw std::runtime_error("Unexpected behaviour.");
-
- PredecessorNode* predecessor = dynamic_cast<PredecessorNode*>(start.get());
-
- if(predecessor == NULL)
- throw std::runtime_error("Unexpected behaviour.");
-
- SuccessorNode* suc = predecessor->get_successors().front()->get_successor();
- ReferenceNode* ref = dynamic_cast<ReferenceNode*>(suc);
-
- if(ref == NULL)
- throw std::runtime_error("Unexpected behaviour.");
-
- return ref->get_msc();
- }
+ for(unsigned int i = 0; i < relations.size(); i++)
+ relations[i]->set_marked(NOT_COVER);
}
+//! makes path colored
HMscPtr color_path(MembershipContext* c, HMscPtr msc)
{
HMscNodePtr node;
PredecessorNode* predecessor;
SuccessorNode* successor;
- NodeRelationPtrVector predecessors_rel;
+ NodeRelationPtrVector predecessors_rel;
while(c->get_path_size() > 0)
{
node = c->top_pop_path();
- node->set_marked();
+ if(node->get_marked() == NONE)
+ node->set_marked(PATH);
+
//in case the node is reference,
//this increase the value of attribute membership_counter
//membership counter - store amount of node memberships (occurrences) in the flow
@@ -1049,20 +1133,42 @@
//end node is not predecessor
if(predecessor == NULL)
continue;
-
+
//mark the connections
for(unsigned int i = 0; i < predecessors_rel.size(); i++)
if(predecessors_rel[i]->get_predecessor() == predecessor)
- predecessors_rel[i]->set_marked();
+ predecessors_rel[i]->set_marked(PATH);
}
return msc;
}
-void color_intervals(MembershipContext* c)
+MscPtr make_result(MembershipContext* c, HMscPtr msc)
{
- std::vector<TimeRelationPtr> relations = c->get_not_covered_intervals();
-
- for(unsigned int i = 0; i < relations.size(); i++)
- relations[i]->set_marked();
+//TODO remove the second parameter and use duplicator to create new
+ if(c->get_not_full_covered_intervals().size() > 0 || c->get_not_covered_intervals().size() > 0)
+ color_intervals(c);
+
+ if(c->get_print_path())
+ return color_path(c, msc);
+ else
+ {
+ HMscNodePtr start = msc->get_start();
+
+ if(start == NULL)
+ throw std::runtime_error("Unexpected behaviour.");
+
+ PredecessorNode* predecessor = dynamic_cast<PredecessorNode*>(start.get());
+
+ if(predecessor == NULL)
+ throw std::runtime_error("Unexpected behaviour.");
+
+ SuccessorNode* suc = predecessor->get_successors().front()->get_successor();
+ ReferenceNode* ref = dynamic_cast<ReferenceNode*>(suc);
+
+ if(ref == NULL)
+ throw std::runtime_error("Unexpected behaviour.");
+
+ return ref->get_msc();
+ }
}
Modified: trunk/src/membership/membership_alg.h
===================================================================
--- trunk/src/membership/membership_alg.h 2011-07-12 21:33:15 UTC (rev 1138)
+++ trunk/src/membership/membership_alg.h 2011-07-13 08:31:27 UTC (rev 1139)
@@ -98,10 +98,4 @@
MscPtr make_result(MembershipContext* c, HMscPtr msc);
-//! makes path colored
-HMscPtr color_path(MembershipContext* c, HMscPtr msc);
-
-//! makes not full covered intervals colored
-void color_intervals(MembershipContext* c);
-
#endif
Modified: trunk/src/membership/membership_base.h
===================================================================
--- trunk/src/membership/membership_base.h 2011-07-12 21:33:15 UTC (rev 1138)
+++ trunk/src/membership/membership_base.h 2011-07-13 08:31:27 UTC (rev 1139)
@@ -21,6 +21,7 @@
#include <set>
#include <vector>
#include <string>
+#include <climits>
#include "data/msc.h"
#include "data/searcher.h"
#include "membership/export.h"
@@ -34,6 +35,7 @@
class MembershipAlg;
class SnapshotContext;
class CoregionOrdering;
+class MembershipContext;
class MembershipTimeRelation;
enum check_type {membership, receive_ordering};
@@ -52,6 +54,7 @@
private:
std::set<Event*> start;
std::set<Event*> end;
+ TimeRelationPtr original_relation;
MscTimeIntervalSet<double> interval_set;
@@ -63,9 +66,10 @@
friend void intrusive_ptr_release(const MembershipTimeRelation *ptr);
public:
- MembershipTimeRelation(MscTimeIntervalSet<double> interval_set)
+ MembershipTimeRelation(TimeRelationPtr original_relation)
{
- this->interval_set = interval_set;
+ this->original_relation = original_relation;
+ this->interval_set = original_relation->get_interval_set();
this->m_counter = 0;
}
@@ -102,6 +106,11 @@
{
return interval_set;
}
+
+ TimeRelationPtr get_original_rel()
+ {
+ return original_relation;
+ }
};
inline void intrusive_ptr_add_ref(const MembershipTimeRelation *ptr)
@@ -128,6 +137,7 @@
int max_id; //! identification for receive events
BMscPtr bmsc; //! bmsc which represents the flow
MscPtr msc; //! msc which represents the specification
+ HMscPtr hmsc; //! hmsc which represents the specification //TODO (find uses hmsc, diff uses msc)
std::vector<std::wstring> focused_instances; //! name of instances on which a user is focused on
std::map<CoregionAreaPtr, SnapshotContextPtr> snapshots; //! snapshots of context for each coregion
std::vector<Event*> attributed_events; //! events with attribute
@@ -137,9 +147,17 @@
std::map<CoregionAreaPtr, std::vector<CoregionOrderingPtr> > checked_orderings; //! checked possibilities of coregion ordering
std::map<CoregionAreaPtr, CoregionOrderingPtr> coregion_ordering; //! save ordering of coregion events in appropriate coregion
BMscIntervalSetComponentMatrix* time_matrix; //! matrix of all time intervals among events in bmsc
+ std::vector<TimeRelationPtr> not_covered_intervals; //! intervals in specification which are not satisfied
std::vector<TimeRelationPtr> not_full_covered_intervals; //! intervals in specification which are not full covered
std::stack<HMscNodePtr> path; //! store information about the path if the flow meets the specification
bool print_path; //! store whether the path will be printed
+
+// std::multimap<int, HMscPtr> not_covered_intervals_per_path;
+// std::multimap<int, HMscPtr> not_full_covered_intervals_per_path;
+ unsigned int min_not_covered_intervals;
+ unsigned int min_not_full_covered_intervals;
+ std::vector<HMscNodePtr> result_path;
+
std::stack<std::map<TimeRelationEventPtr, std::vector<MembershipTimeRelationPtr> > > relative_time;
std::stack<std::vector<TimeRelationRefNodePtr> > ref_node_time_stack;
std::map<TimeRelationRefNodePtr, std::vector<MembershipTimeRelationPtr> > ref_node_time; //! key is a time relation in hmsc specification and set of MembershipTimeRelationPtr which hold possible events for the comparison.
@@ -159,6 +177,8 @@
print_path = true;
diff_type = NOT_DIFF;
checking_time_mode = NO_TIME;
+ min_not_covered_intervals = UINT_MAX;
+ min_not_full_covered_intervals = UINT_MAX;
}
void set_mem(MembershipAlg* m)
@@ -190,6 +210,11 @@
{
return bmsc;
}
+
+ void set_hmsc(HMscPtr h)
+ {
+ hmsc = h;
+ }
void set_specification(MscPtr m)
{
@@ -340,16 +365,86 @@
return time_matrix;
}
- void add_not_covered_interval(TimeRelationPtr hmsc_inter)
+ void add_not_full_covered_interval(TimeRelationPtr inter)
{
- not_full_covered_intervals.push_back(hmsc_inter);
+ not_full_covered_intervals.push_back(inter);
}
- const std::vector<TimeRelationPtr> get_not_covered_intervals()
+ const std::vector<TimeRelationPtr> get_not_full_covered_intervals()
{
return not_full_covered_intervals;
}
+/*
+ void add_not_full_covered_path()
+ {
+ MscPtr result = make_result(this, hmsc);
+ not_full_covered_intervals_per_path.insert(std::make_pair(not_full_covered_intervals.size(), hmsc));
+
+ not_full_covered_intervals.clear();
+
+ while(path.empty())
+ {
+ path.pop();
+ }
+ }
+
+ std::multimap<int, HMscPtr> get_not_full_covered_paths()
+ {
+ return not_full_covered_intervals_per_path;
+ }
+*/
+
+ void add_not_covered_interval(TimeRelationPtr inter)
+ {
+ not_covered_intervals.push_back(inter);
+ }
+
+ const std::vector<TimeRelationPtr> get_not_covered_intervals()
+ {
+ return not_covered_intervals;
+ }
+
+/*
+ void add_not_covered_path()
+ {
+ MscPtr result = make_result(this, hmsc);
+ not_full_covered_intervals_per_path.insert(std::make_pair(not_covered_intervals.size(), hmsc));
+
+ not_covered_intervals.clear();
+ not_full_covered_intervals.clear();
+
+ while(path.empty())
+ {
+ path.pop();
+ }
+ }
+
+ std::multimap<int, HMscPtr> get_not_covered_paths()
+ {
+ return not_covered_intervals_per_path;
+ }
+*/
+ void set_min_not_covered_intervals(int x)
+ {
+ min_not_covered_intervals = x;
+ }
+
+ unsigned int get_min_not_covered_intervals()
+ {
+ return min_not_covered_intervals;
+ }
+
+ void set_min_not_full_covered_intervals(int x)
+ {
+ min_not_full_covered_intervals = x;
+ }
+
+ unsigned int get_min_not_full_covered_intervals()
+ {
+ return min_not_full_covered_intervals;
+ }
+
void push_path(HMscNodePtr node)
{
path.push(node);
@@ -372,6 +467,11 @@
return path.size();
}
+ int get_result_path_size()
+ {
+ return result_path.size();
+ }
+
void print_msc_path(bool value)
{
print_path = value;
@@ -382,6 +482,22 @@
return print_path;
}
+ //TODO upravit aby nedochadzalo k tolkemu kopirovaniu
+ void update_result_path()
+ {
+ result_path.clear();
+
+ while(!path.empty())
+ {
+ result_path.push_back(top_pop_path());
+ }
+
+ for(int i = result_path.size()-1; i >=0; i--)
+ {
+ path.push(result_path[i]);
+ }
+ }
+
void add_relative_time(Event* e, TimeRelationEventPtrList list, Event* node_e)
{
std::map<TimeRelationEventPtr, std::vector<MembershipTimeRelationPtr> >::iterator map_it;
@@ -396,7 +512,7 @@
{
std::set<Event*> end;
end.insert(e);
- MembershipTimeRelationPtr time_rel = new MembershipTimeRelation((*list_it)->get_interval_set());
+ MembershipTimeRelationPtr time_rel = new MembershipTimeRelation(*list_it);
time_rel->set_end(end);
std::vector<MembershipTimeRelationPtr> vec;
@@ -407,7 +523,7 @@
{
std::set<Event*> start;
start.insert(e);
- MembershipTimeRelationPtr time_rel = new MembershipTimeRelation((*list_it)->get_interval_set());
+ MembershipTimeRelationPtr time_rel = new MembershipTimeRelation(*list_it);
time_rel->set_start(start);
std::vector<MembershipTimeRelationPtr> vec;
@@ -429,7 +545,7 @@
{
std::set<Event*> end;
end.insert(e);
- MembershipTimeRelationPtr time_rel = new MembershipTimeRelation((*list_it)->get_interval_set());
+ MembershipTimeRelationPtr time_rel = new MembershipTimeRelation(*list_it);
time_rel->set_end(end);
map_it->second.push_back(time_rel);
@@ -447,7 +563,7 @@
{
std::set<Event*> start;
start.insert(e);
- MembershipTimeRelationPtr time_rel = new MembershipTimeRelation((*list_it)->get_interval_set());
+ MembershipTimeRelationPtr time_rel = new MembershipTimeRelation(*list_it);
time_rel->set_start(start);
map_it->second.push_back(time_rel);
@@ -493,7 +609,7 @@
if(rel == NULL)
return ;
- MembershipTimeRelationPtr time_rel = new MembershipTimeRelation(rel->get_interval_set());
+ MembershipTimeRelationPtr time_rel = new MembershipTimeRelation(rel);
time_rel->set_start(event_set);
map_it = ref_node_time.find(rel);
Modified: trunk/src/membership/membership_time.cpp
===================================================================
--- trunk/src/membership/membership_time.cpp 2011-07-12 21:33:15 UTC (rev 1138)
+++ trunk/src/membership/membership_time.cpp 2011-07-13 08:31:27 UTC (rev 1139)
@@ -203,10 +203,10 @@
result = MscTimeIntervalSetD::set_intersection(hmsc_inter, bmsc_inter);
if(result.is_empty())
- return false;
+ c->add_not_covered_interval(map_it->first);
else
if(result != bmsc_inter)
- c->add_not_covered_interval(map_it->first);
+ c->add_not_full_covered_interval(map_it->first);
}
}
//----------------------------------------------------------------------------------------------
@@ -225,10 +225,10 @@
result = MscTimeIntervalSetD::set_intersection(hmsc_absolute, bmsc_inter);
if(result.is_empty())
- return false;
+ c->add_not_covered_interval(map_it->first);
else
if(result != bmsc_inter)
- c->add_not_covered_interval(map_it->first);
+ c->add_not_full_covered_interval(map_it->first);
}
}
@@ -250,12 +250,10 @@
result = MscTimeIntervalSetD::set_intersection(hmsc_inter, bmsc_inter);
if(result.is_empty())
- return false;
+ c->add_not_covered_interval((*relative_it)->get_original_rel());
else
if(result != bmsc_inter)
-//TODO
-std::cerr << "Error: some relative interval was not satisfied" << std::endl;
-// c->add_not_covered_interval(relative_it->first);
+ c->add_not_full_covered_interval((*relative_it)->get_original_rel());
}
return true;
@@ -434,10 +432,10 @@
result = MscTimeIntervalSetD::set_intersection(hmsc_inter, bmsc_inter);
if(result.is_empty())
- return false;
+ c->add_not_covered_interval(map_it->first);
else
if(result != bmsc_inter)
- c->add_not_covered_interval(map_it->first);
+ c->add_not_full_covered_interval(map_it->first);
}
}
@@ -457,10 +455,10 @@
result = MscTimeIntervalSetD::set_intersection(hmsc_absolute, bmsc_inter);
if(result.is_empty())
- return false;
+ c->add_not_covered_interval(map_it->first);
else
if(result != bmsc_inter)
- c->add_not_covered_interval(map_it->first);
+ c->add_not_full_covered_interval(map_it->first);
}
}
@@ -479,12 +477,10 @@
result = MscTimeIntervalSetD::set_intersection(hmsc_inter, bmsc_inter);
if(result.is_empty())
- return false;
+ c->add_not_covered_interval((*relative_it)->get_original_rel());
else
if(result != bmsc_inter)
-//TODO
-std::cerr << "Error: some relative interval was not satisfied" << std::endl;
-// c->add_not_covered_interval(relative_it->first);
+ c->add_not_full_covered_interval((*relative_it)->get_original_rel());
}
return true;
Modified: trunk/src/membership/membership_time.h
===================================================================
--- trunk/src/membership/membership_time.h 2011-07-12 21:33:15 UTC (rev 1138)
+++ trunk/src/membership/membership_time.h 2011-07-13 08:31:27 UTC (rev 1139)
@@ -19,6 +19,8 @@
#define __MEMBERSHIP_TIME__
#include "membership/membership_additional.h"
+#include "check/time/time_pseudocode.h"
+#include "check/time/tightening.h"
bool check_time_constraints(MembershipContext* c);
Modified: trunk/src/view/visio/addon/visualize.cpp
===================================================================
--- trunk/src/view/visio/addon/visualize.cpp 2011-07-12 21:33:15 UTC (rev 1138)
+++ trunk/src/view/visio/addon/visualize.cpp 2011-07-13 08:31:27 UTC (rev 1139)
@@ -443,6 +443,8 @@
case MARKED: CShapeUtils::MarkShape(result, SC_RED); break;
case ADDED: CShapeUtils::MarkShape(result, SC_GREEN); break;
case REMOVED: CShapeUtils::MarkShape(result, SC_RED); break;
+ case NOT_COVER: CShapeUtils::MarkShape(result, SC_RED); break;
+ case NOT_FULL_COVER: CShapeUtils::MarkShape(result, SC_BLUE); break;
default: throw std::runtime_error("Error: unexpected behaviour");
}
@@ -683,6 +685,7 @@
case MARKED: CShapeUtils::MarkShape(shape, SC_RED); break;
case ADDED: CShapeUtils::MarkShape(shape, SC_GREEN); break;
case REMOVED: CShapeUtils::MarkShape(shape, SC_RED); break;
+ case PATH: CShapeUtils::MarkShape(shape, SC_GREEN); break;
default: throw std::runtime_error("Error: unexpected behaviour");
}
@@ -777,6 +780,7 @@
case MARKED: CShapeUtils::MarkShape(connector, SC_RED); break;
case ADDED: CShapeUtils::MarkShape(connector, SC_GREEN); break;
case REMOVED: CShapeUtils::MarkShape(connector, SC_RED); break;
+ case PATH: CShapeUtils::MarkShape(connector, SC_GREEN); break;
default: throw std::runtime_error("Error: unexpected behaviour");
}
Modified: trunk/tests/membership/membership_test.cpp
===================================================================
--- trunk/tests/membership/membership_test.cpp 2011-07-12 21:33:15 UTC (rev 1138)
+++ trunk/tests/membership/membership_test.cpp 2011-07-13 08:31:27 UTC (rev 1139)
@@ -150,7 +150,18 @@
if(result.empty())
std::cerr << "Result messages are empty" << std::endl;
else
-std::cerr << "Result messages are NOT empty" << std::endl;
+{
+ std::map<std::wstring, std::vector<MscPtr> >::iterator map_it;
+
+ for(map_it = result.begin(); map_it != result.end(); map_it++)
+ {
+ std::wcerr << map_it->first << std::endl;
+ for(unsigned int i = 0; i < map_it->second.size(); i++)
+ {
+ z120.save_msc(std::cout, TOWSTRING(filename), map_it->second.at(i));
+ }
+ }
+}
return errors;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ma...@us...> - 2011-07-18 21:41:47
|
Revision: 1154
http://scstudio.svn.sourceforge.net/scstudio/?rev=1154&view=rev
Author: madzin
Date: 2011-07-18 21:41:35 +0000 (Mon, 18 Jul 2011)
Log Message:
-----------
Modify find flow output messages and methodology of testing (necessary to add .result files; it supposed to be done, when output messages in the correct form).
Modified Paths:
--------------
trunk/doc/help/membership/membership.html
trunk/src/data/searcher.h
trunk/src/membership/membership_alg.cpp
trunk/src/membership/membership_base.h
trunk/src/view/visio/addon/document.cpp
trunk/tests/CMakeLists.txt
trunk/tests/diff/diff_diff.py
trunk/tests/diff/diff_test.cpp
trunk/tests/membership/CMakeLists.txt
trunk/tests/membership/membership_test.cpp
Added Paths:
-----------
trunk/tests/membership/membership_diff.py
Modified: trunk/doc/help/membership/membership.html
===================================================================
--- trunk/doc/help/membership/membership.html 2011-07-18 19:31:17 UTC (rev 1153)
+++ trunk/doc/help/membership/membership.html 2011-07-18 21:41:35 UTC (rev 1154)
@@ -180,8 +180,8 @@
sequentialy composed (putting the BMSCs one after the other and gluing
the matching process lines). It is easy to see that the <i>BMSC flow</i>
is exactly the same BMSC represented by the path in the <i>HMSC specification</i>.
- The result of procedure solving the find flow problem should
- be every successful path i.e. <i>HMSC specification</i>.
+ <!--The result of procedure solving the find flow problem should
+ be every successful path i.e. <i>HMSC specification</i>. --!>
</p>
<p>
<h2>More formal specification of the procedure:</h2>
Modified: trunk/src/data/searcher.h
===================================================================
--- trunk/src/data/searcher.h 2011-07-18 19:31:17 UTC (rev 1153)
+++ trunk/src/data/searcher.h 2011-07-18 21:41:35 UTC (rev 1154)
@@ -41,8 +41,7 @@
virtual PreconditionList get_preconditions(MscPtr msc) const = 0;
//! Find the first occurence of needle in haystack.
-// virtual std::map<std::wstring, std::vector<MscPtr> > find(MscPtr haystack, MscPtr needle) = 0;
- virtual std::map<std::wstring, std::vector<MscPtr> > find(MscPtr msc, std::vector<MscPtr>& bmscs) = 0;
+ virtual std::vector<std::pair<std::wstring, std::vector<MscPtr> > > find(MscPtr msc, std::vector<MscPtr>& bmscs) = 0;
//! Make diff between specification and flow
// virtual MscPtr diff(MscPtr specification, std::vector<MscPtr>& flows) = 0;
Modified: trunk/src/membership/membership_alg.cpp
===================================================================
--- trunk/src/membership/membership_alg.cpp 2011-07-18 19:31:17 UTC (rev 1153)
+++ trunk/src/membership/membership_alg.cpp 2011-07-18 21:41:35 UTC (rev 1154)
@@ -42,7 +42,7 @@
* NULL value means that the specification cover will not be depicted.
*/
MscPtr MembershipAlg::find_flow(MscPtr msc, MscPtr bmsc, std::vector<std::wstring> instances,
- std::map<std::wstring, std::vector<MscPtr> >& messages)
+ std::vector<std::pair<std::wstring, std::vector<MscPtr> > >& messages)
{
HMscPtr hmsc = boost::dynamic_pointer_cast<HMsc > (msc);
BMscPtr bmsc_f = boost::dynamic_pointer_cast<BMsc > (bmsc);
@@ -67,7 +67,7 @@
if(result == NULL)
{
- print_report(RS_ERROR, L"The specification does not contain \"" + bmsc->get_label() + L"\" flow.");
+ print_report(RS_ERROR, L"Flow \"" + bmsc->get_label() + L"\" does not meet the specification.");
delete c;
return NULL;
}
@@ -75,13 +75,13 @@
{
if(c->get_result()->get_corupted_intervals_size().first != 0)
{
- std::wstring msg = L"Some intervals does not satisfy the time constraints. ";
- msg += L"For more information: ";
+ std::wstring msg = L"Flow \"" + bmsc->get_label() + L"\" does not satisfy time constraints of the specification. ";
+ msg += L"For more information (red intervals are not satisfied, blue intervals are partialy satisfied): ";
std::vector<MscPtr> result_vec;
result_vec.push_back(result);
- messages.insert(std::make_pair(msg, result_vec));
+ messages.push_back(std::make_pair(msg, result_vec));
delete c;
return NULL;
@@ -89,13 +89,13 @@
if(c->get_result()->get_corupted_intervals_size().second != 0)
{
- std::wstring msg = L"Some intervals could not satisfy the time constraints. ";
+ std::wstring msg = L"Flow \"" + bmsc->get_label() + L" does not satisfy time constraints of the specification. Some intervals are only partialy satisfied. ";
msg += L"For more information: ";
std::vector<MscPtr> result_vec;
result_vec.push_back(result);
- messages.insert(std::make_pair(msg, result_vec));
+ messages.push_back(std::make_pair(msg, result_vec));
delete c;
return NULL;
@@ -144,12 +144,12 @@
if(result != NULL)
{
std::wstring message;
- message = L"Msc \"" + bmsc_f->get_label() + L"\" does not meet the specification. Diff: ";
+ message = L"Flow \"" + bmsc_f->get_label() + L"\" does not meet the specification. Diff: ";
std::vector<MscPtr> diff_result;
diff_result.push_back(result);
- messages.insert(std::make_pair(message, diff_result));
+ messages.push_back(std::make_pair(message, diff_result));
}
delete c;
@@ -158,13 +158,13 @@
if(c->get_result()->get_corupted_intervals_size().first != 0)
{
- std::wstring msg = L"Some intervals does not satisfy the time constraints. ";
- msg += L"For more information: ";
+ std::wstring msg = L"Flow \"" + bmsc->get_label() + L"\" does not satisfy time constraints of the specification. ";
+ msg += L"For more information (red intervals are not satisfied, blue intervals are partialy satisfied): ";
std::vector<MscPtr> result_vec;
result_vec.push_back(result);
- messages.insert(std::make_pair(msg, result_vec));
+ messages.push_back(std::make_pair(msg, result_vec));
delete c;
return NULL;
@@ -172,13 +172,13 @@
if(c->get_result()->get_corupted_intervals_size().second != 0)
{
- std::wstring msg = L"Some intervals could not satisfy the time constraints. ";
+ std::wstring msg = L"Flow \"" + bmsc->get_label() + L" does not satisfy time constraints of the specification. Some intervals are only partialy satisfied. ";
msg += L"For more information: ";
std::vector<MscPtr> result_vec;
result_vec.push_back(result);
- messages.insert(std::make_pair(msg, result_vec));
+ messages.push_back(std::make_pair(msg, result_vec));
delete c;
return NULL;
@@ -191,16 +191,17 @@
}
}
- print_report(RS_ERROR, L"Find flow algorithm cannot recognize a MSC type of specification.");
+ print_report(RS_ERROR, L"Find flow algorithm cannot recognize an MSC type of specification.");
return NULL;
}
-std::map<std::wstring, std::vector<MscPtr> > MembershipAlg::find(MscPtr msc, std::vector<MscPtr>& bmscs,
- std::vector<std::wstring> instances)
+std::vector<std::pair<std::wstring, std::vector<MscPtr> > > MembershipAlg::find(MscPtr msc,
+ std::vector<MscPtr>& bmscs,
+ std::vector<std::wstring> instances)
{
MscPtr temp;
bool cover = false;
- std::map<std::wstring, std::vector<MscPtr> > messages;
+ std::vector<std::pair<std::wstring, std::vector<MscPtr> > > messages;
for(unsigned int i = 0; i < bmscs.size(); i++)
{
@@ -217,15 +218,15 @@
msc_cover.push_back(msc);
if(bmscs.size() > 1)
- messages.insert(std::make_pair(L"Flows coverage of the specification.", msc_cover));
+ messages.push_back(std::make_pair(L"Flows coverage of the specification.", msc_cover));
else
- messages.insert(std::make_pair(L"Flow coverage of the specification.", msc_cover));
+ messages.push_back(std::make_pair(L"Flow coverage of the specification.", msc_cover));
}
return messages;
}
-std::map<std::wstring, std::vector<MscPtr> > MembershipAlg::find(MscPtr msc, std::vector<MscPtr>& bmscs)
+std::vector<std::pair<std::wstring, std::vector<MscPtr> > > MembershipAlg::find(MscPtr msc, std::vector<MscPtr>& bmscs)
{
std::vector<std::wstring> instances;
return find(msc, bmscs, instances);
@@ -242,7 +243,7 @@
//TODO it is necessary to copy MSC because of path returning.
//dup_hmsc should be MSC graph. Due to that duplicatior throws exception during copying time intervals, membership workes just with MSC graphs.
dup_hmsc = hmsc;
-// dup_hmsc = dup_hmsc = duplicator.duplicate(hmsc);
+// dup_hmsc = duplicator.duplicate(hmsc);
c->set_hmsc(dup_hmsc);
Modified: trunk/src/membership/membership_base.h
===================================================================
--- trunk/src/membership/membership_base.h 2011-07-18 19:31:17 UTC (rev 1153)
+++ trunk/src/membership/membership_base.h 2011-07-18 21:41:35 UTC (rev 1154)
@@ -235,7 +235,7 @@
enum DiffType diff_type;
- std::map<std::wstring, std::vector<MscPtr> > result_messages;
+ std::vector<std::pair<std::wstring, std::vector<MscPtr> > > result_messages;
// bool search_bmsc;
public:
@@ -709,7 +709,7 @@
diff_type = type;
}
- void set_result_messages(std::map<std::wstring, std::vector<MscPtr> >& messages)
+ void set_result_messages(std::vector<std::pair<std::wstring, std::vector<MscPtr> > >& messages)
{
result_messages = messages;
}
@@ -721,7 +721,7 @@
*/
void add_result_message(std::wstring message, std::vector<MscPtr> results)
{
- result_messages.insert(std::make_pair(message, results));
+ result_messages.push_back(std::make_pair(message, results));
}
/*
void set_search_bmsc()
@@ -1211,7 +1211,8 @@
{
private:
MscPtr find_flow(MscPtr msc, MscPtr bmsc, std::vector<std::wstring> instances,
- std::map<std::wstring, std::vector<MscPtr> >& messages);
+ std::vector<std::pair<std::wstring, std::vector<MscPtr> > >& messages);
+ //! Make diff between specification and flow
MscPtr diff(MscPtr specification, std::vector<MscPtr>& flows);
public:
@@ -1236,17 +1237,11 @@
//! Returns a list of preconditions for this search.
virtual PreconditionList get_preconditions(MscPtr msc) const;
- //! Finds the bmsc flow in hmsc specification
-// virtual MscPtr find(MscPtr hmsc, MscPtr bmsc);
-
- //! Make diff between specification and flow
//! Finds each bmsc flow from the vector in hmsc specification
- virtual std::map<std::wstring, std::vector<MscPtr> > find(MscPtr hmsc, std::vector<MscPtr>& bmscs);
+ virtual std::vector<std::pair<std::wstring, std::vector<MscPtr> > > find(MscPtr hmsc, std::vector<MscPtr>& bmscs);
- //! Finds the bmsc flow in hmsc specification, focusing on specified instances, DO NOT CHECKING TIME CONSTRAINTS
-// virtual std::map<std::wstring, std::vector<MscPtr> > find(MscPtr hmsc, MscPtr bmsc, std::vector<std::wstring> instances);
- virtual std::map<std::wstring, std::vector<MscPtr> > find(MscPtr msc, std::vector<MscPtr>& bmscs, std::vector<std::wstring> instances);
+ virtual std::vector<std::pair<std::wstring, std::vector<MscPtr> > > find(MscPtr msc, std::vector<MscPtr>& bmscs, std::vector<std::wstring> instances);
MscPtr get_dp_msc(MscPtr msc);
Modified: trunk/src/view/visio/addon/document.cpp
===================================================================
--- trunk/src/view/visio/addon/document.cpp 2011-07-18 19:31:17 UTC (rev 1153)
+++ trunk/src/view/visio/addon/document.cpp 2011-07-18 21:41:35 UTC (rev 1154)
@@ -1132,8 +1132,8 @@
if (msc_haystack == NULL || msc_needles.empty())
return VAORC_FAILURE;
- std::map<std::wstring, std::vector<MscPtr> > result_messages;
- std::map<std::wstring, std::vector<MscPtr> >::iterator result_it;
+ std::vector<std::pair<std::wstring, std::vector<MscPtr> > > result_messages;
+ std::vector<std::pair<std::wstring, std::vector<MscPtr> > >::iterator result_it;
try
{
Modified: trunk/tests/CMakeLists.txt
===================================================================
--- trunk/tests/CMakeLists.txt 2011-07-18 19:31:17 UTC (rev 1153)
+++ trunk/tests/CMakeLists.txt 2011-07-18 21:41:35 UTC (rev 1154)
@@ -112,6 +112,19 @@
ADD_SUBDIRECTORY(z120_test)
+SET(MEMBER_SEQUENCE 0)
+MACRO(ADD_MEMBER_TEST FILE1 FILE2 SATISFIED)
+ GET_TARGET_PROPERTY(MEMBER_TEST_EXECUTABLE membership_test LOCATION)
+ # Replace the "$(IntDir)", "$(OutDir)", or "$(CONFIGURATION)"
+ # depending on the generator being used with the test-time variable.
+ STRING(REGEX REPLACE "\\$\\(.*\\)" "\${CTEST_CONFIGURATION_TYPE}"
+ MEMBER_TEST_EXECUTABLE "${MEMBER_TEST_EXECUTABLE}")
+
+ ADD_TEST("membership_test-${MEMBER_SEQUENCE}-${FILE2}"
+ ${PYTHON_EXECUTABLE} "${CMAKE_SOURCE_DIR}/tests/membership/membership_diff.py" "${MEMBER_TEST_EXECUTABLE}" "${CMAKE_CURRENT_SOURCE_DIR}/${FILE1}" "${CMAKE_CURRENT_SOURCE_DIR}/${FILE2}" ${SATISFIED})
+ MATH(EXPR MEMBER_SEQUENCE ${MEMBER_SEQUENCE}+1)
+ENDMACRO(ADD_MEMBER_TEST)
+
ADD_SUBDIRECTORY(membership)
SET(DIFF_SEQUENCE 0)
Modified: trunk/tests/diff/diff_diff.py
===================================================================
--- trunk/tests/diff/diff_diff.py 2011-07-18 19:31:17 UTC (rev 1153)
+++ trunk/tests/diff/diff_diff.py 2011-07-18 21:41:35 UTC (rev 1154)
@@ -11,48 +11,43 @@
# note: ctest expects the valgring errors at stderr
sys.stderr.writelines(output)
-if int(sys.argv[4]) == 0:
+result_files = glob.glob(sys.argv[3] + ".result*")
+# if no result file, return the error code
+if len(result_files) == 0:
exit = p.wait()
- sys.exit(exit)
+ sys.exit(1)
-else:
- result_files = glob.glob(sys.argv[3] + ".result*")
- # if no result file, return the error code
- if len(result_files) == 0:
- exit = p.wait()
- sys.exit(1)
+error_count = 0
+passed_count = 0
+for result_file in result_files:
+ try:
+ expected_output = open(result_file, "rt")
+ except IOError:
+ error_count = error_count+1
+ print "----------------------------------------------------------"
+ print "FAILED: cannot open", result_file
+ continue
- error_count = 0
- passed_count = 0
- for result_file in result_files:
- try:
- expected_output = open(result_file, "rt")
- except IOError:
+ result = difflib.unified_diff(expected_output.readlines(), output)
+ result_lines = 0
+ # print the differences between the real and the expected output
+ for line in result:
+ if result_lines == 0:
error_count = error_count+1
print "----------------------------------------------------------"
- print "FAILED: cannot open", result_file
- continue
+ print "FAILED: does not match", result_file
- result = difflib.unified_diff(expected_output.readlines(), output)
- result_lines = 0
- # print the differences between the real and the expected output
- for line in result:
- if result_lines == 0:
- error_count = error_count+1
- print "----------------------------------------------------------"
- print "FAILED: does not match", result_file
+ print line,
+ result_lines = result_lines + 1
- print line,
- result_lines = result_lines + 1
+ if result_lines == 0:
+ passed_count = passed_count + 1
+ print "----------------------------------------------------------"
+ print "PASSED: matches", result_file
- if result_lines == 0:
- passed_count = passed_count + 1
- print "----------------------------------------------------------"
- print "PASSED: matches", result_file
+if passed_count > 0:
+ sys.exit(0)
+else:
+ sys.exit(error_count)
- if passed_count > 0:
- sys.exit(0)
- else:
- sys.exit(error_count)
-
# $Id: z120_diff.py 627 2010-02-26 11:31:43Z gotthardp $
Modified: trunk/tests/diff/diff_test.cpp
===================================================================
--- trunk/tests/diff/diff_test.cpp 2011-07-18 19:31:17 UTC (rev 1153)
+++ trunk/tests/diff/diff_test.cpp 2011-07-18 21:41:35 UTC (rev 1154)
@@ -100,7 +100,7 @@
MembershipAlg mem;
mem.set_printer(&printer);
- std::map<std::wstring, std::vector<MscPtr> > result;
+ std::vector<std::pair<std::wstring, std::vector<MscPtr> > > result;
result = mem.find(msc[0], msc_b);
@@ -128,7 +128,7 @@
try
{
- std::map<std::wstring, std::vector<MscPtr> >::iterator result_it;
+ std::vector<std::pair<std::wstring, std::vector<MscPtr> > >::iterator result_it;
for(result_it = result.begin(); result_it != result.end(); result_it++)
{
for(unsigned int i = 0; i < result_it->second.size(); i++)
Modified: trunk/tests/membership/CMakeLists.txt
===================================================================
--- trunk/tests/membership/CMakeLists.txt 2011-07-18 19:31:17 UTC (rev 1153)
+++ trunk/tests/membership/CMakeLists.txt 2011-07-18 21:41:35 UTC (rev 1154)
@@ -1,3 +1,5 @@
+FIND_PACKAGE(PythonInterp REQUIRED)
+
ADD_EXECUTABLE(membership_test
membership_test.cpp
)
@@ -13,264 +15,168 @@
#ADD_MEMBERSHIP_TEST(test_hmsc01 test_bmsc01 1)
-GET_TARGET_PROPERTY(MEMBERSHIP_TEST_EXECUTABLE membership_test LOCATION)
+#GET_TARGET_PROPERTY(MEMBERSHIP_TEST_EXECUTABLE membership_test LOCATION)
# Replace the "$(IntDir)", "$(OutDir)", or "$(CONFIGURATION)"
# depending on the generator being used with the test-time variable.
-STRING(REGEX REPLACE "\\$\\(.*\\)" "\${CTEST_CONFIGURATION_TYPE}"
- MEMBERSHIP_TEST_EXECUTABLE "${MEMBERSHIP_TEST_EXECUTABLE}")
+#STRING(REGEX REPLACE "\\$\\(.*\\)" "\${CTEST_CONFIGURATION_TYPE}"
+# MEMBERSHIP_TEST_EXECUTABLE "")
-ADD_TEST(membership_test-01 ${MEMBERSHIP_TEST_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/test_hmsc01.mpr ${CMAKE_CURRENT_SOURCE_DIR}/test_bmsc01.mpr 1)
+ADD_MEMBER_TEST(test_hmsc01.mpr test_bmsc01.mpr 1)
+ADD_MEMBER_TEST(test_hmsc01.mpr test_bmsc01.mpr 1)
+ADD_MEMBER_TEST(test_hmsc02.mpr test_bmsc02.mpr 0)
+ADD_MEMBER_TEST(test_hmsc03.mpr test_bmsc03.mpr 1)
+ADD_MEMBER_TEST(test_hmsc04.mpr test_bmsc04.mpr 0)
+ADD_MEMBER_TEST(test_hmsc05.mpr test_bmsc05.mpr 1)
-ADD_TEST(membership_test-02 ${MEMBERSHIP_TEST_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/test_hmsc02.mpr ${CMAKE_CURRENT_SOURCE_DIR}/test_bmsc02.mpr 0)
+ADD_MEMBER_TEST(test_hmsc06.mpr test_bmsc06.mpr 0)
-ADD_TEST(membership_test-03 ${MEMBERSHIP_TEST_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/test_hmsc03.mpr ${CMAKE_CURRENT_SOURCE_DIR}/test_bmsc03.mpr 1)
-
-ADD_TEST(membership_test-04 ${MEMBERSHIP_TEST_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/test_hmsc04.mpr ${CMAKE_CURRENT_SOURCE_DIR}/test_bmsc04.mpr 0)
-
-ADD_TEST(membership_test-05 ${MEMBERSHIP_TEST_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/test_hmsc05.mpr ${CMAKE_CURRENT_SOURCE_DIR}/test_bmsc05.mpr 1)
-
-ADD_TEST(membership_test-06 ${MEMBERSHIP_TEST_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/test_hmsc06.mpr ${CMAKE_CURRENT_SOURCE_DIR}/test_bmsc06.mpr 0)
-
#coregion tests
-ADD_TEST(membership_test-08 ${MEMBERSHIP_TEST_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/test_hmsc08.mpr ${CMAKE_CURRENT_SOURCE_DIR}/test_bmsc08.mpr 1)
+ADD_MEMBER_TEST(test_hmsc08.mpr test_bmsc08.mpr 1)
+ADD_MEMBER_TEST(test_hmsc09.mpr test_bmsc09.mpr 1)
+ADD_MEMBER_TEST(test_hmsc10.mpr test_bmsc10.mpr 1)
+ADD_MEMBER_TEST(test_hmsc11.mpr test_bmsc11_1.mpr 1)
+ADD_MEMBER_TEST(test_hmsc11.mpr test_bmsc11_2.mpr 0)
+ADD_MEMBER_TEST(test_hmsc11.mpr test_bmsc11_3.mpr 0)
+ADD_MEMBER_TEST(test_hmsc11.mpr test_bmsc11_4.mpr 0)
+ADD_MEMBER_TEST(test_hmsc12.mpr test_bmsc12_1.mpr 1)
+ADD_MEMBER_TEST(test_hmsc12.mpr test_bmsc12_2.mpr 1)
+ADD_MEMBER_TEST(test_hmsc12.mpr test_bmsc12_3.mpr 0)
+ADD_MEMBER_TEST(test_hmsc12.mpr test_bmsc12_4.mpr 0)
+ADD_MEMBER_TEST(test_hmsc12.mpr test_bmsc12_5.mpr 0)
+ADD_MEMBER_TEST(test_hmsc13.mpr test_bmsc13_1.mpr 1)
+ADD_MEMBER_TEST(test_hmsc13.mpr test_bmsc13_2.mpr 1)
+ADD_MEMBER_TEST(test_hmsc13.mpr test_bmsc13_3.mpr 0)
+ADD_MEMBER_TEST(test_hmsc14.mpr test_bmsc14_1.mpr 1)
+ADD_MEMBER_TEST(test_hmsc14.mpr test_bmsc14_2.mpr 0)
+ADD_MEMBER_TEST(test_hmsc14.mpr test_bmsc14_3.mpr 0)
+ADD_MEMBER_TEST(test_hmsc14.mpr test_bmsc14_4.mpr 0)
+ADD_MEMBER_TEST(test_hmsc15.mpr test_bmsc15_1.mpr 1)
+ADD_MEMBER_TEST(test_hmsc15.mpr test_bmsc15_2.mpr 0)
+ADD_MEMBER_TEST(test_hmsc16.mpr test_bmsc16_1.mpr 1)
+ADD_MEMBER_TEST(test_hmsc16.mpr test_bmsc16_2.mpr 1)
+ADD_MEMBER_TEST(test_hmsc16.mpr test_bmsc16_3.mpr 0)
+ADD_MEMBER_TEST(test_hmsc11.mpr test_bmsc11_5.mpr 1)
+ADD_MEMBER_TEST(test_hmsc17.mpr test_bmsc17_1.mpr 1)
+ADD_MEMBER_TEST(test_hmsc17.mpr test_bmsc17_2.mpr 0)
+ADD_MEMBER_TEST(test_hmsc18.mpr test_bmsc18_1.mpr 1)
+ADD_MEMBER_TEST(test_hmsc18.mpr test_bmsc18_2.mpr 0)
+ADD_MEMBER_TEST(test_hmsc18.mpr test_bmsc18_3.mpr 0)
-ADD_TEST(membership_test-09 ${MEMBERSHIP_TEST_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/test_hmsc09.mpr ${CMAKE_CURRENT_SOURCE_DIR}/test_bmsc09.mpr 1)
-
-ADD_TEST(membership_test-10 ${MEMBERSHIP_TEST_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/test_hmsc10.mpr ${CMAKE_CURRENT_SOURCE_DIR}/test_bmsc10.mpr 1)
-
-ADD_TEST(membership_test-11 ${MEMBERSHIP_TEST_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/test_hmsc11.mpr ${CMAKE_CURRENT_SOURCE_DIR}/test_bmsc11_1.mpr 1)
-
-ADD_TEST(membership_test-12 ${MEMBERSHIP_TEST_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/test_hmsc11.mpr ${CMAKE_CURRENT_SOURCE_DIR}/test_bmsc11_2.mpr 0)
-
-ADD_TEST(membership_test-13 ${MEMBERSHIP_TEST_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/test_hmsc11.mpr ${CMAKE_CURRENT_SOURCE_DIR}/test_bmsc11_3.mpr 0)
-
-ADD_TEST(membership_test-14 ${MEMBERSHIP_TEST_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/test_hmsc11.mpr ${CMAKE_CURRENT_SOURCE_DIR}/test_bmsc11_4.mpr 0)
-
-ADD_TEST(membership_test-15 ${MEMBERSHIP_TEST_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/test_hmsc12.mpr ${CMAKE_CURRENT_SOURCE_DIR}/test_bmsc12_1.mpr 1)
-
-ADD_TEST(membership_test-16 ${MEMBERSHIP_TEST_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/test_hmsc12.mpr ${CMAKE_CURRENT_SOURCE_DIR}/test_bmsc12_2.mpr 1)
-
-ADD_TEST(membership_test-17 ${MEMBERSHIP_TEST_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/test_hmsc12.mpr ${CMAKE_CURRENT_SOURCE_DIR}/test_bmsc12_3.mpr 0)
-
-ADD_TEST(membership_test-18 ${MEMBERSHIP_TEST_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/test_hmsc12.mpr ${CMAKE_CURRENT_SOURCE_DIR}/test_bmsc12_4.mpr 0)
-
-ADD_TEST(membership_test-19 ${MEMBERSHIP_TEST_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/test_hmsc12.mpr ${CMAKE_CURRENT_SOURCE_DIR}/test_bmsc12_5.mpr 0)
-
-ADD_TEST(membership_test-20 ${MEMBERSHIP_TEST_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/test_hmsc13.mpr ${CMAKE_CURRENT_SOURCE_DIR}/test_bmsc13_1.mpr 1)
-
-ADD_TEST(membership_test-21 ${MEMBERSHIP_TEST_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/test_hmsc13.mpr ${CMAKE_CURRENT_SOURCE_DIR}/test_bmsc13_2.mpr 1)
-
-ADD_TEST(membership_test-22 ${MEMBERSHIP_TEST_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/test_hmsc13.mpr ${CMAKE_CURRENT_SOURCE_DIR}/test_bmsc13_3.mpr 0)
-
-ADD_TEST(membership_test-23 ${MEMBERSHIP_TEST_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/test_hmsc14.mpr ${CMAKE_CURRENT_SOURCE_DIR}/test_bmsc14_1.mpr 1)
-
-ADD_TEST(membership_test-24 ${MEMBERSHIP_TEST_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/test_hmsc14.mpr ${CMAKE_CURRENT_SOURCE_DIR}/test_bmsc14_2.mpr 0)
-
-ADD_TEST(membership_test-25 ${MEMBERSHIP_TEST_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/test_hmsc14.mpr ${CMAKE_CURRENT_SOURCE_DIR}/test_bmsc14_3.mpr 0)
-
-ADD_TEST(membership_test-26 ${MEMBERSHIP_TEST_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/test_hmsc14.mpr ${CMAKE_CURRENT_SOURCE_DIR}/test_bmsc14_4.mpr 0)
-
-ADD_TEST(membership_test-27 ${MEMBERSHIP_TEST_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/test_hmsc15.mpr ${CMAKE_CURRENT_SOURCE_DIR}/test_bmsc15_1.mpr 1)
-
-ADD_TEST(membership_test-28 ${MEMBERSHIP_TEST_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/test_hmsc15.mpr ${CMAKE_CURRENT_SOURCE_DIR}/test_bmsc15_2.mpr 0)
-
-ADD_TEST(membership_test-29 ${MEMBERSHIP_TEST_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/test_hmsc16.mpr ${CMAKE_CURRENT_SOURCE_DIR}/test_bmsc16_1.mpr 1)
-
-ADD_TEST(membership_test-30 ${MEMBERSHIP_TEST_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/test_hmsc16.mpr ${CMAKE_CURRENT_SOURCE_DIR}/test_bmsc16_2.mpr 1)
-
-ADD_TEST(membership_test-31 ${MEMBERSHIP_TEST_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/test_hmsc16.mpr ${CMAKE_CURRENT_SOURCE_DIR}/test_bmsc16_3.mpr 0)
-
-ADD_TEST(membership_test-32 ${MEMBERSHIP_TEST_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/test_hmsc11.mpr ${CMAKE_CURRENT_SOURCE_DIR}/test_bmsc11_5.mpr 1)
-
-ADD_TEST(membership_test-33 ${MEMBERSHIP_TEST_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/test_hmsc17.mpr ${CMAKE_CURRENT_SOURCE_DIR}/test_bmsc17_1.mpr 1)
-
-ADD_TEST(membership_test-34 ${MEMBERSHIP_TEST_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/test_hmsc17.mpr ${CMAKE_CURRENT_SOURCE_DIR}/test_bmsc17_2.mpr 0)
-
-ADD_TEST(membership_test-35 ${MEMBERSHIP_TEST_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/test_hmsc18.mpr ${CMAKE_CURRENT_SOURCE_DIR}/test_bmsc18_1.mpr 1)
-
-ADD_TEST(membership_test-36 ${MEMBERSHIP_TEST_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/test_hmsc18.mpr ${CMAKE_CURRENT_SOURCE_DIR}/test_bmsc18_2.mpr 0)
-
-ADD_TEST(membership_test-37 ${MEMBERSHIP_TEST_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/test_hmsc18.mpr ${CMAKE_CURRENT_SOURCE_DIR}/test_bmsc18_3.mpr 0)
-
#due to duplicator, membership works only over MSC graph
-#ADD_TEST(membership_test-38 ${MEMBERSHIP_TEST_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/test_hmsc19.mpr ${CMAKE_CURRENT_SOURCE_DIR}/test_bmsc19.mpr 1)
-ADD_TEST(membership_test-38 ${MEMBERSHIP_TEST_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/test_hmsc19.mpr ${CMAKE_CURRENT_SOURCE_DIR}/test_bmsc19.mpr 0)
+#ADD_MEMBER_TEST(test_hmsc19.mpr test_bmsc19.mpr 1)
+ADD_MEMBER_TEST(test_hmsc19.mpr test_bmsc19.mpr 0)
#test bMSC x bMSC
-ADD_TEST(membership_test-39 ${MEMBERSHIP_TEST_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/test_bmsc19.mpr ${CMAKE_CURRENT_SOURCE_DIR}/test_bmsc19.mpr 1)
+ADD_MEMBER_TEST(test_bmsc19.mpr test_bmsc19.mpr 1)
+ADD_MEMBER_TEST(test_bmsc12_1.mpr test_bmsc12_1.mpr 1)
+ADD_MEMBER_TEST(test_bmsc13_1.mpr test_bmsc13_1.mpr 1)
+ADD_MEMBER_TEST(test_bmsc15_1.mpr test_bmsc15_1.mpr 1)
-ADD_TEST(membership_test-40 ${MEMBERSHIP_TEST_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/test_bmsc12_1.mpr ${CMAKE_CURRENT_SOURCE_DIR}/test_bmsc12_1.mpr 1)
-
-ADD_TEST(membership_test-41 ${MEMBERSHIP_TEST_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/test_bmsc13_1.mpr ${CMAKE_CURRENT_SOURCE_DIR}/test_bmsc13_1.mpr 1)
-
-ADD_TEST(membership_test-42 ${MEMBERSHIP_TEST_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/test_bmsc15_1.mpr ${CMAKE_CURRENT_SOURCE_DIR}/test_bmsc15_1.mpr 1)
-
#rozcvicka
-ADD_TEST(membership_test-43 ${MEMBERSHIP_TEST_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/rozcvicka_hmsc.mpr ${CMAKE_CURRENT_SOURCE_DIR}/rozcvicka_bmsc.mpr 1)
+ADD_MEMBER_TEST(rozcvicka_hmsc.mpr rozcvicka_bmsc.mpr 1)
+ADD_MEMBER_TEST(rozcvicka_long.mpr rozcvicka_bmsc.mpr 1)
-ADD_TEST(membership_test-44 ${MEMBERSHIP_TEST_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/rozcvicka_long.mpr ${CMAKE_CURRENT_SOURCE_DIR}/rozcvicka_bmsc.mpr 1)
-
#test coregion ordering skontrolovat
-ADD_TEST(membership_test-45 ${MEMBERSHIP_TEST_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/test_hmsc20.mpr ${CMAKE_CURRENT_SOURCE_DIR}/test_bmsc20_1.mpr 1)
+ADD_MEMBER_TEST(test_hmsc20.mpr test_bmsc20_1.mpr 1)
+ADD_MEMBER_TEST(test_hmsc20.mpr test_bmsc20_2.mpr 0)
-ADD_TEST(membership_test-46 ${MEMBERSHIP_TEST_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/test_hmsc20.mpr ${CMAKE_CURRENT_SOURCE_DIR}/test_bmsc20_2.mpr 0)
-
#incomplete messages
-ADD_TEST(membership_test-47 ${MEMBERSHIP_TEST_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/test_hmsc21.mpr ${CMAKE_CURRENT_SOURCE_DIR}/test_bmsc21_1.mpr 1)
+ADD_MEMBER_TEST(test_hmsc21.mpr test_bmsc21_1.mpr 1)
+ADD_MEMBER_TEST(test_hmsc21.mpr test_bmsc21_2.mpr 1)
+ADD_MEMBER_TEST(test_hmsc21.mpr test_bmsc21_3.mpr 0)
+ADD_MEMBER_TEST(test_hmsc21.mpr test_bmsc21_4.mpr 0)
+ADD_MEMBER_TEST(test_hmsc22.mpr test_bmsc22_1.mpr 1)
+ADD_MEMBER_TEST(test_hmsc22.mpr test_bmsc22_2.mpr 1)
+ADD_MEMBER_TEST(test_hmsc22.mpr test_bmsc22_3.mpr 1)
+ADD_MEMBER_TEST(test_hmsc22.mpr test_bmsc22_4.mpr 1)
+ADD_MEMBER_TEST(test_hmsc23.mpr test_bmsc23_1.mpr 1)
+ADD_MEMBER_TEST(test_hmsc23.mpr test_bmsc23_2.mpr 1)
+ADD_MEMBER_TEST(test_hmsc23.mpr test_bmsc23_3.mpr 1)
+ADD_MEMBER_TEST(test_hmsc23.mpr test_bmsc23_4.mpr 1)
-ADD_TEST(membership_test-48 ${MEMBERSHIP_TEST_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/test_hmsc21.mpr ${CMAKE_CURRENT_SOURCE_DIR}/test_bmsc21_2.mpr 1)
-
-ADD_TEST(membership_test-49 ${MEMBERSHIP_TEST_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/test_hmsc21.mpr ${CMAKE_CURRENT_SOURCE_DIR}/test_bmsc21_3.mpr 0)
-
-ADD_TEST(membership_test-50 ${MEMBERSHIP_TEST_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/test_hmsc21.mpr ${CMAKE_CURRENT_SOURCE_DIR}/test_bmsc21_4.mpr 0)
-
-ADD_TEST(membership_test-51 ${MEMBERSHIP_TEST_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/test_hmsc22.mpr ${CMAKE_CURRENT_SOURCE_DIR}/test_bmsc22_1.mpr 1)
-
-ADD_TEST(membership_test-52 ${MEMBERSHIP_TEST_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/test_hmsc22.mpr ${CMAKE_CURRENT_SOURCE_DIR}/test_bmsc22_2.mpr 1)
-
-ADD_TEST(membership_test-53 ${MEMBERSHIP_TEST_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/test_hmsc22.mpr ${CMAKE_CURRENT_SOURCE_DIR}/test_bmsc22_3.mpr 1)
-
-ADD_TEST(membership_test-54 ${MEMBERSHIP_TEST_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/test_hmsc22.mpr ${CMAKE_CURRENT_SOURCE_DIR}/test_bmsc22_4.mpr 1)
-
-ADD_TEST(membership_test-55 ${MEMBERSHIP_TEST_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/test_hmsc23.mpr ${CMAKE_CURRENT_SOURCE_DIR}/test_bmsc23_1.mpr 1)
-
-ADD_TEST(membership_test-56 ${MEMBERSHIP_TEST_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/test_hmsc23.mpr ${CMAKE_CURRENT_SOURCE_DIR}/test_bmsc23_2.mpr 1)
-
-ADD_TEST(membership_test-57 ${MEMBERSHIP_TEST_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/test_hmsc23.mpr ${CMAKE_CURRENT_SOURCE_DIR}/test_bmsc23_3.mpr 1)
-
-ADD_TEST(membership_test-58 ${MEMBERSHIP_TEST_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/test_hmsc23.mpr ${CMAKE_CURRENT_SOURCE_DIR}/test_bmsc23_4.mpr 1)
-
#empty MSC
-ADD_...
[truncated message content] |
|
From: <ma...@us...> - 2011-07-19 09:17:47
|
Revision: 1156
http://scstudio.svn.sourceforge.net/scstudio/?rev=1156&view=rev
Author: madzin
Date: 2011-07-19 09:17:41 +0000 (Tue, 19 Jul 2011)
Log Message:
-----------
Modify Find Flow output messages. Add new tests
Modified Paths:
--------------
trunk/src/membership/membership_alg.cpp
trunk/src/view/visio/addon/document.cpp
trunk/tests/membership/flow10_neg.vsd
trunk/tests/membership/flow12_neg.vsd
trunk/tests/membership/flow14_pos.vsd
trunk/tests/membership/flow15_pos.vsd
trunk/tests/membership/flow19_pos.vsd
trunk/tests/membership/flow20_pos.vsd
trunk/tests/membership/spec11.vsd
Added Paths:
-----------
trunk/tests/membership/flow21_neg.vsd
trunk/tests/membership/flow22_neg.vsd
trunk/tests/membership/spec12.vsd
Modified: trunk/src/membership/membership_alg.cpp
===================================================================
--- trunk/src/membership/membership_alg.cpp 2011-07-18 21:59:19 UTC (rev 1155)
+++ trunk/src/membership/membership_alg.cpp 2011-07-19 09:17:41 UTC (rev 1156)
@@ -101,8 +101,11 @@
return NULL;
}
- print_report(RS_NOTICE, L"Flow \"" + bmsc->get_label() + L"\" meets the specification.");
+ std::wstring msg = L"Flow \"" + bmsc->get_label() + L"\" meets the specification.";
+ std::vector<MscPtr> result_vec;
+ messages.push_back(std::make_pair(msg, result_vec));
+
delete c;
return result;
}
@@ -130,7 +133,7 @@
instances_name += instances[i];
}
- print_report(RS_ERROR, L"Flow \"" + bmsc->get_label() + L"\" does not meet the specification on instances:" + instances_name);
+ print_report(RS_ERROR, L"Flow \"" + bmsc_f->get_label() + L"\" does not meet the specification on instances:" + instances_name);
delete c;
return NULL;
@@ -158,7 +161,7 @@
if(c->get_result()->get_corupted_intervals_size().first != 0)
{
- std::wstring msg = L"Flow \"" + bmsc->get_label() + L"\" does not satisfy time constraints of the specification. ";
+ std::wstring msg = L"Flow \"" + bmsc_f->get_label() + L"\" does not satisfy time constraints of the specification. ";
msg += L"For more information (red intervals are not satisfied, blue intervals are partialy satisfied): ";
std::vector<MscPtr> result_vec;
@@ -172,7 +175,7 @@
if(c->get_result()->get_corupted_intervals_size().second != 0)
{
- std::wstring msg = L"Flow \"" + bmsc->get_label() + L" does not satisfy time constraints of the specification. Some intervals are only partialy satisfied. ";
+ std::wstring msg = L"Flow \"" + bmsc_f->get_label() + L" does not satisfy time constraints of the specification. Some intervals are only partialy satisfied. ";
msg += L"For more information: ";
std::vector<MscPtr> result_vec;
@@ -184,7 +187,7 @@
return NULL;
}
- print_report(RS_NOTICE, L"Flow \"" + bmsc->get_label() + L"\" meets the specification.");
+ print_report(RS_NOTICE, L"Flow \"" + bmsc_f->get_label() + L"\" meets the specification.");
delete c;
return NULL;
@@ -202,20 +205,50 @@
MscPtr temp;
bool cover = false;
std::vector<std::pair<std::wstring, std::vector<MscPtr> > > messages;
+ HMscPtr hmsc = boost::dynamic_pointer_cast<HMsc>(msc);
+ BMscPtr bmsc = boost::dynamic_pointer_cast<BMsc>(msc);
+ BMscGraphDuplicator hmsc_duplicator;
+ BMscDuplicator bmsc_duplicator;
+ MscPtr dup_msc = NULL;
+ std::vector<MscPtr> msc_for_cover;
+
for(unsigned int i = 0; i < bmscs.size(); i++)
{
temp = NULL;
- temp = find_flow(msc, bmscs[i], instances, messages);
+ dup_msc = NULL;
+ if(hmsc == NULL && bmsc != NULL)
+ dup_msc = bmsc_duplicator.duplicate(bmsc);
+
+ if(hmsc != NULL && bmsc == NULL)
+ dup_msc = hmsc_duplicator.duplicate(hmsc);
+
+ if(dup_msc == NULL)
+ throw std::runtime_error("Error: unexpected behaviour.");
+
+ temp = find_flow(dup_msc, bmscs[i], instances, messages);
+
if(temp != NULL)
+ {
+ msc_for_cover.push_back(bmscs[i]);
cover = true;
+ }
}
if(cover)
{
+ std::vector<std::pair<std::wstring, std::vector<MscPtr> > > msg;
+
+ dup_msc = hmsc_duplicator.duplicate(hmsc);
+
+ for(unsigned int i = 0; i < msc_for_cover.size(); i++)
+ {
+ find_flow(dup_msc, msc_for_cover[i], instances, msg);
+ }
+
std::vector<MscPtr> msc_cover;
- msc_cover.push_back(msc);
+ msc_cover.push_back(dup_msc);
if(bmscs.size() > 1)
messages.push_back(std::make_pair(L"Flows coverage of the specification.", msc_cover));
@@ -243,7 +276,7 @@
//TODO it is necessary to copy MSC because of path returning.
//dup_hmsc should be MSC graph. Due to that duplicatior throws exception during copying time intervals, membership workes just with MSC graphs.
dup_hmsc = hmsc;
-// dup_hmsc = duplicator.duplicate(hmsc);
+ //dup_hmsc = duplicator.duplicate(hmsc);
c->set_hmsc(dup_hmsc);
@@ -1129,8 +1162,12 @@
//in case the node is reference,
//this increase the value of attribute membership_counter
//membership counter - store amount of node memberships (occurrences) in the flow
- if(dynamic_cast<ReferenceNode*>(node.get()) != NULL)
+ if(dynamic_cast<ReferenceNode*>(node.get()) != NULL &&
+ c->get_result()->get_corupted_intervals_size().first == 0 &&
+ c->get_result()->get_corupted_intervals_size().second == 0)
+ {
node->set_attribute("membership_counter" , node->get_attribute("membership_counter", 0)+1);
+ }
successor = dynamic_cast<SuccessorNode*>(node.get());
Modified: trunk/src/view/visio/addon/document.cpp
===================================================================
--- trunk/src/view/visio/addon/document.cpp 2011-07-18 21:59:19 UTC (rev 1155)
+++ trunk/src/view/visio/addon/document.cpp 2011-07-19 09:17:41 UTC (rev 1156)
@@ -1148,7 +1148,10 @@
for(result_it = result_messages.begin(); result_it != result_messages.end(); result_it++)
{
- m_reportView->Print(RS_NOTICE, result_it->first, result_it->second.front());
+ if(result_it->second.empty())
+ m_reportView->Print(RS_NOTICE, result_it->first);
+ else
+ m_reportView->Print(RS_NOTICE, result_it->first, result_it->second.front());
}
return VAORC_SUCCESS;
Modified: trunk/tests/membership/flow10_neg.vsd
===================================================================
(Binary files differ)
Modified: trunk/tests/membership/flow12_neg.vsd
===================================================================
(Binary files differ)
Modified: trunk/tests/membership/flow14_pos.vsd
===================================================================
(Binary files differ)
Modified: trunk/tests/membership/flow15_pos.vsd
===================================================================
(Binary files differ)
Modified: trunk/tests/membership/flow19_pos.vsd
===================================================================
(Binary files differ)
Modified: trunk/tests/membership/flow20_pos.vsd
===================================================================
(Binary files differ)
Added: trunk/tests/membership/flow21_neg.vsd
===================================================================
(Binary files differ)
Property changes on: trunk/tests/membership/flow21_neg.vsd
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: trunk/tests/membership/flow22_neg.vsd
===================================================================
(Binary files differ)
Property changes on: trunk/tests/membership/flow22_neg.vsd
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Modified: trunk/tests/membership/spec11.vsd
===================================================================
(Binary files differ)
Added: trunk/tests/membership/spec12.vsd
===================================================================
(Binary files differ)
Property changes on: trunk/tests/membership/spec12.vsd
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ma...@us...> - 2011-08-01 11:16:08
|
Revision: 1168
http://scstudio.svn.sourceforge.net/scstudio/?rev=1168&view=rev
Author: madzin
Date: 2011-08-01 11:16:01 +0000 (Mon, 01 Aug 2011)
Log Message:
-----------
Remove some memory leaks in parser (absolute time)
Modified Paths:
--------------
trunk/src/data/Z120/Context.cpp
trunk/src/data/msc.h
trunk/tests/membership/complete_absolute_pat2.mpr
trunk/tests/membership/membership_test.cpp
Modified: trunk/src/data/Z120/Context.cpp
===================================================================
--- trunk/src/data/Z120/Context.cpp 2011-07-31 23:55:32 UTC (rev 1167)
+++ trunk/src/data/Z120/Context.cpp 2011-08-01 11:16:01 UTC (rev 1168)
@@ -1042,8 +1042,11 @@
context->z->print_report(RS_ERROR, stringize() << L"Warning: wrong definition of absolut time");
}
- context->current_event->add_absolut_time(*(new MscTimeIntervalSet<double>(context->time)));
+ MscTimeIntervalSetD* abs_time = new MscTimeIntervalSet<double>(context->time);
+ context->current_event->add_absolut_time(*abs_time);
+ delete abs_time;
+
context->absolut_first_border = false;
context->absolut_second_border = false;
context->absolut_first_set = false;
Modified: trunk/src/data/msc.h
===================================================================
--- trunk/src/data/msc.h 2011-07-31 23:55:32 UTC (rev 1167)
+++ trunk/src/data/msc.h 2011-08-01 11:16:01 UTC (rev 1168)
@@ -1746,7 +1746,7 @@
// }
- void add_absolut_time(const MscTimeIntervalSetD& absolut_time)
+ void add_absolut_time(MscTimeIntervalSetD absolut_time)
{
m_absolut_time.push_back(absolut_time);
}
Modified: trunk/tests/membership/complete_absolute_pat2.mpr
===================================================================
--- trunk/tests/membership/complete_absolute_pat2.mpr 2011-07-31 23:55:32 UTC (rev 1167)
+++ trunk/tests/membership/complete_absolute_pat2.mpr 2011-08-01 11:16:01 UTC (rev 1168)
@@ -3,7 +3,7 @@
inst PC;
inst Router;
inst Server;
-text 'Specification: complete_absolute.vsd The flows absolute time constraint is not full covered (C ref. node). The flow does not meet time constraints of specification Output: message + intervals';
+text 'Specification: complete_absolute.vsd The flow absolute time constraint is not full covered (C ref. node). The flow does not meet time constraints of specification Output: message + intervals';
PC: instance;
out c,0 to Router;
time [@0];
Modified: trunk/tests/membership/membership_test.cpp
===================================================================
--- trunk/tests/membership/membership_test.cpp 2011-07-31 23:55:32 UTC (rev 1167)
+++ trunk/tests/membership/membership_test.cpp 2011-08-01 11:16:01 UTC (rev 1168)
@@ -100,8 +100,14 @@
MembershipAlg mem;
mem.set_printer(&printer);
+ if(msc_b.size() != 1 || msc_b[0] == NULL)
+ throw std::runtime_error("Error: Unexpected behaviour");
+
BMscPtr bmsc = boost::dynamic_pointer_cast<BMsc>(msc_b[0]);
+ if(bmsc == NULL)
+ throw std::runtime_error("Error: Flow typecasting failed");
+
std::vector<std::pair<std::wstring, std::vector<MscPtr> > > result;
std::vector<MscPtr> bmscs;
bmscs.push_back(bmsc);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ma...@us...> - 2011-08-08 18:32:45
|
Revision: 1176
http://scstudio.svn.sourceforge.net/scstudio/?rev=1176&view=rev
Author: madzin
Date: 2011-08-08 18:32:38 +0000 (Mon, 08 Aug 2011)
Log Message:
-----------
Modify absolute time in the msc.h structure. Create new class for absolute time and organize time constraints in class TimeConstraint. Modify algorithms to be able work with new structure. Fix some bugs in Find Flow algorithm and add some test results.
Modified Paths:
--------------
trunk/src/check/time/tightening.h
trunk/src/check/time/time_consistency.h
trunk/src/data/Z120/z120_save.cpp
trunk/src/data/msc.cpp
trunk/src/data/msc.h
trunk/src/membership/membership_alg.cpp
trunk/src/membership/membership_base.h
trunk/src/membership/membership_time.cpp
Added Paths:
-----------
trunk/tests/membership/bmsc_absolute_pat1_1.mpr.result
trunk/tests/membership/bmsc_absolute_pat1_2.mpr.result
trunk/tests/membership/bmsc_absolute_pat2_4.mpr.result
trunk/tests/membership/bmsc_absolute_pat2_5.mpr.result
Modified: trunk/src/check/time/tightening.h
===================================================================
--- trunk/src/check/time/tightening.h 2011-08-07 18:14:58 UTC (rev 1175)
+++ trunk/src/check/time/tightening.h 2011-08-08 18:32:38 UTC (rev 1176)
@@ -357,7 +357,10 @@
while(copy->get_original()->get_original()!=NULL)
{
- copy = copy->get_original();
+ copy = dynamic_cast<TimeRelation*>(copy->get_original());
+
+ if(copy == NULL)
+ throw std::runtime_error("Error: Internal Error, typecast from TimeConstraint to TimeRelation failed");
}
copy->get_interval_set() = MscTimeIntervalSetD::set_union(copy->get_interval_set(),result(b_matrix.get_number(it->second.first),
b_matrix.get_number(it->second.second)));
Modified: trunk/src/check/time/time_consistency.h
===================================================================
--- trunk/src/check/time/time_consistency.h 2011-08-07 18:14:58 UTC (rev 1175)
+++ trunk/src/check/time/time_consistency.h 2011-08-08 18:32:38 UTC (rev 1176)
@@ -673,7 +673,10 @@
TimeRelation* copy = *it;
while(copy->get_original()->get_original()!=NULL)
{
- copy = copy->get_original();
+ copy = dynamic_cast<TimeRelation*>(copy->get_original());
+
+ if(copy == NULL)
+ throw std::runtime_error("Error: Internal Error, typecast from TimeConstraint to TimeRelation failed");
}
duplicator.get_copy(copy)->set_marked();
}
Modified: trunk/src/data/Z120/z120_save.cpp
===================================================================
--- trunk/src/data/Z120/z120_save.cpp 2011-08-07 18:14:58 UTC (rev 1175)
+++ trunk/src/data/Z120/z120_save.cpp 2011-08-08 18:32:38 UTC (rev 1176)
@@ -386,9 +386,9 @@
}
}
-void print_absolut_time(std::ostream& stream, const MscTimeIntervalSetD& interval)
+void print_absolute_time(std::ostream& stream, AbsoluteTimePtr abs)
{
- const std::list< MscTimeInterval<double> > constraints = interval.get_set();
+ const std::list< MscTimeInterval<double> > constraints = abs->get_interval_set().get_set();
for(std::list< MscTimeInterval<double> >::const_iterator it = constraints.begin();
it != constraints.end(); it++)
@@ -418,9 +418,9 @@
size_t printed = 0;
const TimeRelationEventPtrList& relations = event->get_time_relations();
- const MscTimeIntervalSetDList& absolut_times = event->get_absolut_times();
+ const AbsoluteTimePtrList absolut_times = event->get_absolut_times();
// process all absolut time constraints
- for(MscTimeIntervalSetDList::const_iterator apos = absolut_times.begin();
+ for(AbsoluteTimePtrList::const_iterator apos = absolut_times.begin();
apos != absolut_times.end(); apos++)
{
if(!printed++)
@@ -428,8 +428,10 @@
else
stream << ", ";
+ print_element_attributes(stream, *apos);
+
//do not used the print function of MscTimeInterval due to [@3]
- print_absolut_time(stream, *apos);
+ print_absolute_time(stream, *apos);
}
// process all time relations
Modified: trunk/src/data/msc.cpp
===================================================================
--- trunk/src/data/msc.cpp 2011-08-07 18:14:58 UTC (rev 1175)
+++ trunk/src/data/msc.cpp 2011-08-08 18:32:38 UTC (rev 1176)
@@ -301,6 +301,49 @@
////////////////////////////////////
+Event::Event(Event* original) : MscElementTmpl<Event>(original), Commentable(),
+ m_position(original->m_position),
+ m_message()
+{
+ AbsoluteTimePtrList::iterator it;
+ for(it = original->m_absolut_time.begin(); it != original->m_absolut_time.end(); it++)
+ {
+ AbsoluteTimePtr abs = new AbsoluteTime(it->get());
+ m_absolut_time.push_back(abs);
+ }
+}
+
+void Event::add_absolut_time(MscTimeIntervalSetD absolut_time)
+{
+ AbsoluteTimePtr abs = new AbsoluteTime(absolut_time);
+ m_absolut_time.push_back(abs);
+}
+
+void Event::remove_absolut_time(const MscTimeIntervalSetD& absolute_time)
+{
+ std::list<AbsoluteTimePtr>::iterator pos;
+
+ for(pos = m_absolut_time.begin(); pos != m_absolut_time.end(); pos++)
+ {
+ if((*pos)->get_interval_set() == absolute_time)
+ break;
+ }
+
+ if(pos != m_absolut_time.end())
+ m_absolut_time.erase(pos);
+}
+
+void Event::set_absolut_time(const std::list<AbsoluteTimePtr>& list)
+{
+ m_absolut_time = list;
+}
+
+const AbsoluteTimePtrList& Event::get_absolut_times() const
+{
+ return m_absolut_time;
+}
+////////////////////////////////////
+
/*inline StrictOrderArea* StrictEvent::get_strict_order_area()
{
return dynamic_cast<StrictOrderArea*>(m_area);
@@ -511,28 +554,68 @@
/////////////////////////////////////////////////////////////////////////////
#ifdef _TIME_H_
+TimeConstraint::TimeConstraint():
+ MscElementTmpl<TimeConstraint>(),
+ m_interval_set(), m_width(0)
+{
+}
+
+TimeConstraint::TimeConstraint(const MscTimeIntervalSetD& set):
+ MscElementTmpl<TimeConstraint>(),
+ m_interval_set(set), m_width(0)
+{
+}
+
+TimeConstraint::TimeConstraint(TimeConstraint* original):
+ MscElementTmpl<TimeConstraint>(original)
+{
+ if(original)
+ {
+ m_interval_set = original->m_interval_set;
+ m_width = original->get_width();
+ }
+}
+
+TimeConstraint::~TimeConstraint()
+{
+}
+
+const MscTimeIntervalSetD& TimeConstraint::get_interval_set() const
+{
+ return m_interval_set;
+}
+
+MscTimeIntervalSetD& TimeConstraint::get_interval_set()
+{
+ return m_interval_set;
+}
+
+void TimeConstraint::set_interval_set(const MscTimeIntervalSetD& set)
+{
+ m_interval_set = set;
+}
+
+/////////////////////////////////////////////////////////////////////////////
+
TimeRelation::TimeRelation(const MscTimeIntervalSetD& set):
- MscElementTmpl<TimeRelation>(),
- m_directed(false), m_interval_set(set), m_measurement(), m_width(0)
+ TimeConstraint(set), m_directed(false), m_measurement()
{
}
TimeRelation::TimeRelation(const std::string& value):
- MscElementTmpl<TimeRelation>(),
- m_directed(false), m_interval_set(), m_measurement(), m_width(0)
+ TimeConstraint(),
+ m_directed(false), m_measurement()
{
assign_label(value);
}
TimeRelation::TimeRelation(TimeRelation* original):
- MscElementTmpl<TimeRelation>(original)
+ TimeConstraint(original)
{
if(original)
{
m_directed = original->is_directed();
- m_interval_set = original->m_interval_set;
m_measurement = original->m_measurement;
- m_width = original->get_width();
}
}
@@ -691,21 +774,6 @@
return text.str();
}
-const MscTimeIntervalSetD& TimeRelation::get_interval_set() const
-{
- return m_interval_set;
-}
-
-MscTimeIntervalSetD& TimeRelation::get_interval_set()
-{
- return m_interval_set;
-}
-
-void TimeRelation::set_interval_set(const MscTimeIntervalSetD& set)
-{
- m_interval_set = set;
-}
-
TimeRelationEvent::TimeRelationEvent(TimeRelationEvent *original):
TimeRelation(original), m_event_origin(NULL), m_event(NULL)
{
Modified: trunk/src/data/msc.h
===================================================================
--- trunk/src/data/msc.h 2011-08-07 18:14:58 UTC (rev 1175)
+++ trunk/src/data/msc.h 2011-08-08 18:32:38 UTC (rev 1176)
@@ -65,6 +65,8 @@
class SuccessorNode;
class PredecessorNode;
#ifdef _TIME_H_
+class TimeConstraint;
+class AbsoluteTime;
class TimeRelation;
class TimeRelationEvent;
class TimeRelationRefNode;
@@ -141,6 +143,10 @@
typedef MscTimeIntervalSet<double> MscTimeIntervalSetD;
typedef std::list<MscTimeIntervalSetD> MscTimeIntervalSetDList;
+typedef boost::intrusive_ptr<AbsoluteTime> AbsoluteTimePtr;
+typedef std::list<AbsoluteTimePtr> AbsoluteTimePtrList;
+typedef boost::intrusive_ptr<TimeConstraint> TimeConstraintPtr;
+typedef std::list<TimeConstraintPtr> TimeConstraintPtrList;
#endif
enum MarkType {NONE, MARKED, ADDED, REMOVED, NOT_COVER, NOT_FULL_COVER, PATH};
@@ -1659,7 +1665,7 @@
#ifdef _TIME_H_
TimeRelationEventPtrList m_time_relations;
- MscTimeIntervalSetDList m_absolut_time;
+ AbsoluteTimePtrList m_absolut_time;
#endif
Event() : MscElementTmpl<Event>(), Commentable(),
@@ -1671,11 +1677,7 @@
/**
* @param original - original Event of this Event
*/
- Event(Event* original) : MscElementTmpl<Event>(original), Commentable(),
- m_position(original->m_position),
- m_message()
- {
- }
+ Event(Event* original);
CompleteMessage* get_complete() const
{
@@ -1746,30 +1748,11 @@
// }
- void add_absolut_time(MscTimeIntervalSetD absolut_time)
- {
- m_absolut_time.push_back(absolut_time);
- }
+ void add_absolut_time(MscTimeIntervalSetD absolut_time);
+ void remove_absolut_time(const MscTimeIntervalSetD& absolute_time);
+ void set_absolut_time(const std::list<AbsoluteTimePtr>& list);
+ const AbsoluteTimePtrList& get_absolut_times() const;
- void remove_absolut_time(const MscTimeIntervalSetD& absolut_time)
- {
- MscTimeIntervalSetDList::iterator pos =
- std::find(m_absolut_time.begin(), m_absolut_time.end(), absolut_time);
-
- if(pos != m_absolut_time.end())
- m_absolut_time.erase(pos);
- }
-
- void set_absolut_time(const MscTimeIntervalSetDList& list)
- {
- m_absolut_time = list;
- }
-
- const MscTimeIntervalSetDList& get_absolut_times() const
- {
- return m_absolut_time;
- }
-
void clear_absolut_times()
{
m_absolut_time.clear();
@@ -2586,15 +2569,60 @@
};
#ifdef _TIME_H_
-class SCMSC_EXPORT TimeRelation:public MscElementTmpl<TimeRelation>
+class SCMSC_EXPORT TimeConstraint:public MscElementTmpl<TimeConstraint>
{
protected:
- bool m_directed; //! indicates directed constraint, see "origin" keyword
MscTimeIntervalSet<double> m_interval_set;
- std::string m_measurement; //! measurement variable name
Size m_width; //! length of the guide line
+ TimeConstraint();
+ TimeConstraint(const MscTimeIntervalSetD& set);
+ TimeConstraint(TimeConstraint *original);
+ virtual ~TimeConstraint();
+
public:
+ void clear_interval_set(){
+ m_interval_set.clear();
+ }
+
+ const MscTimeIntervalSetD& get_interval_set() const;
+ MscTimeIntervalSetD& get_interval_set();
+ void set_interval_set(const MscTimeIntervalSetD& set);
+
+ Size get_width() const
+ {
+ return m_width;
+ }
+
+ void set_width(const Size& width)
+ {
+ m_width = width;
+ }
+};
+
+class SCMSC_EXPORT AbsoluteTime:public TimeConstraint
+{
+public:
+ AbsoluteTime():TimeConstraint()
+ {
+ }
+
+ AbsoluteTime(MscTimeIntervalSetD set):TimeConstraint(set)
+ {
+ }
+
+ AbsoluteTime(AbsoluteTime* original):TimeConstraint(original)
+ {
+ }
+};
+
+class SCMSC_EXPORT TimeRelation:public TimeConstraint
+{
+protected:
+ bool m_directed; //! indicates directed constraint, see "origin" keyword
+ std::string m_measurement; //! measurement variable name
+
+public:
TimeRelation(const MscTimeIntervalSetD& set);
TimeRelation(const std::string& set);
TimeRelation(TimeRelation *original);
@@ -2617,10 +2645,6 @@
m_interval_set.clear();
}
- const MscTimeIntervalSetD& get_interval_set() const;
- MscTimeIntervalSetD& get_interval_set();
- void set_interval_set(const MscTimeIntervalSetD& set);
-
const std::string& get_measurement() const
{
return m_measurement;
@@ -2630,16 +2654,6 @@
{
m_measurement = measurement;
}
-
- Size get_width() const
- {
- return m_width;
- }
-
- void set_width(const Size& width)
- {
- m_width = width;
- }
};
class SCMSC_EXPORT TimeRelationEvent:public TimeRelation
Modified: trunk/src/membership/membership_alg.cpp
===================================================================
--- trunk/src/membership/membership_alg.cpp 2011-08-07 18:14:58 UTC (rev 1175)
+++ trunk/src/membership/membership_alg.cpp 2011-08-08 18:32:38 UTC (rev 1176)
@@ -1117,7 +1117,7 @@
//! makes not full covered intervals colored
void color_intervals(MembershipContext* c)
{
- std::vector<std::pair<TimeRelationPtr, HMscNodePtr> > relations;
+ std::vector<std::pair<TimeConstraintPtr, HMscNodePtr> > relations;
relations = c->get_result()->get_not_full_covered_intervals();
Modified: trunk/src/membership/membership_base.h
===================================================================
--- trunk/src/membership/membership_base.h 2011-08-07 18:14:58 UTC (rev 1175)
+++ trunk/src/membership/membership_base.h 2011-08-08 18:32:38 UTC (rev 1176)
@@ -139,8 +139,8 @@
class MembershipResult
{
- std::vector<std::pair<TimeRelationPtr, HMscNodePtr> > not_covered_intervals; //! intervals in specification which are not satisfied
- std::vector<std::pair<TimeRelationPtr, HMscNodePtr> > not_full_covered_intervals; //! intervals in specification which are not full covered
+ std::vector<std::pair<TimeConstraintPtr, HMscNodePtr> > not_covered_intervals; //! intervals in specification which are not satisfied
+ std::vector<std::pair<TimeConstraintPtr, HMscNodePtr> > not_full_covered_intervals; //! intervals in specification which are not full covered
std::vector<HMscNodePtr> result_path;
//! Number of references to this object.
@@ -151,8 +151,8 @@
friend void intrusive_ptr_release(const MembershipResult *ptr);
public:
- MembershipResult(std::vector<std::pair<TimeRelationPtr, HMscNodePtr> > not_covered,
- std::vector<std::pair<TimeRelationPtr, HMscNodePtr> > not_full_covered,
+ MembershipResult(std::vector<std::pair<TimeConstraintPtr, HMscNodePtr> > not_covered,
+ std::vector<std::pair<TimeConstraintPtr, HMscNodePtr> > not_full_covered,
std::vector<HMscNodePtr> path)
{
not_covered_intervals.insert(not_covered_intervals.begin(), not_covered.begin(), not_covered.end());
@@ -169,12 +169,12 @@
return std::make_pair(not_covered_intervals.size(), not_full_covered_intervals.size());
}
- std::vector<std::pair<TimeRelationPtr, HMscNodePtr> > get_not_covered_intervals()
+ std::vector<std::pair<TimeConstraintPtr, HMscNodePtr> > get_not_covered_intervals()
{
return not_covered_intervals;
}
- std::vector<std::pair<TimeRelationPtr, HMscNodePtr> > get_not_full_covered_intervals()
+ std::vector<std::pair<TimeConstraintPtr, HMscNodePtr> > get_not_full_covered_intervals()
{
return not_full_covered_intervals;
}
@@ -219,8 +219,8 @@
std::map<CoregionAreaPtr, std::vector<CoregionOrderingPtr> > checked_orderings; //! checked possibilities of coregion ordering
std::map<CoregionAreaPtr, CoregionOrderingPtr> coregion_ordering; //! save ordering of coregion events in appropriate coregion
BMscIntervalSetComponentMatrix* time_matrix; //! matrix of all time intervals among events in bmsc
- std::vector<std::pair<TimeRelationPtr, HMscNodePtr> > not_covered_intervals; //! intervals in specification which are not satisfied
- std::vector<std::pair<TimeRelationPtr, HMscNodePtr> > not_full_covered_intervals; //! intervals in specification which are not full covered
+ std::vector<std::pair<TimeConstraintPtr, HMscNodePtr> > not_covered_intervals; //! intervals in specification which are not satisfied
+ std::vector<std::pair<TimeConstraintPtr, HMscNodePtr> > not_full_covered_intervals; //! intervals in specification which are not full covered
std::stack<HMscNodePtr> path; //! store information about the path if the flow meets the specification
bool print_path; //! store whether the path will be printed
@@ -230,7 +230,7 @@
std::stack<std::vector<TimeRelationRefNodePtr> > ref_node_time_stack;
std::map<TimeRelationRefNodePtr, std::vector<MembershipTimeRelationPtr> > ref_node_time; //! key is a time relation in hmsc specification and set of MembershipTimeRelationPtr which hold possible events for the comparison.
- std::stack<std::map<Event*, MscTimeIntervalSetDList> > absolute_time;
+ std::stack<std::map<Event*, AbsoluteTimePtrList> > absolute_time;
enum checkingTimeMode checking_time_mode;
enum DiffType diff_type;
@@ -432,22 +432,22 @@
return time_matrix;
}
- void add_not_full_covered_interval(TimeRelationPtr inter, HMscNodePtr node)
+ void add_not_full_covered_interval(TimeConstraintPtr inter, HMscNodePtr node)
{
not_full_covered_intervals.push_back(std::make_pair(inter, node));
}
- const std::vector<std::pair<TimeRelationPtr, HMscNodePtr> > get_not_full_covered_intervals()
+ const std::vector<std::pair<TimeConstraintPtr, HMscNodePtr> > get_not_full_covered_intervals()
{
return not_full_covered_intervals;
}
- void add_not_covered_interval(TimeRelationPtr inter, HMscNodePtr node)
+ void add_not_covered_interval(TimeConstraintPtr inter, HMscNodePtr node)
{
not_covered_intervals.push_back(std::make_pair(inter,node));
}
- const std::vector<std::pair<TimeRelationPtr, HMscNodePtr> > get_not_covered_intervals()
+ const std::vector<std::pair<TimeConstraintPtr, HMscNodePtr> > get_not_covered_intervals()
{
return not_covered_intervals;
}
@@ -587,10 +587,10 @@
}
- void add_absolute_time(Event* e, MscTimeIntervalSetDList list)
+ void add_absolute_time(Event* e, AbsoluteTimePtrList list)
{
- std::pair<std::map<Event*, MscTimeIntervalSetDList>::iterator, bool> map_return;
- MscTimeIntervalSetDList::iterator list_it;
+ std::pair<std::map<Event*, AbsoluteTimePtrList>::iterator, bool> map_return;
+ AbsoluteTimePtrList::iterator list_it;
//it's tricky one, the return value returns a pair of iteratior and a bool value whether the element was added
//in both cases the first of return pair is a iterator to the element in the map
@@ -605,7 +605,7 @@
}
}
- std::stack<std::map<Event*, MscTimeIntervalSetDList> > get_absolute_time()
+ std::stack<std::map<Event*, AbsoluteTimePtrList> > get_absolute_time()
{
return absolute_time;
}
@@ -658,7 +658,7 @@
void push_time_stacks()
{
std::map<TimeRelationEventPtr, std::vector<MembershipTimeRelationPtr> > r_time;
- std::map<Event*, MscTimeIntervalSetDList> a_time;
+ std::map<Event*, AbsoluteTimePtrList> a_time;
std::vector<TimeRelationRefNodePtr> ref_time;
relative_time.push(r_time);
Modified: trunk/src/membership/membership_time.cpp
===================================================================
--- trunk/src/membership/membership_time.cpp 2011-08-07 18:14:58 UTC (rev 1175)
+++ trunk/src/membership/membership_time.cpp 2011-08-08 18:32:38 UTC (rev 1176)
@@ -18,10 +18,10 @@
#include "membership/membership_time.h"
std::set<MembershipTimeRelationPtr> merge_relative_time_constraints(MembershipContext* c);
-std::map<Event*, MscTimeIntervalSetDList> merge_absolute_time_constraints(MembershipContext* c);
+std::map<Event*, AbsoluteTimePtrList> merge_absolute_time_constraints(MembershipContext* c);
std::set<MembershipTimeRelationPtr> merge_ref_node_time_constraints(MembershipContext* c);
bool check_time(MembershipContext* c, std::set<MembershipTimeRelationPtr>& relative_time,
- std::map<Event*, MscTimeIntervalSetDList>& absolute_time,
+ std::map<Event*, AbsoluteTimePtrList>& absolute_time,
std::set<MembershipTimeRelationPtr> ref_node_time);
void print_bmsc(MembershipContext* c)
@@ -62,7 +62,7 @@
{
std::set<MembershipTimeRelationPtr> relative_time;
- std::map<Event*, MscTimeIntervalSetDList> absolute_time;
+ std::map<Event*, AbsoluteTimePtrList> absolute_time;
std::set<MembershipTimeRelationPtr> ref_node_time;
relative_time = merge_relative_time_constraints(c);
@@ -98,10 +98,10 @@
return relative_time;
}
-std::map<Event*, MscTimeIntervalSetDList> merge_absolute_time_constraints(MembershipContext* c)
+std::map<Event*, AbsoluteTimePtrList> merge_absolute_time_constraints(MembershipContext* c)
{
- std::map<Event*, MscTimeIntervalSetDList> absolute_time, temp;
- std::stack<std::map<Event*, MscTimeIntervalSetDList> > stack;
+ std::map<Event*, AbsoluteTimePtrList> absolute_time, temp;
+ std::stack<std::map<Event*, AbsoluteTimePtrList> > stack;
stack = c->get_absolute_time();
@@ -110,7 +110,7 @@
temp = stack.top();
stack.pop();
- std::map<Event*, MscTimeIntervalSetDList>::iterator it, temp_it;
+ std::map<Event*, AbsoluteTimePtrList>::iterator it, temp_it;
for(temp_it = temp.begin(); temp_it != temp.end(); temp_it++)
{
it = absolute_time.find(temp_it->first);
@@ -141,7 +141,7 @@
}
bool check_time_absolute_mode(MembershipContext* c, std::set<MembershipTimeRelationPtr>& relative_time,
- std::map<Event*, MscTimeIntervalSetDList>& absolute_time,
+ std::map<Event*, AbsoluteTimePtrList>& absolute_time,
std::set<MembershipTimeRelationPtr> ref_node_time)
{
std::map<TimeRelationRefNodePtr, std::vector<MembershipTimeRelationPtr> > ref_node_time_map;
@@ -195,8 +195,11 @@
MscTimeIntervalSetD bmsc_inter, hmsc_inter, result;
//TODO when a time constraints is not only a one interval
- MscTimeIntervalSetD start_i = *(start_e->get_absolut_times().begin());
- MscTimeIntervalSetD end_i = *(end_e->get_absolut_times().begin());
+ AbsoluteTimePtr abs_start = *(start_e->get_absolut_times().begin());
+ AbsoluteTimePtr abs_end = *(end_e->get_absolut_times().begin());
+ MscTimeIntervalSetD start_i = abs_start->get_interval_set();
+ MscTimeIntervalSetD end_i = abs_end->get_interval_set();
+
bmsc_inter = get_continous_interval(c, start_i, end_i);
hmsc_inter = map_it->first->get_interval_set();
@@ -214,21 +217,21 @@
//absolute time constraints checking
if(absolute_time.size() > 0)
{
- std::map<Event*, MscTimeIntervalSetDList>::iterator absolute_it;
+ std::map<Event*, AbsoluteTimePtrList>::iterator absolute_it;
MscTimeIntervalSetD bmsc_inter, hmsc_absolute, result;
//TODO only first list interval is taken to the consideration
for(absolute_it = absolute_time.begin(); absolute_it != absolute_time.end(); absolute_it++)
{
- bmsc_inter = absolute_it->first->get_absolut_times().front();
- hmsc_absolute = *(absolute_it->second.begin());
+ bmsc_inter = absolute_it->first->get_absolut_times().front()->get_interval_set();
+ hmsc_absolute = (*(absolute_it->second.begin()))->get_interval_set();
result = MscTimeIntervalSetD::set_intersection(hmsc_absolute, bmsc_inter);
if(result.is_empty())
- c->add_not_covered_interval(map_it->first, NULL);
+ c->add_not_covered_interval(*(absolute_it->second.begin()), NULL);
else
if(result != bmsc_inter)
- c->add_not_full_covered_interval(map_it->first, NULL);
+ c->add_not_full_covered_interval(*(absolute_it->second.begin()), NULL);
}
}
@@ -241,9 +244,12 @@
Event* start_e = *(*relative_it)->get_start().begin();
Event* end_e = *(*relative_it)->get_end().begin();
- MscTimeIntervalSetD start_i = *(start_e->get_absolut_times().begin());
- MscTimeIntervalSetD end_i = *(end_e->get_absolut_times().begin());
+ AbsoluteTimePtr start_abs = *(start_e->get_absolut_times().begin());
+ AbsoluteTimePtr end_abs = *(end_e->get_absolut_times().begin());
+ MscTimeIntervalSetD start_i = start_abs->get_interval_set();
+ MscTimeIntervalSetD end_i = end_abs->get_interval_set();
+
bmsc_inter = get_continous_interval(c, start_i, end_i);
hmsc_inter = (*relative_it)->get_interval_set();
@@ -260,7 +266,7 @@
}
bool check_time_relative_mode(MembershipContext* c, std::set<MembershipTimeRelationPtr>& relative_time,
- std::map<Event*, MscTimeIntervalSetDList>& absolute_time,
+ std::map<Event*, AbsoluteTimePtrList>& absolute_time,
std::set<MembershipTimeRelationPtr> ref_node_time)
{
BMscPtr bmsc_f = c->get_bmsc();
@@ -337,7 +343,7 @@
}
//add time relation between events with absolute time comstrainst to possible minimal events
- std::map<Event*, MscTimeIntervalSetDList>::iterator map_it;
+ std::map<Event*, AbsoluteTimePtrList>::iterator map_it;
for(map_it = absolute_time.begin(); map_it != absolute_time.end(); map_it++)
{
for(second = bmsc_minimal_events.begin(); second != bmsc_minimal_events.end(); second++)
@@ -444,21 +450,21 @@
{
Event* minimal = get_min_event(c, bmsc_minimal_events);
- std::map<Event*, MscTimeIntervalSetDList>::iterator absolute_it;
+ std::map<Event*, AbsoluteTimePtrList>::iterator absolute_it;
MscTimeIntervalSetD bmsc_inter, hmsc_absolute, result;
for(absolute_it = absolute_time.begin(); absolute_it != absolute_time.end(); absolute_it++)
{
bmsc_inter = c->get_time_matrix()->operator()(minimal, absolute_it->first);
//TODO only first interval from the list is taken to comparison, don't know why the list is pressen and not only a interval.
- hmsc_absolute = *(absolute_it->second.begin());
+ hmsc_absolute = (*(absolute_it->second.begin()))->get_interval_set();
result = MscTimeIntervalSetD::set_intersection(hmsc_absolute, bmsc_inter);
if(result.is_empty())
- c->add_not_covered_interval(map_it->first, NULL);
+ c->add_not_covered_interval(*(absolute_it->second.begin()), NULL);
else
if(result != bmsc_inter)
- c->add_not_full_covered_interval(map_it->first, NULL);
+ c->add_not_full_covered_interval(*(absolute_it->second.begin()), NULL);
}
}
@@ -487,7 +493,7 @@
}
bool check_time(MembershipContext* c, std::set<MembershipTimeRelationPtr>& relative_time,
- std::map<Event*, MscTimeIntervalSetDList>& absolute_time,
+ std::map<Event*, AbsoluteTimePtrList>& absolute_time,
std::set<MembershipTimeRelationPtr> ref_node_time)
{
switch(c->get_checking_time_mode())
@@ -790,9 +796,12 @@
return 3;
}
- MscTimeIntervalSetD a = *(first->get_absolut_times().begin());
- MscTimeIntervalSetD b = *(second->get_absolut_times().begin());
+ AbsoluteTimePtr a_abs = *(first->get_absolut_times().begin());
+ AbsoluteTimePtr b_abs = *(second->get_absolut_times().begin());
+ MscTimeIntervalSetD a = a_abs->get_interval_set();
+ MscTimeIntervalSetD b = b_abs->get_interval_set();
+
inter = get_continous_interval(c, a, b);
}
else
Added: trunk/tests/membership/bmsc_absolute_pat1_1.mpr.result
===================================================================
--- trunk/tests/membership/bmsc_absolute_pat1_1.mpr.result (rev 0)
+++ trunk/tests/membership/bmsc_absolute_pat1_1.mpr.result 2011-08-08 18:32:38 UTC (rev 1176)
@@ -0,0 +1,50 @@
+Flow "Page_1" not found. Unsatisfied time constraint(s) (red intervals are not satisfied, blue intervals are partialy satisfied):
+mscdocument bmsc_spec_absolute1;
+msc Page_1;
+inst PC;
+inst Router;
+inst Server;
+PC: instance;
+out c,0 to Router;
+time [@0];
+out a,1 to Router;
+out a,2 to Router;
+in b,3 from Router;
+out c,4 to Router;
+time [@15];
+endinstance;
+Router: instance;
+in c,0 from PC;
+time [@0];
+out a,5 to Server;
+out b,6 to Server;
+time /* NOT_COVER */
+[@5];
+in a,1 from PC;
+time [@10];
+in b,7 from Server;
+time [@11];
+in a,2 from PC;
+time [@11];
+in b,8 from Server;
+time [@13];
+in a,9 from Server;
+out b,3 to PC;
+time [@14];
+in a,10 from Server;
+in c,4 from PC;
+time [@15];
+endinstance;
+Server: instance;
+in a,5 from Router;
+time [@7];
+in b,6 from Router;
+time [@9];
+out b,7 to Router;
+out b,8 to Router;
+time [@13];
+out a,9 to Router;
+out a,10 to Router;
+time [@14];
+endinstance;
+endmsc;
Added: trunk/tests/membership/bmsc_absolute_pat1_2.mpr.result
===================================================================
--- trunk/tests/membership/bmsc_absolute_pat1_2.mpr.result (rev 0)
+++ trunk/tests/membership/bmsc_absolute_pat1_2.mpr.result 2011-08-08 18:32:38 UTC (rev 1176)
@@ -0,0 +1,60 @@
+Flow "Page_1" not found. Unsatisfied time constraint(s) (red intervals are not satisfied, blue intervals are partialy satisfied):
+mscdocument bmsc_spec_absolute2;
+msc Page_1;
+inst PC;
+inst Router;
+inst Server;
+PC: instance;
+out c,0 to Router;
+time [@0];
+out a,1 to Router;
+time [@10];
+out a,2 to Router;
+time [@11];
+in b,3 from Router;
+time [@15];
+out c,4 to Router;
+time [@15];
+endinstance;
+Router: instance;
+in c,0 from PC;
+time [@0];
+label e0;
+out a,5 to Server;
+time/* NOT_COVER */
+ e1 [0,1];
+label e1;
+out b,6 to Server;
+in a,1 from PC;
+time [@10];
+in b,7 from Server;
+time [@11];
+in a,2 from PC;
+time [@11];
+label e2;
+in b,8 from Server;
+time e3 [0,1];
+label e3;
+in a,9 from Server;
+out b,3 to PC;
+time [@14];
+in a,10 from Server;
+time [@14];
+in c,4 from PC;
+time [@15];
+endinstance;
+Server: instance;
+in a,5 from Router;
+time [@7];
+in b,6 from Router;
+time [@9];
+out b,7 to Router;
+time [@10];
+out b,8 to Router;
+time [@13];
+out a,9 to Router;
+time [@14];
+out a,10 to Router;
+time [@14];
+endinstance;
+endmsc;
Added: trunk/tests/membership/bmsc_absolute_pat2_4.mpr.result
===================================================================
--- trunk/tests/membership/bmsc_absolute_pat2_4.mpr.result (rev 0)
+++ trunk/tests/membership/bmsc_absolute_pat2_4.mpr.result 2011-08-08 18:32:38 UTC (rev 1176)
@@ -0,0 +1,53 @@
+Flow "Page_1" not found. Unsatisfied time constraint(s) (red intervals are not satisfied, blue intervals ar...
[truncated message content] |
|
From: <ma...@us...> - 2011-08-09 17:24:51
|
Revision: 1178
http://scstudio.svn.sourceforge.net/scstudio/?rev=1178&view=rev
Author: madzin
Date: 2011-08-09 17:24:44 +0000 (Tue, 09 Aug 2011)
Log Message:
-----------
Bug fix: reference node was not marked in case absolute time constraint was not satisfied.
Modified Paths:
--------------
trunk/src/membership/membership_alg.cpp
trunk/src/membership/membership_base.h
trunk/src/membership/membership_time.cpp
Added Paths:
-----------
trunk/tests/membership/complete_absolute_pat2.mpr.result
trunk/tests/membership/complete_pat6_6.mpr.result
Modified: trunk/src/membership/membership_alg.cpp
===================================================================
--- trunk/src/membership/membership_alg.cpp 2011-08-09 00:31:03 UTC (rev 1177)
+++ trunk/src/membership/membership_alg.cpp 2011-08-09 17:24:44 UTC (rev 1178)
@@ -1033,6 +1033,7 @@
{
//get msc from the node
ConfigurationPtr old_conf = new Configuration(conf);
+ c->set_processed_ref_node(node);
MscPtr msc = node->get_msc();
BMscPtr bmsc = boost::dynamic_pointer_cast<BMsc > (msc);
Modified: trunk/src/membership/membership_base.h
===================================================================
--- trunk/src/membership/membership_base.h 2011-08-09 00:31:03 UTC (rev 1177)
+++ trunk/src/membership/membership_base.h 2011-08-09 17:24:44 UTC (rev 1178)
@@ -38,6 +38,7 @@
class MembershipResult;
class MembershipContext;
class MembershipTimeRelation;
+class MembershipAbsoluteTime;
enum check_type {membership, receive_ordering};
enum TopBottom {top, bottom};
@@ -50,7 +51,10 @@
typedef boost::intrusive_ptr<CoregionOrdering> CoregionOrderingPtr;
typedef boost::intrusive_ptr<MembershipTimeRelation> MembershipTimeRelationPtr;
typedef boost::intrusive_ptr<MembershipResult> MembershipResultPtr;
+typedef boost::intrusive_ptr<MembershipAbsoluteTime> MembershipAbsoluteTimePtr;
+typedef std::list<MembershipAbsoluteTimePtr> MembershipAbsoluteTimePtrList;
+
class MembershipTimeRelation
{
private:
@@ -137,6 +141,52 @@
}
}
+class MembershipAbsoluteTime
+{
+private:
+ HMscNodePtr ref_node;
+ AbsoluteTimePtr abs;
+
+ //! Number of references to this object.
+ mutable size_t m_counter;
+
+// see http://www.boost.org/doc/libs/1_37_0/libs/smart_ptr/intrusive_ptr.html
+friend void intrusive_ptr_add_ref(const MembershipAbsoluteTime *ptr);
+friend void intrusive_ptr_release(const MembershipAbsoluteTime *ptr);
+
+public:
+ MembershipAbsoluteTime(AbsoluteTimePtr abs, HMscNodePtr ref_node)
+ {
+ this->abs = abs;
+ this->ref_node = ref_node;
+ }
+
+ HMscNodePtr get_ref_node()
+ {
+ return ref_node;
+ }
+
+ AbsoluteTimePtr get_absolute_time()
+ {
+ return abs;
+ }
+};
+
+inline void intrusive_ptr_add_ref(const MembershipAbsoluteTime *ptr)
+{
+ if(ptr != NULL)
+ ++ptr->m_counter;
+}
+
+inline void intrusive_ptr_release(const MembershipAbsoluteTime *ptr)
+{
+ if(ptr != NULL)
+ {
+ if(--ptr->m_counter <= 0)
+ delete ptr;
+ }
+}
+
class MembershipResult
{
std::vector<std::pair<TimeConstraintPtr, HMscNodePtr> > not_covered_intervals; //! intervals in specification which are not satisfied
@@ -210,6 +260,7 @@
BMscPtr bmsc; //! bmsc which represents the flow
MscPtr msc; //! msc which represents the specification
HMscPtr hmsc; //! hmsc which represents the specification //TODO (find uses hmsc, diff uses msc)
+ ReferenceNodePtr processed_ref_node; //! currently processed reference node
std::vector<std::wstring> focused_instances; //! name of instances on which a user is focused on
std::map<CoregionAreaPtr, SnapshotContextPtr> snapshots; //! snapshots of context for each coregion
std::vector<Event*> attributed_events; //! events with attribute
@@ -230,7 +281,7 @@
std::stack<std::vector<TimeRelationRefNodePtr> > ref_node_time_stack;
std::map<TimeRelationRefNodePtr, std::vector<MembershipTimeRelationPtr> > ref_node_time; //! key is a time relation in hmsc specification and set of MembershipTimeRelationPtr which hold possible events for the comparison.
- std::stack<std::map<Event*, AbsoluteTimePtrList> > absolute_time;
+ std::stack<std::map<Event*, MembershipAbsoluteTimePtrList> > absolute_time;
enum checkingTimeMode checking_time_mode;
enum DiffType diff_type;
@@ -246,6 +297,10 @@
diff_type = NOT_DIFF;
checking_time_mode = NO_TIME;
result = NULL;
+ bmsc = NULL;
+ msc = NULL;
+ hmsc = NULL;
+ processed_ref_node = NULL;
}
void set_mem(MembershipAlg* m)
@@ -293,6 +348,16 @@
return msc;
}
+ void set_processed_ref_node(ReferenceNodePtr node)
+ {
+ processed_ref_node = node;
+ }
+
+ ReferenceNodePtr get_processed_ref_node()
+ {
+ return processed_ref_node;
+ }
+
void set_focused_instances(std::vector<std::wstring> instances)
{
focused_instances.insert(focused_instances.begin(), instances.begin(), instances.end());
@@ -587,25 +652,35 @@
}
- void add_absolute_time(Event* e, AbsoluteTimePtrList list)
+ void add_absolute_time(Event* e, AbsoluteTimePtrList list, HMscNodePtr ref_node)
{
- std::pair<std::map<Event*, AbsoluteTimePtrList>::iterator, bool> map_return;
+ std::map<Event*, MembershipAbsoluteTimePtrList>::iterator map_it;
AbsoluteTimePtrList::iterator list_it;
+ MembershipAbsoluteTimePtr abs;
- //it's tricky one, the return value returns a pair of iteratior and a bool value whether the element was added
- //in both cases the first of return pair is a iterator to the element in the map
- map_return = absolute_time.top().insert(std::make_pair(e, list));
+ if(absolute_time.top().find(e) == absolute_time.top().end())
+ {
+ MembershipAbsoluteTimePtrList abs_list;
- if(map_return.second == false)
+ for(list_it = list.begin(); list_it != list.end(); list_it++)
+ {
+ abs = new MembershipAbsoluteTime(*list_it, ref_node);
+ abs_list.push_back(abs);
+ }
+
+ absolute_time.top().insert(std::make_pair(e, abs_list));
+ }
+ else
{
for(list_it = list.begin(); list_it != list.end(); list_it++)
{
- map_return.first->second.insert(map_return.first->second.begin(), *list_it);
+ abs = new MembershipAbsoluteTime(*list_it, ref_node);
+ map_it->second.push_back(abs);
}
}
}
- std::stack<std::map<Event*, AbsoluteTimePtrList> > get_absolute_time()
+ std::stack<std::map<Event*, MembershipAbsoluteTimePtrList> > get_absolute_time()
{
return absolute_time;
}
@@ -658,7 +733,7 @@
void push_time_stacks()
{
std::map<TimeRelationEventPtr, std::vector<MembershipTimeRelationPtr> > r_time;
- std::map<Event*, AbsoluteTimePtrList> a_time;
+ std::map<Event*, MembershipAbsoluteTimePtrList> a_time;
std::vector<TimeRelationRefNodePtr> ref_time;
relative_time.push(r_time);
Modified: trunk/src/membership/membership_time.cpp
===================================================================
--- trunk/src/membership/membership_time.cpp 2011-08-09 00:31:03 UTC (rev 1177)
+++ trunk/src/membership/membership_time.cpp 2011-08-09 17:24:44 UTC (rev 1178)
@@ -18,10 +18,10 @@
#include "membership/membership_time.h"
std::set<MembershipTimeRelationPtr> merge_relative_time_constraints(MembershipContext* c);
-std::map<Event*, AbsoluteTimePtrList> merge_absolute_time_constraints(MembershipContext* c);
+std::map<Event*, MembershipAbsoluteTimePtrList> merge_absolute_time_constraints(MembershipContext* c);
std::set<MembershipTimeRelationPtr> merge_ref_node_time_constraints(MembershipContext* c);
bool check_time(MembershipContext* c, std::set<MembershipTimeRelationPtr>& relative_time,
- std::map<Event*, AbsoluteTimePtrList>& absolute_time,
+ std::map<Event*, MembershipAbsoluteTimePtrList>& absolute_time,
std::set<MembershipTimeRelationPtr> ref_node_time);
void print_bmsc(MembershipContext* c)
@@ -62,7 +62,7 @@
{
std::set<MembershipTimeRelationPtr> relative_time;
- std::map<Event*, AbsoluteTimePtrList> absolute_time;
+ std::map<Event*, MembershipAbsoluteTimePtrList> absolute_time;
std::set<MembershipTimeRelationPtr> ref_node_time;
relative_time = merge_relative_time_constraints(c);
@@ -98,10 +98,11 @@
return relative_time;
}
-std::map<Event*, AbsoluteTimePtrList> merge_absolute_time_constraints(MembershipContext* c)
+//! merge maps of absolute time constraints which are stored in the stack to one map
+std::map<Event*, MembershipAbsoluteTimePtrList> merge_absolute_time_constraints(MembershipContext* c)
{
- std::map<Event*, AbsoluteTimePtrList> absolute_time, temp;
- std::stack<std::map<Event*, AbsoluteTimePtrList> > stack;
+ std::map<Event*, MembershipAbsoluteTimePtrList> absolute_time, temp;
+ std::stack<std::map<Event*, MembershipAbsoluteTimePtrList> > stack;
stack = c->get_absolute_time();
@@ -110,7 +111,7 @@
temp = stack.top();
stack.pop();
- std::map<Event*, AbsoluteTimePtrList>::iterator it, temp_it;
+ std::map<Event*, MembershipAbsoluteTimePtrList>::iterator it, temp_it;
for(temp_it = temp.begin(); temp_it != temp.end(); temp_it++)
{
it = absolute_time.find(temp_it->first);
@@ -141,7 +142,7 @@
}
bool check_time_absolute_mode(MembershipContext* c, std::set<MembershipTimeRelationPtr>& relative_time,
- std::map<Event*, AbsoluteTimePtrList>& absolute_time,
+ std::map<Event*, MembershipAbsoluteTimePtrList>& absolute_time,
std::set<MembershipTimeRelationPtr> ref_node_time)
{
std::map<TimeRelationRefNodePtr, std::vector<MembershipTimeRelationPtr> > ref_node_time_map;
@@ -217,21 +218,23 @@
//absolute time constraints checking
if(absolute_time.size() > 0)
{
- std::map<Event*, AbsoluteTimePtrList>::iterator absolute_it;
+ std::map<Event*, MembershipAbsoluteTimePtrList>::iterator absolute_it;
MscTimeIntervalSetD bmsc_inter, hmsc_absolute, result;
+ MembershipAbsoluteTimePtr abs;
//TODO only first list interval is taken to the consideration
for(absolute_it = absolute_time.begin(); absolute_it != absolute_time.end(); absolute_it++)
{
+ MembershipAbsoluteTimePtr abs = *(absolute_it->second.begin());
bmsc_inter = absolute_it->first->get_absolut_times().front()->get_interval_set();
- hmsc_absolute = (*(absolute_it->second.begin()))->get_interval_set();
+ hmsc_absolute = abs->get_absolute_time()->get_interval_set();
result = MscTimeIntervalSetD::set_intersection(hmsc_absolute, bmsc_inter);
if(result.is_empty())
- c->add_not_covered_interval(*(absolute_it->second.begin()), NULL);
+ c->add_not_covered_interval(abs->get_absolute_time(), abs->get_ref_node());
else
if(result != bmsc_inter)
- c->add_not_full_covered_interval(*(absolute_it->second.begin()), NULL);
+ c->add_not_full_covered_interval(abs->get_absolute_time(), abs->get_ref_node());
}
}
@@ -266,7 +269,7 @@
}
bool check_time_relative_mode(MembershipContext* c, std::set<MembershipTimeRelationPtr>& relative_time,
- std::map<Event*, AbsoluteTimePtrList>& absolute_time,
+ std::map<Event*, MembershipAbsoluteTimePtrList>& absolute_time,
std::set<MembershipTimeRelationPtr> ref_node_time)
{
BMscPtr bmsc_f = c->get_bmsc();
@@ -343,7 +346,7 @@
}
//add time relation between events with absolute time comstrainst to possible minimal events
- std::map<Event*, AbsoluteTimePtrList>::iterator map_it;
+ std::map<Event*, MembershipAbsoluteTimePtrList>::iterator map_it;
for(map_it = absolute_time.begin(); map_it != absolute_time.end(); map_it++)
{
for(second = bmsc_minimal_events.begin(); second != bmsc_minimal_events.end(); second++)
@@ -449,22 +452,24 @@
if(absolute_time.size() > 0)
{
Event* minimal = get_min_event(c, bmsc_minimal_events);
+ std::map<Event*, MembershipAbsoluteTimePtrList>::iterator absolute_it;
+ MscTimeIntervalSetD bmsc_inter, hmsc_absolute, result;
+ MembershipAbsoluteTimePtr abs;
- std::map<Event*, AbsoluteTimePtrList>::iterator absolute_it;
- MscTimeIntervalSetD bmsc_inter, hmsc_absolute, result;
for(absolute_it = absolute_time.begin(); absolute_it != absolute_time.end(); absolute_it++)
{
+ //TODO only first interval from the list is taken to comparison, don't know why the list is pressen and not only a interval.
+ abs = *(absolute_it->second.begin());
bmsc_inter = c->get_time_matrix()->operator()(minimal, absolute_it->first);
- //TODO only first interval from the list is taken to comparison, don't know why the list is pressen and not only a interval.
- hmsc_absolute = (*(absolute_it->second.begin()))->get_interval_set();
+ hmsc_absolute = abs->get_absolute_time()->get_interval_set();
result = MscTimeIntervalSetD::set_intersection(hmsc_absolute, bmsc_inter);
if(result.is_empty())
- c->add_not_covered_interval(*(absolute_it->second.begin()), NULL);
+ c->add_not_covered_interval(abs->get_absolute_time(), abs->get_ref_node());
else
if(result != bmsc_inter)
- c->add_not_full_covered_interval(*(absolute_it->second.begin()), NULL);
+ c->add_not_full_covered_interval(abs->get_absolute_time(), abs->get_ref_node());
}
}
@@ -493,7 +498,7 @@
}
bool check_time(MembershipContext* c, std::set<MembershipTimeRelationPtr>& relative_time,
- std::map<Event*, AbsoluteTimePtrList>& absolute_time,
+ std::map<Event*, MembershipAbsoluteTimePtrList>& absolute_time,
std::set<MembershipTimeRelationPtr> ref_node_time)
{
switch(c->get_checking_time_mode())
@@ -850,7 +855,7 @@
void analyze_time_constraints(MembershipContext* c, Event* node_e, Event* b_e)
{
if(node_e->get_absolut_times().size() > 0)
- c->add_absolute_time(b_e, node_e->get_absolut_times());
+ c->add_absolute_time(b_e, node_e->get_absolut_times(), c->get_processed_ref_node());
if(node_e->get_time_relations().size() > 0)
c->add_relative_time(b_e, node_e->get_time_relations(), node_e);
Added: trunk/tests/membership/complete_absolute_pat2.mpr.result
===================================================================
--- trunk/tests/membership/complete_absolute_pat2.mpr.result (rev 0)
+++ trunk/tests/membership/complete_absolute_pat2.mpr.result 2011-08-09 17:24:44 UTC (rev 1178)
@@ -0,0 +1,125 @@
+Flow "Page_1" not found. Unsatisfied time constraint(s) (red intervals are not satisfied, blue intervals are partialy satisfied):
+mscdocument complete_absolute;
+msc Page_1;
+/* PATH */
+initial connect/* PATH */
+ L0;
+/* PATH */
+L0: reference A/* PATH */
+ connect/* PATH */
+ L1;
+/* PATH */
+L1:/* PATH */
+ connect/* PATH */
+ L2, L3;
+/* MARKED */
+L2: reference C top/* NOT_COVER */
+ bottom L4 [4,5];
+ bottom top L4 [2,3);
+/* PATH */
+ connect/* PATH */
+ L4;
+L3: reference B time [1];
+ connect L5;
+/* PATH */
+L4: reference D/* PATH */
+ connect/* PATH */
+ L5;
+/* PATH */
+L5:/* PATH */
+ connect/* PATH */
+ L6;
+/* PATH */
+L6: final/* PATH */
+;
+endmsc;
+msc A;
+inst PC;
+inst Router;
+inst Server;
+PC: instance;
+label e0;
+out c,0 to Router;
+time e1 [0,1);
+endinstance;
+Router: instance;
+concurrent;
+label e1;
+in c,0 from PC;
+label e2;
+out a,1 to Server before e3;
+time e3 [1,2];
+label e3;
+out b,2 to Server;
+endconcurrent;
+endinstance;
+Server: instance;
+in a,1 from Router;
+in b,2 from Router;
+endinstance;
+endmsc;
+msc C;
+inst PC;
+inst Router;
+inst Server;
+PC: instance;
+out a,0 to Router;
+time /* NOT_FULL_COVER */
+@[9,10];
+out a,1 to Router;
+endinstance;
+Router: instance;
+in a,0 from PC;
+in b,2 from Server;
+in a,1 from PC;
+endinstance;
+Server: instance;
+out b,2 to Router;
+endinstance;
+endmsc;
+msc B;
+inst PC;
+inst Router;
+inst Server;
+PC: instance;
+in c,0 from Server;
+out b,1 to Router;
+endinstance;
+Router: instance;
+in c,2 from Server;
+in b,1 from PC;
+time @[0,15];
+endinstance;
+Server: instance;
+concurrent;
+out c,2 to Router;
+out c,0 to PC;
+endconcurrent;
+endinstance;
+endmsc;
+msc D;
+inst PC;
+inst Router;
+inst Server;
+PC: instance;
+in b,0 from Router;
+out c,1 to Router;
+time @[15,16];
+endinstance;
+Router: instance;
+concurrent;
+in a,2 from Server;
+in a,3 from Server;
+in b,4 from Server;
+out b,0 to PC;
+endconcurrent;
+in c,1 from PC;
+endinstance;
+Server: instance;
+concurrent;
+out a,2 to Router;
+out a,3 to Router;
+out b,4 to Router;
+endconcurrent;
+endinstance;
+endmsc;
Added: trunk/tests/membership/complete_pat6_6.mpr.result
===================================================================
--- trunk/tests/membership/complete_pat6_6.mpr.result (rev 0)
+++ trunk/tests/membership/complete_pat6_6.mpr.result 2011-08-09 17:24:44 UTC (rev 1178)
@@ -0,0 +1,42 @@
+Flow "Page_1" not found. Unsatisfied time constraint(s) (red intervals are not satisfied, blue intervals are partialy satisfied):
+mscdocument bmsc_spec3;
+msc Page_1;
+inst PC;
+inst Router;
+inst Server;
+PC: instance;
+out c,0 to Router;
+out a,1 to Router;
+label e0;
+out a,2 to Router;
+time e1 [4,6);
+in b,3 from Router;
+label e1;
+out c,4 to Router;
+endinstance;
+Router: instance;
+in c,0 from PC;
+label e2;
+out a,5 to Server;
+time/* NOT_COVER */
+ e3 [3,6];
+label e3;
+out b,6 to Server;
+in a,1 from PC;
+in b,7 from Server;
+in a,2 from PC;
+in b,8 from Server;
+in a,9 from Server;
+out b,3 to PC;
+in a,10 from Server;
+in c,4 from PC;
+endinstance;
+Server: instance;
+in a,5 from Router;
+in b,6 from Router;
+out b,7 to Router;
+out b,8 to Router;
+out a,9 to Router;
+out a,10 to Router;
+endinstance;
+endmsc;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ma...@us...> - 2011-08-11 14:37:55
|
Revision: 1180
http://scstudio.svn.sourceforge.net/scstudio/?rev=1180&view=rev
Author: madzin
Date: 2011-08-11 14:37:48 +0000 (Thu, 11 Aug 2011)
Log Message:
-----------
Fix test empty_neg_pat.mpr
Modified Paths:
--------------
trunk/src/membership/membership_additional.cpp
trunk/src/membership/membership_additional.h
trunk/src/membership/membership_alg.cpp
trunk/src/membership/membership_base.h
trunk/tests/membership/CMakeLists.txt
trunk/tests/membership/empty_pos_pat.mpr
Added Paths:
-----------
trunk/tests/membership/empty_neg_pat.mpr.result
trunk/tests/membership/empty_pos_pat.mpr.result
Modified: trunk/src/membership/membership_additional.cpp
===================================================================
--- trunk/src/membership/membership_additional.cpp 2011-08-11 14:09:08 UTC (rev 1179)
+++ trunk/src/membership/membership_additional.cpp 2011-08-11 14:37:48 UTC (rev 1180)
@@ -136,22 +136,6 @@
return true;
}
-bool look_at_checked_conf(MembershipContext* c, ReferenceNodePtr node, ConfigurationPtr b)
-{
- const std::set<ConfigurationPtr> checked_conf = c->find_checked_conf(node->get_msc()->get_label());
-
- if (!checked_conf.empty())
- {
- std::set<ConfigurationPtr>::const_iterator conf_it;
-
- for (conf_it = checked_conf.begin(); conf_it != checked_conf.end(); conf_it++)
- if (b->compare(*conf_it))
- return false;
- }
-
- return true;
-}
-
//TODO I don't like the time of increasing max id
void set_identification(MembershipContext* c, Event* node_e, Event* b_e)
{
Modified: trunk/src/membership/membership_additional.h
===================================================================
--- trunk/src/membership/membership_additional.h 2011-08-11 14:09:08 UTC (rev 1179)
+++ trunk/src/membership/membership_additional.h 2011-08-11 14:37:48 UTC (rev 1180)
@@ -37,9 +37,6 @@
void compare_events_attribute_diff(MembershipContext* c, Event* spec_e, Event* flow_e);
-//! tries to find configuration into map of seared configuration
-bool look_at_checked_conf(MembershipContext* c, ReferenceNodePtr node, ConfigurationPtr b);
-
/**
* \brief in case events are send events, adds attribute to both events and to both receive event in case messages are complete
*
Modified: trunk/src/membership/membership_alg.cpp
===================================================================
--- trunk/src/membership/membership_alg.cpp 2011-08-11 14:09:08 UTC (rev 1179)
+++ trunk/src/membership/membership_alg.cpp 2011-08-11 14:37:48 UTC (rev 1180)
@@ -374,14 +374,6 @@
return false;
}
- //checks if this node with this configuration was checked
- if (!look_at_checked_conf(c, node, b))
- {
- c->top_pop_path();
- c->pop_time_stacks();
- return false;
- }
-
ConfigurationPtr old_config_I, old_config_II;
old_config_I = new Configuration(b);
@@ -809,22 +801,6 @@
}
/*
- * Add checked branch to map of checked branches
- */
-void add_checked_branch(MembershipContext* c, ReferenceNodePtr ref_node, ConfigurationPtr conf)
-{
- BMscPtr bmsc = ref_node->get_bmsc();
-
- if(bmsc == NULL)
- {
- throw std::runtime_error("Unexpected behaviour.");
- return;
- }
-
- c->add_checked_conf(bmsc->get_label(), conf);
-}
-
-/*
* Tries finding bMSC in bMSC
*
* bmsc - where the bmsc_f is looking for
@@ -1031,6 +1007,24 @@
*/
bool check_node(MembershipContext* c, ReferenceNodePtr node, enum check_type type, ConfigurationPtr conf)
{
+ //in case membership checking mod, the algorithm checks whether the reference node have already
+ //been checked with the same flow configuration.
+ if(type == membership)
+ {
+ std::set<ConfigurationPtr> checked_configs = c->find_checked_conf(node);
+ std::set<ConfigurationPtr>::iterator checked_conf_it;
+
+ for(checked_conf_it = checked_configs.begin(); checked_conf_it != checked_configs.end(); checked_conf_it++)
+ {
+ if(conf->compare(*checked_conf_it))
+ return false;
+ }
+
+ //add this configuration among checked configurations
+ ConfigurationPtr old_conf = new Configuration(conf);
+ c->add_checked_conf(node, old_conf);
+ }
+
//get msc from the node
ConfigurationPtr old_conf = new Configuration(conf);
c->set_processed_ref_node(node);
@@ -1083,10 +1077,7 @@
continue; //remember position and continue in cycle
if (!check_instance(c, node_instance, type, *position_it))
- {
- add_checked_branch(c, node, old_conf);
return false;
- }
}
return true;
Modified: trunk/src/membership/membership_base.h
===================================================================
--- trunk/src/membership/membership_base.h 2011-08-11 14:09:08 UTC (rev 1179)
+++ trunk/src/membership/membership_base.h 2011-08-11 14:37:48 UTC (rev 1180)
@@ -264,7 +264,7 @@
std::vector<std::wstring> focused_instances; //! name of instances on which a user is focused on
std::map<CoregionAreaPtr, SnapshotContextPtr> snapshots; //! snapshots of context for each coregion
std::vector<Event*> attributed_events; //! events with attribute
- std::map<std::wstring, std::set<ConfigurationPtr> > checked_conf; //! map of bmsc names and configurations which were checked
+ std::map<ReferenceNodePtr, std::set<ConfigurationPtr> > checked_conf; //! map of reference nodes and configurations which were checked
std::map<TimeRelationRefNodePtr, ConfigurationPtr> top_time_references; //! the start of time interval is connected on top
std::map<TimeRelationRefNodePtr, ConfigurationPtr> bottom_time_references; //! the start of time interval is connected on bottom
std::map<CoregionAreaPtr, std::vector<CoregionOrderingPtr> > checked_orderings; //! checked possibilities of coregion ordering
@@ -419,14 +419,14 @@
attributed_events.clear();
}
- const std::set<ConfigurationPtr> find_checked_conf(std::wstring name)
+ const std::set<ConfigurationPtr> find_checked_conf(ReferenceNodePtr ref_node)
{
- return checked_conf[name];
+ return checked_conf[ref_node];
}
- void add_checked_conf(std::wstring name, ConfigurationPtr conf)
+ void add_checked_conf(ReferenceNodePtr ref_node, ConfigurationPtr conf)
{
- checked_conf[name].insert(conf);
+ checked_conf[ref_node].insert(conf);
}
void add_top_time_ref(TimeRelationRefNodePtr rel, ConfigurationPtr conf)
@@ -877,13 +877,9 @@
if(events.size() != a->get_events().size()) return false;
std::vector<Event*>::iterator it;
- Event* b;
-
for(it=events.begin(); it!=events.end(); it++)
{
- b = a->find_event(*it);
-
- if(b == NULL || !this->compare_events(*it, b))
+ if(a->find_event(*it) == NULL)
return false;
}
Modified: trunk/tests/membership/CMakeLists.txt
===================================================================
--- trunk/tests/membership/CMakeLists.txt 2011-08-11 14:09:08 UTC (rev 1179)
+++ trunk/tests/membership/CMakeLists.txt 2011-08-11 14:37:48 UTC (rev 1180)
@@ -111,7 +111,8 @@
ADD_MEMBER_TEST(cycle_neg_hmsc.mpr cycle_neg_pat.mpr 0)
ADD_MEMBER_TEST(cycle_pos_hmsc.mpr cycle_pos_pat.mpr 1)
ADD_MEMBER_TEST(cycleWithEmpty_pos_hmsc.mpr cycleWithEmpty_pos_pat.mpr 1)
-ADD_MEMBER_TEST(empty_pos_hmsc.mpr empty_pos_pat.mpr 0)
+ADD_MEMBER_TEST(empty_pos_hmsc.mpr empty_pos_pat.mpr 1)
+ADD_MEMBER_TEST(empty_neg_hmsc.mpr empty_neg_pat.mpr 0)
ADD_MEMBER_TEST(hard_neg_hmsc.mpr hard_neg_pat.mpr 0)
ADD_MEMBER_TEST(hard_pos_hmsc.mpr hard_pos_pat.mpr 1)
Added: trunk/tests/membership/empty_neg_pat.mpr.result
===================================================================
--- trunk/tests/membership/empty_neg_pat.mpr.result (rev 0)
+++ trunk/tests/membership/empty_neg_pat.mpr.result 2011-08-11 14:37:48 UTC (rev 1180)
@@ -0,0 +1 @@
+Flow "Page_1" not found.
Modified: trunk/tests/membership/empty_pos_pat.mpr
===================================================================
--- trunk/tests/membership/empty_pos_pat.mpr 2011-08-11 14:09:08 UTC (rev 1179)
+++ trunk/tests/membership/empty_pos_pat.mpr 2011-08-11 14:37:48 UTC (rev 1180)
@@ -1,5 +1,5 @@
mscdocument empty_pos_pat.vsd;
-msc Page-1;
+msc Page1;
inst p;
inst q;
p: instance;
Added: trunk/tests/membership/empty_pos_pat.mpr.result
===================================================================
--- trunk/tests/membership/empty_pos_pat.mpr.result (rev 0)
+++ trunk/tests/membership/empty_pos_pat.mpr.result 2011-08-11 14:37:48 UTC (rev 1180)
@@ -0,0 +1,109 @@
+Flow "Page1" found.
+Diagram with found flow highlighted.
+mscdocument empty_pos_hmsc;
+msc Page_1;
+/* PATH */
+initial connect/* PATH */
+ L0;
+/* PATH */
+/* ATTRIBUTES: [membership_counter 2] */
+L0: reference bMSC1/* PATH */
+/* PATH */
+ connect/* PATH */
+ L0,/* PATH */
+ L1, L2, L3;
+/* PATH */
+/* ATTRIBUTES: [membership_counter 1] */
+L1: reference empty1/* PATH */
+ connect L4,/* PATH */
+ L5;
+L2: reference bMSC2 connect L1;
+L3: reference bMSC3 connect L5;
+L4: reference empty2 connect L6;
+/* PATH */
+/* ATTRIBUTES: [membership_counter 1] */
+L5: reference empty4/* PATH */
+ connect L5,/* PATH */
+ L7;
+L6: reference empty3 connect L1;
+/* PATH */
+/* ATTRIBUTES: [membership_counter 1] */
+L7: reference bMSC4/* PATH */
+ connect/* PATH */
+ L8;
+/* PATH */
+L8: final/* PATH */
+;
+endmsc;
+msc bMSC1;
+inst p;
+inst q;
+p: instance;
+out a,0 to q;
+endinstance;
+q: instance;
+in a,0 from p;
+endinstance;
+endmsc;
+msc empty1;
+inst p;
+inst q;
+p: instance;
+endinstance;
+q: instance;
+endinstance;
+endmsc;
+msc bMSC2;
+inst p;
+inst q;
+p: instance;
+out a,0 to q;
+endinstance;
+q: instance;
+in a,0 from p;
+endinstance;
+endmsc;
+msc bMSC3;
+inst p;
+inst q;
+p: instance;
+out a,0 to q;
+endinstance;
+q: instance;
+in a,0 from p;
+endinstance;
+endmsc;
+msc empty2;
+inst p;
+inst q;
+p: instance;
+endinstance;
+q: instance;
+endinstance;
+endmsc;
+msc empty4;
+inst p;
+inst q;
+p: instance;
+endinstance;
+q: instance;
+endinstance;
+endmsc;
+msc empty3;
+inst p;
+inst q;
+p: instance;
+endinstance;
+q: instance;
+endinstance;
+endmsc;
+msc bMSC4;
+inst p;
+inst q;
+p: instance;
+in b,0 from q;
+endinstance;
+q: instance;
+out b,0 to p;
+endinstance;
+endmsc;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ma...@us...> - 2011-08-11 16:59:28
|
Revision: 1181
http://scstudio.svn.sourceforge.net/scstudio/?rev=1181&view=rev
Author: madzin
Date: 2011-08-11 16:59:22 +0000 (Thu, 11 Aug 2011)
Log Message:
-----------
Add test results and modify diff script to support Partial Find Flow algorithm.
Modified Paths:
--------------
trunk/src/membership/membership_alg.cpp
trunk/tests/CMakeLists.txt
trunk/tests/membership/CMakeLists.txt
trunk/tests/membership/membership_diff.py
trunk/tests/membership/partial_mem_easy_pat2.mpr.result
Added Paths:
-----------
trunk/tests/membership/partial_mem_easy_pat1.mpr.result
trunk/tests/membership/partial_mem_easy_pat3.mpr.result
trunk/tests/membership/partial_mem_easy_pat4.mpr.result
trunk/tests/membership/time_hard_bmsc_pat03.mpr.result
trunk/tests/membership/time_hard_bmsc_pat05.mpr.result
Modified: trunk/src/membership/membership_alg.cpp
===================================================================
--- trunk/src/membership/membership_alg.cpp 2011-08-11 14:37:48 UTC (rev 1180)
+++ trunk/src/membership/membership_alg.cpp 2011-08-11 16:59:22 UTC (rev 1181)
@@ -59,7 +59,16 @@
c->set_bmsc(bmsc_f);
c->set_result_messages(messages);
MscPtr result = NULL;
+ std::wstring focused_instance_names = L"";
+ for(unsigned int i = 0; i < instances.size(); i++)
+ {
+ if(i != 0)
+ focused_instance_names += L", ";
+
+ focused_instance_names += instances[i];
+ }
+
//the specification is HMSC
if (hmsc != NULL)
{
@@ -67,7 +76,14 @@
if(result == NULL)
{
- print_report(RS_ERROR, L"Flow \"" + bmsc->get_label() + L"\" not found.");
+ if(!instances.empty())
+ {
+ std::wstring msg = L"Flow \"" + bmsc->get_label() + L"\" not found on instances: ";
+ print_report(RS_ERROR, stringize() << msg << focused_instance_names << ".");
+ }
+ else
+ print_report(RS_ERROR, L"Flow \"" + bmsc->get_label() + L"\" not found.");
+
delete c;
return NULL;
}
@@ -100,9 +116,14 @@
return NULL;
}
- std::wstring msg = L"Flow \"" + bmsc->get_label() + L"\" found.";
+ std::wstring msg = L"Flow \"" + bmsc->get_label() + L"\" found";
std::vector<MscPtr> result_vec;
+ if(!instances.empty())
+ msg += L" on instances: " + focused_instance_names;
+
+ msg += L".";
+
messages.push_back(std::make_pair(msg, result_vec));
delete c;
@@ -122,18 +143,8 @@
{
if(!instances.empty())
{
- std::wstring instances_name;
+ print_report(RS_ERROR, L"Flow \"" + bmsc_f->get_label() + L"\" not found on instances: " + focused_instance_names);
- for(unsigned int i = 0; i < instances.size(); i++)
- {
- if(i != 0)
- instances_name += L",";
-
- instances_name += instances[i];
- }
-
- print_report(RS_ERROR, L"Flow \"" + bmsc_f->get_label() + L"\" found on instances:" + instances_name);
-
delete c;
return NULL;
}
@@ -185,8 +196,16 @@
return NULL;
}
- print_report(RS_NOTICE, L"Flow \"" + bmsc_f->get_label() + L"\" found.");
+ std::wstring msg = L"Flow \"" + bmsc_f->get_label() + L"\" found";
+
+ if(!instances.empty())
+ msg += L" on instances: " + focused_instance_names;
+
+ msg += L".";
+
+ print_report(RS_NOTICE, msg);
+
delete c;
return NULL;
}
Modified: trunk/tests/CMakeLists.txt
===================================================================
--- trunk/tests/CMakeLists.txt 2011-08-11 14:37:48 UTC (rev 1180)
+++ trunk/tests/CMakeLists.txt 2011-08-11 16:59:22 UTC (rev 1181)
@@ -112,7 +112,7 @@
ADD_SUBDIRECTORY(z120_test)
-SET(MEMBER_SEQUENCE 0)
+SET(MEMBER_SEQUENCE 6)
MACRO(ADD_MEMBER_TEST FILE1 FILE2 SATISFIED)
GET_TARGET_PROPERTY(MEMBER_TEST_EXECUTABLE membership_test LOCATION)
# Replace the "$(IntDir)", "$(OutDir)", or "$(CONFIGURATION)"
Modified: trunk/tests/membership/CMakeLists.txt
===================================================================
--- trunk/tests/membership/CMakeLists.txt 2011-08-11 14:37:48 UTC (rev 1180)
+++ trunk/tests/membership/CMakeLists.txt 2011-08-11 16:59:22 UTC (rev 1181)
@@ -21,6 +21,37 @@
#STRING(REGEX REPLACE "\\$\\(.*\\)" "\${CTEST_CONFIGURATION_TYPE}"
# MEMBERSHIP_TEST_EXECUTABLE "")
+#partial membership
+ADD_TEST("membership_test-0-partial_mem_easy_pat1.mpr"
+ ${PYTHON_EXECUTABLE} "${CMAKE_SOURCE_DIR}/tests/membership/membership_diff.py"
+ "./membership_test" "${CMAKE_CURRENT_SOURCE_DIR}/partial_mem_easy.mpr"
+ "${CMAKE_CURRENT_SOURCE_DIR}/partial_mem_easy_pat1.mpr" 1 "A")
+
+ADD_TEST("membership_test-1-partial_mem_easy_pat2.mpr"
+ ${PYTHON_EXECUTABLE} "${CMAKE_SOURCE_DIR}/tests/membership/membership_diff.py"
+ "./membership_test" "${CMAKE_CURRENT_SOURCE_DIR}/partial_mem_easy.mpr"
+ "${CMAKE_CURRENT_SOURCE_DIR}/partial_mem_easy_pat2.mpr" 0 "A" "B")
+
+ADD_TEST("membership_test-2-partial_mem_easy_pat3.mpr"
+ ${PYTHON_EXECUTABLE} "${CMAKE_SOURCE_DIR}/tests/membership/membership_diff.py"
+ "./membership_test" "${CMAKE_CURRENT_SOURCE_DIR}/partial_mem_easy.mpr"
+ "${CMAKE_CURRENT_SOURCE_DIR}/partial_mem_easy_pat3.mpr" 1 "A" "B")
+
+ADD_TEST("membership_test-3-partial_mem_easy_pat4.mpr"
+ ${PYTHON_EXECUTABLE} "${CMAKE_SOURCE_DIR}/tests/membership/membership_diff.py"
+ "./membership_test" "${CMAKE_CURRENT_SOURCE_DIR}/partial_mem_easy.mpr"
+ "${CMAKE_CURRENT_SOURCE_DIR}/partial_mem_easy_pat4.mpr" 1 "A" "B" "C")
+
+ADD_TEST("membership_test-4-complete_partial_pat1.mpr"
+ ${PYTHON_EXECUTABLE} "${CMAKE_SOURCE_DIR}/tests/membership/membership_diff.py"
+ "./membership_test" "${CMAKE_CURRENT_SOURCE_DIR}/complete.mpr"
+ "${CMAKE_CURRENT_SOURCE_DIR}/complete_partial_pat1.mpr" 1 "PC")
+
+ADD_TEST("membership_test-5-complete_partial_pat2.mpr"
+ ${PYTHON_EXECUTABLE} "${CMAKE_SOURCE_DIR}/tests/membership/membership_diff.py"
+ "./membership_test" "${CMAKE_CURRENT_SOURCE_DIR}/complete.mpr"
+ "${CMAKE_CURRENT_SOURCE_DIR}/complete_partial_pat2.mpr" 1 "PC" "Router" "Server")
+
ADD_MEMBER_TEST(test_hmsc01.mpr test_bmsc01.mpr 1)
ADD_MEMBER_TEST(test_hmsc02.mpr test_bmsc02.mpr 0)
ADD_MEMBER_TEST(test_hmsc03.mpr test_bmsc03.mpr 1)
@@ -138,9 +169,9 @@
ADD_MEMBER_TEST(test_hmsc31.mpr test_bmsc31_1.mpr 1)
ADD_MEMBER_TEST(time_hard_bmsc01.mpr time_hard_bmsc_pat01.mpr 1)
ADD_MEMBER_TEST(time_hard_bmsc02.mpr time_hard_bmsc_pat02.mpr 1) # + warning
-ADD_MEMBER_TEST(time_hard_bmsc03.mpr time_hard_bmsc_pat03.mpr 0)
+ADD_MEMBER_TEST(time_hard_bmsc03.mpr time_hard_bmsc_pat03.mpr 1) # + warning
ADD_MEMBER_TEST(time_hard_bmsc04.mpr time_hard_bmsc_pat04.mpr 1) # + warning
-ADD_MEMBER_TEST(time_hard_bmsc05.mpr time_hard_bmsc_pat05.mpr 0)
+ADD_MEMBER_TEST(time_hard_bmsc05.mpr time_hard_bmsc_pat05.mpr 1) # + warning
#coregion minimal
ADD_MEMBER_TEST(coregion_minimal.mpr coregion_minimal_pat1.mpr 0)
@@ -152,20 +183,11 @@
ADD_MEMBER_TEST(coregion_minimal.mpr coregion_minimal_pat7.mpr 1)
ADD_MEMBER_TEST(coregion_minimal.mpr coregion_minimal_pat8.mpr 1)
-#partial membership
-ADD_MEMBER_TEST(partial_mem_easy.mpr partial_mem_easy_pat1.mpr 1 A)
-ADD_MEMBER_TEST(partial_mem_easy.mpr partial_mem_easy_pat2.mpr 0 A B)
-ADD_MEMBER_TEST(partial_mem_easy.mpr partial_mem_easy_pat3.mpr 1 A B)
-ADD_MEMBER_TEST(partial_mem_easy.mpr partial_mem_easy_pat4.mpr 1 A B C)
-
-
ADD_MEMBER_TEST(complete.mpr complete_pat1.mpr 0)
ADD_MEMBER_TEST(complete.mpr complete_pat2.mpr 0)
ADD_MEMBER_TEST(complete.mpr complete_pat4.mpr 1)
ADD_MEMBER_TEST(complete.mpr complete_pat5.mpr 1)
ADD_MEMBER_TEST(complete1.mpr complete_pat3.mpr 1)
-ADD_MEMBER_TEST(complete.mpr complete_partial_pat1.mpr 1 PC)
-ADD_MEMBER_TEST(complete.mpr complete_partial_pat2.mpr 1 PC Router Server)
#complete.mpr separeted into small pieces
Modified: trunk/tests/membership/membership_diff.py
===================================================================
--- trunk/tests/membership/membership_diff.py 2011-08-11 14:37:48 UTC (rev 1180)
+++ trunk/tests/membership/membership_diff.py 2011-08-11 16:59:22 UTC (rev 1181)
@@ -4,7 +4,7 @@
import sys
import glob
-p = subprocess.Popen([sys.argv[1], sys.argv[2], sys.argv[3], sys.argv[4]], stdout=subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=True)
+p = subprocess.Popen(sys.argv[1:], stdout=subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=True)
output = p.stderr.readlines() + p.stdout.readlines()
# print the output as it may contain valgrind error reports
Added: trunk/tests/membership/partial_mem_easy_pat1.mpr.result
===================================================================
--- trunk/tests/membership/partial_mem_easy_pat1.mpr.result (rev 0)
+++ trunk/tests/membership/partial_mem_easy_pat1.mpr.result 2011-08-11 16:59:22 UTC (rev 1181)
@@ -0,0 +1 @@
+Flow "Page_1" found on instances: A.
Modified: trunk/tests/membership/partial_mem_easy_pat2.mpr.result
===================================================================
--- trunk/tests/membership/partial_mem_easy_pat2.mpr.result 2011-08-11 14:37:48 UTC (rev 1180)
+++ trunk/tests/membership/partial_mem_easy_pat2.mpr.result 2011-08-11 16:59:22 UTC (rev 1181)
@@ -1 +1 @@
-Flow "Page_1" found on instances:A,B
+Flow "Page_1" not found on instances: A, B
Added: trunk/tests/membership/partial_mem_easy_pat3.mpr.result
===================================================================
--- trunk/tests/membership/partial_mem_easy_pat3.mpr.result (rev 0)
+++ trunk/tests/membership/partial_mem_easy_pat3.mpr.result 2011-08-11 16:59:22 UTC (rev 1181)
@@ -0,0 +1 @@
+Flow "Page_1" found on instances: A, B.
Added: trunk/tests/membership/partial_mem_easy_pat4.mpr.result
===================================================================
--- trunk/tests/membership/partial_mem_easy_pat4.mpr.result (rev 0)
+++ trunk/tests/membership/partial_mem_easy_pat4.mpr.result 2011-08-11 16:59:22 UTC (rev 1181)
@@ -0,0 +1 @@
+Flow "Page_1" found on instances: A, B, C.
Added: trunk/tests/membership/time_hard_bmsc_pat03.mpr.result
===================================================================
--- trunk/tests/membership/time_hard_bmsc_pat03.mpr.result (rev 0)
+++ trunk/tests/membership/time_hard_bmsc_pat03.mpr.result 2011-08-11 16:59:22 UTC (rev 1181)
@@ -0,0 +1,20 @@
+Flow "Page_1" not found. Unsatisfied time constraint(s) (red intervals are not satisfied, blue intervals are partialy satisfied):
+mscdocument time_hard_bmsc03;
+msc Page_1;
+inst A;
+inst B;
+A: instance;
+in NAME,0 from B;
+out NAME,1 to B;
+label e0;
+in NAME,2 from B;
+endinstance;
+B: instance;
+label e1;
+out NAME,0 to A;
+time/* NOT_COVER */
+ e0 [0,2);
+in NAME,1 from A;
+out NAME,2 to A;
+endinstance;
+endmsc;
Added: trunk/tests/membership/time_hard_bmsc_pat05.mpr.result
===================================================================
--- trunk/tests/membership/time_hard_bmsc_pat05.mpr.result (rev 0)
+++ trunk/tests/membership/time_hard_bmsc_pat05.mpr.result 2011-08-11 16:59:22 UTC (rev 1181)
@@ -0,0 +1,23 @@
+Flow "Page_1" not found. Unsatisfied time constraint(s) (red intervals are not satisfied, blue intervals are partialy satisfied):
+mscdocument time_hard_bmsc05;
+msc Page_1;
+inst A;
+inst B;
+inst C;
+A: instance;
+in NAME,0 from B;
+in NAME,1 from B;
+endinstance;
+B: instance;
+label e0;
+out NAME,0 to A;
+time/* NOT_COVER */
+ e1 [1];
+out NAME,1 to A;
+out NAME,2 to C;
+endinstance;
+C: instance;
+label e1;
+in NAME,2 from B;
+endinstance;
+endmsc;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ma...@us...> - 2011-08-16 17:39:57
|
Revision: 1183
http://scstudio.svn.sourceforge.net/scstudio/?rev=1183&view=rev
Author: madzin
Date: 2011-08-16 17:39:51 +0000 (Tue, 16 Aug 2011)
Log Message:
-----------
Add test results, change error messages and patch possible segmentation fault
Modified Paths:
--------------
trunk/src/membership/membership_alg.cpp
trunk/src/membership/membership_base.h
trunk/src/membership/membership_time.cpp
trunk/tests/membership/CMakeLists.txt
Added Paths:
-----------
trunk/tests/membership/bmsc_spec4_pat.mpr.result
trunk/tests/membership/bmsc_spec5_pat.mpr.result
trunk/tests/membership/coregion_absolute_pat1.mpr.result
trunk/tests/membership/coregion_absolute_pat2.mpr.result
trunk/tests/membership/coregion_absolute_pat3.mpr.result
trunk/tests/membership/coregion_absolute_pat4.mpr.result
trunk/tests/membership/coregion_absolute_pat5.mpr.result
Modified: trunk/src/membership/membership_alg.cpp
===================================================================
--- trunk/src/membership/membership_alg.cpp 2011-08-16 16:59:19 UTC (rev 1182)
+++ trunk/src/membership/membership_alg.cpp 2011-08-16 17:39:51 UTC (rev 1183)
@@ -515,7 +515,7 @@
bool strict_coregion(MembershipContext* c, StrictOrderAreaPtr node_strict, std::vector<Event*>& node_events,
CoregionAreaPtr b_coregion, std::vector<Event*>& b_events)
{
- c->get_mem()->print_report(RS_ERROR, L"unsuported function: Flow cannot contain coregion.");
+ c->get_mem()->print_report(RS_ERROR, L"Error: Unsuported function (flow cannot contain coregion).");
return false;
}
Modified: trunk/src/membership/membership_base.h
===================================================================
--- trunk/src/membership/membership_base.h 2011-08-16 16:59:19 UTC (rev 1182)
+++ trunk/src/membership/membership_base.h 2011-08-16 17:39:51 UTC (rev 1183)
@@ -43,7 +43,7 @@
enum check_type {membership, receive_ordering};
enum TopBottom {top, bottom};
enum DiffType {NOT_DIFF, MESSAGE, ATTRIBUTE};
-enum checkingTimeMode{NO_TIME, RELATIVE_TIME, ABSOLUTE_TIME};
+enum checkingTimeMode{NO_TIME, RELATIVE_TIME, ABSOLUTE_TIME, RELATIVE_ABSOLUTE_TIME};
typedef boost::intrusive_ptr<Position> PositionPtr;
typedef boost::intrusive_ptr<Configuration> ConfigurationPtr;
@@ -156,6 +156,7 @@
public:
MembershipAbsoluteTime(AbsoluteTimePtr abs, HMscNodePtr ref_node)
+
{
this->abs = abs;
this->ref_node = ref_node;
@@ -571,6 +572,11 @@
return result;
}
+ /*
+ * parameters: e - event in the flow diagram
+ * list - list of time relations connected to event in the specification
+ * node_e - event from the specification to which time relations of list are connected.
+ */
void add_relative_time(Event* e, TimeRelationEventPtrList list, Event* node_e)
{
std::map<TimeRelationEventPtr, std::vector<MembershipTimeRelationPtr> >::iterator map_it;
@@ -646,7 +652,7 @@
}
}
- std::stack<std::map<TimeRelationEventPtr, std::vector<MembershipTimeRelationPtr> > >get_relative_time()
+ std::stack<std::map<TimeRelationEventPtr, std::vector<MembershipTimeRelationPtr> > > get_relative_time()
{
return relative_time;
}
Modified: trunk/src/membership/membership_time.cpp
===================================================================
--- trunk/src/membership/membership_time.cpp 2011-08-16 16:59:19 UTC (rev 1182)
+++ trunk/src/membership/membership_time.cpp 2011-08-16 17:39:51 UTC (rev 1183)
@@ -65,6 +65,7 @@
std::map<Event*, MembershipAbsoluteTimePtrList> absolute_time;
std::set<MembershipTimeRelationPtr> ref_node_time;
+ //time constraints from specification which has to be satisfied
relative_time = merge_relative_time_constraints(c);
absolute_time = merge_absolute_time_constraints(c);
ref_node_time = merge_ref_node_time_constraints(c);
@@ -250,6 +251,12 @@
AbsoluteTimePtr start_abs = *(start_e->get_absolut_times().begin());
AbsoluteTimePtr end_abs = *(end_e->get_absolut_times().begin());
+ if(start_abs == NULL || end_abs == NULL)
+ {
+ c->get_mem()->print_report(RS_ERROR, L"Error: Not able to check absolute time constraints (some flow event does not have absolute time constraint).");
+ c->add_not_covered_interval((*relative_it)->get_original_rel(), (*relative_it)->get_ref_node());
+ }
+
MscTimeIntervalSetD start_i = start_abs->get_interval_set();
MscTimeIntervalSetD end_i = end_abs->get_interval_set();
@@ -506,14 +513,19 @@
case NO_TIME: if(absolute_time.size() == 0 && relative_time.size() == 0 && ref_node_time.size() == 0)
return true;
else
- {
- //TODO
- std::cerr << "Nieco nie je pokryte" << std::endl;
- return false;
- }
+ //TODO refactoring, it could be done with better complexity
+ //absolute is not able to be run because no absolute constraints are in the flow
+ //and all time intervals in the flow are (-inf, inf), in this case check_time_method
+ //mark any time constraint from the specification which is not (-inf, inf).
+ return check_time_relative_mode(c, relative_time, absolute_time, ref_node_time);
case ABSOLUTE_TIME: return check_time_absolute_mode(c, relative_time, absolute_time, ref_node_time);
case RELATIVE_TIME: return check_time_relative_mode(c, relative_time, absolute_time, ref_node_time);
+
+ case RELATIVE_ABSOLUTE_TIME:
+ c->get_mem()->print_report(RS_ERROR, L"Error: Unable to check time constraints (flow contains relative and absolute time constraints).");
+ return true;
+
default: throw std::runtime_error("Error: Internal error 01");
}
}
@@ -860,13 +872,16 @@
if(node_e->get_time_relations().size() > 0)
c->add_relative_time(b_e, node_e->get_time_relations(), node_e);
+ //set the type of recognized time constraints in flow
+ if(c->get_checking_time_mode() == RELATIVE_ABSOLUTE_TIME)
+ return ;
+
if(b_e->get_absolut_times().size() > 0)
{
if(c->get_checking_time_mode() != RELATIVE_TIME)
c->set_checking_time_mode(ABSOLUTE_TIME);
else
- //TODO
- std::cerr << "Error: both absolute and relative time constraints were used" << std::endl;
+ c->set_checking_time_mode(RELATIVE_ABSOLUTE_TIME);
}
if(b_e->get_time_relations().size() > 0)
@@ -874,8 +889,7 @@
if(c->get_checking_time_mode() != ABSOLUTE_TIME)
c->set_checking_time_mode(RELATIVE_TIME);
else
- //TODO
- std::cerr << "Error: both absolute and relative time constraints were used" << std::endl;
+ c->set_checking_time_mode(RELATIVE_ABSOLUTE_TIME);
}
}
Modified: trunk/tests/membership/CMakeLists.txt
===================================================================
--- trunk/tests/membership/CMakeLists.txt 2011-08-16 16:59:19 UTC (rev 1182)
+++ trunk/tests/membership/CMakeLists.txt 2011-08-16 17:39:51 UTC (rev 1183)
@@ -234,8 +234,12 @@
ADD_MEMBER_TEST(bmsc_spec_absolute4.mpr bmsc_absolute_pat2_4.mpr 1)
ADD_MEMBER_TEST(bmsc_spec_absolute5.mpr bmsc_absolute_pat2_5.mpr 1)
-ADD_MEMBER_TEST(coregion_absolute.mpr coregion_absolute_part1.mpr 1)
-ADD_MEMBER_TEST(coregion_absolute.mpr coregion_absolute_part2.mpr 1)
-ADD_MEMBER_TEST(coregion_absolute.mpr coregion_absolute_part3.mpr 1)
-ADD_MEMBER_TEST(coregion_absolute.mpr coregion_absolute_part4.mpr 1)
-ADD_MEMBER_TEST(coregion_absolute.mpr coregion_absolute_part5.mpr 1)
+ADD_MEMBER_TEST(coregion_absolute.mpr coregion_absolute_pat1.mpr 1)
+ADD_MEMBER_TEST(coregion_absolute.mpr coregion_absolute_pat2.mpr 1)
+ADD_MEMBER_TEST(coregion_absolute.mpr coregion_absolute_pat3.mpr 1)
+ADD_MEMBER_TEST(coregion_absolute.mpr coregion_absolute_pat4.mpr 1)
+ADD_MEMBER_TEST(coregion_absolute.mpr coregion_absolute_pat5.mpr 1)
+
+ADD_MEMBER_TEST(bmsc_spec4.mpr bmsc_spec4_pat.mpr 1)
+ADD_MEMBER_TEST(bmsc_spec5.mpr bmsc_spec5_pat.mpr 1)
+
Added: trunk/tests/membership/bmsc_spec4_pat.mpr.result
===================================================================
--- trunk/tests/membership/bmsc_spec4_pat.mpr.result (rev 0)
+++ trunk/tests/membership/bmsc_spec4_pat.mpr.result 2011-08-16 17:39:51 UTC (rev 1183)
@@ -0,0 +1,25 @@
+Flow "Page_1 not found. Unsatisfied time constraint(s). Some interval(s) are only partialy satisfied:
+mscdocument bmsc_spec4;
+msc Page_1;
+inst PC;
+inst Router;
+inst Server;
+PC: instance;
+out c,0 to Router;
+endinstance;
+Router: instance;
+in c,0 from PC;
+label e0;
+out a,1 to Server;
+time/* NOT_FULL_COVER */
+ e1 [0,1];
+label e1;
+out b,2 to Server;
+in b,3 from Server;
+endinstance;
+Server: instance;
+in a,1 from Router;
+in b,2 from Router;
+out b,3 to Router;
+endinstance;
+endmsc;
Added: trunk/tests/membership/bmsc_spec5_pat.mpr.result
===================================================================
--- trunk/tests/membership/bmsc_spec5_pat.mpr.result (rev 0)
+++ trunk/tests/membership/bmsc_spec5_pat.mpr.result 2011-08-16 17:39:51 UTC (rev 1183)
@@ -0,0 +1 @@
+Flow "Page_1" found.
Added: trunk/tests/membership/coregion_absolute_pat1.mpr.result
===================================================================
--- trunk/tests/membership/coregion_absolute_pat1.mpr.result (rev 0)
+++ trunk/tests/membership/coregion_absolute_pat1.mpr.result 2011-08-16 17:39:51 UTC (rev 1183)
@@ -0,0 +1,2 @@
+Error: Unable to check time constraints (flow contains relative and absolute time constraints).
+Flow "Page_1" found.
Added: trunk/tests/membership/coregion_absolute_pat2.mpr.result
===================================================================
--- trunk/tests/membership/coregion_absolute_pat2.mpr.result (rev 0)
+++ trunk/tests/membership/coregion_absolute_pat2.mpr.result 2011-08-16 17:39:51 UTC (rev 1183)
@@ -0,0 +1,2 @@
+Error: Unable to check time constraints (flow contains relative and absolute time constraints).
+Flow "Page_1" found.
Added: trunk/tests/membership/coregion_absolute_pat3.mpr.result
===================================================================
--- trunk/tests/membership/coregion_absolute_pat3.mpr.result (rev 0)
+++ trunk/tests/membership/coregion_absolute_pat3.mpr.result 2011-08-16 17:39:51 UTC (rev 1183)
@@ -0,0 +1,2 @@
+Error: Unable to check time constraints (flow contains relative and absolute time constraints).
+Flow "Page_1" found.
Added: trunk/tests/membership/coregion_absolute_pat4.mpr.result
===================================================================
--- trunk/tests/membership/coregion_absolute_pat4.mpr.result (rev 0)
+++ trunk/tests/membership/coregion_absolute_pat4.mpr.result 2011-08-16 17:39:51 UTC (rev 1183)
@@ -0,0 +1,2 @@
+Error: Unable to check time constraints (flow contains relative and absolute time constraints).
+Flow "Page_1" found.
Added: trunk/tests/membership/coregion_absolute_pat5.mpr.result
===================================================================
--- trunk/tests/membership/coregion_absolute_pat5.mpr.result (rev 0)
+++ trunk/tests/membership/coregion_absolute_pat5.mpr.result 2011-08-16 17:39:51 UTC (rev 1183)
@@ -0,0 +1,2 @@
+Error: Unable to check time constraints (flow contains relative and absolute time constraints).
+Flow "Page_1" found.
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ma...@us...> - 2011-09-13 13:48:31
|
Revision: 1191
http://scstudio.svn.sourceforge.net/scstudio/?rev=1191&view=rev
Author: madzin
Date: 2011-09-13 13:48:20 +0000 (Tue, 13 Sep 2011)
Log Message:
-----------
Add prerequisity and add results of some tests.
Modified Paths:
--------------
trunk/src/membership/membership_alg.cpp
trunk/tests/membership/CMakeLists.txt
trunk/tests/membership/partial_mem_easy_pat1.mpr.result
trunk/tests/membership/partial_mem_easy_pat2.mpr.result
trunk/tests/membership/partial_mem_easy_pat3.mpr.result
trunk/tests/membership/partial_mem_easy_pat4.mpr.result
Added Paths:
-----------
trunk/tests/membership/complete_partial_pat1.mpr.result
trunk/tests/membership/complete_partial_pat2.mpr.result
trunk/tests/membership/rozcvicka_bmsc1.mpr
trunk/tests/membership/rozcvicka_bmsc1.mpr.result
trunk/tests/membership/rozcvicka_bmsc2.mpr.result
trunk/tests/membership/test_bmsc20_1.mpr.result
trunk/tests/membership/test_bmsc20_2.mpr.result
trunk/tests/membership/test_bmsc27_1.mpr.result
Removed Paths:
-------------
trunk/tests/membership/rozcvicka_bmsc.mpr
trunk/tests/membership/rozcvicka_bmsc.mpr.result
Modified: trunk/src/membership/membership_alg.cpp
===================================================================
--- trunk/src/membership/membership_alg.cpp 2011-09-13 11:05:06 UTC (rev 1190)
+++ trunk/src/membership/membership_alg.cpp 2011-09-13 13:48:20 UTC (rev 1191)
@@ -28,6 +28,7 @@
result.push_back(PrerequisiteCheck(L"Unique instance names", PrerequisiteCheck::PP_REQUIRED));
result.push_back(PrerequisiteCheck(L"Correct Time Constraint Syntax", PrerequisiteCheck::PP_REQUIRED));
result.push_back(PrerequisiteCheck(L"Time Consistent", PrerequisiteCheck::PP_REQUIRED));
+ result.push_back(PrerequisiteCheck(L"Acyclic", PrerequisiteCheck::PP_REQUIRED));
return result;
}
@@ -230,6 +231,9 @@
std::vector<MscPtr> msc_for_cover;
+ if(!instances.empty())
+ print_report(RS_WARNING, L"Find Flow algorithm in partial mode is not albe to check time constraints.");
+
for(unsigned int i = 0; i < bmscs.size(); i++)
{
temp = NULL;
Modified: trunk/tests/membership/CMakeLists.txt
===================================================================
--- trunk/tests/membership/CMakeLists.txt 2011-09-13 11:05:06 UTC (rev 1190)
+++ trunk/tests/membership/CMakeLists.txt 2011-09-13 13:48:20 UTC (rev 1191)
@@ -104,8 +104,8 @@
ADD_MEMBER_TEST(BMSCxBMSC4.mpr BMSCxBMSC4.mpr 1)
#rozcvicka
-ADD_MEMBER_TEST(rozcvicka_hmsc.mpr rozcvicka_bmsc.mpr 1)
-ADD_MEMBER_TEST(rozcvicka_long.mpr rozcvicka_bmsc.mpr 1)
+ADD_MEMBER_TEST(rozcvicka_hmsc.mpr rozcvicka_bmsc1.mpr 1)
+ADD_MEMBER_TEST(rozcvicka_long.mpr rozcvicka_bmsc2.mpr 1)
#test coregion ordering skontrolovat
ADD_MEMBER_TEST(test_hmsc20.mpr test_bmsc20_1.mpr 1)
Added: trunk/tests/membership/complete_partial_pat1.mpr.result
===================================================================
--- trunk/tests/membership/complete_partial_pat1.mpr.result (rev 0)
+++ trunk/tests/membership/complete_partial_pat1.mpr.result 2011-09-13 13:48:20 UTC (rev 1191)
@@ -0,0 +1,121 @@
+Find Flow algorithm in partial mode is not albe to check time constraints.
+Flow "Page_1" found on instances: PC.
+Diagram with found flow highlighted.
+mscdocument complete;
+msc Page_1;
+/* PATH */
+initial connect/* PATH */
+ L0;
+/* PATH */
+/* ATTRIBUTES: [membership_counter 1] */
+L0: reference A/* PATH */
+ connect/* PATH */
+ L1;
+/* PATH */
+L1:/* PATH */
+ connect L2,/* PATH */
+ L3;
+L2: reference C top bottom L4 [4,5];
+ bottom top L4 [2,3);
+ connect L4;
+/* PATH */
+/* ATTRIBUTES: [membership_counter 1] */
+L3: reference B time [1];
+/* PATH */
+ connect/* PATH */
+ L5;
+L4: reference D connect L5;
+/* PATH */
+L5:/* PATH */
+ connect/* PATH */
+ L6;
+/* PATH */
+L6: final/* PATH */
+;
+endmsc;
+msc A;
+inst PC;
+inst Router;
+inst Server;
+PC: instance;
+label e0;
+out c,0 to Router;
+time e1 [0,1);
+endinstance;
+Router: instance;
+concurrent;
+label e1;
+in c,0 from PC;
+label e2;
+out a,1 to Server before e3;
+time e3 [1,2];
+label e3;
+out b,2 to Server;
+endconcurrent;
+endinstance;
+Server: instance;
+in a,1 from Router;
+in b,2 from Router;
+endinstance;
+endmsc;
+msc C;
+inst PC;
+inst Router;
+inst Server;
+PC: instance;
+out a,0 to Router;
+out a,1 to Router;
+endinstance;
+Router: instance;
+in a,0 from PC;
+in b,2 from Server;
+in a,1 from PC;
+endinstance;
+Server: instance;
+out b,2 to Router;
+endinstance;
+endmsc;
+msc B;
+inst PC;
+inst Router;
+inst Server;
+PC: instance;
+in c,0 from Server;
+out b,1 to Router;
+endinstance;
+Router: instance;
+in c,2 from Server;
+in b,1 from PC;
+endinstance;
+Server: instance;
+concurrent;
+out c,2 to Router;
+out c,0 to PC;
+endconcurrent;
+endinstance;
+endmsc;
+msc D;
+inst PC;
+inst Router;
+inst Server;
+PC: instance;
+in b,0 from Router;
+out c,1 to Router;
+endinstance;
+Router: instance;
+concurrent;
+in a,2 from Server;
+in a,3 from Server;
+in b,4 from Server;
+out b,0 to PC;
+endconcurrent;
+in c,1 from PC;
+endinstance;
+Server: instance;
+concurrent;
+out a,2 to Router;
+out a,3 to Router;
+out b,4 to Router;
+endconcurrent;
+endinstance;
+endmsc;
Added: trunk/tests/membership/complete_partial_pat2.mpr.result
===================================================================
--- trunk/tests/membership/complete_partial_pat2.mpr.result (rev 0)
+++ trunk/tests/membership/complete_partial_pat2.mpr.result 2011-09-13 13:48:20 UTC (rev 1191)
@@ -0,0 +1,125 @@
+Find Flow algorithm in partial mode is not albe to check time constraints.
+Flow "Page_1" found on instances: PC, Router, Server.
+Diagram with found flow highlighted.
+mscdocument complete;
+msc Page_1;
+/* PATH */
+initial connect/* PATH */
+ L0;
+/* PATH */
+/* ATTRIBUTES: [membership_counter 1] */
+L0: reference A/* PATH */
+ connect/* PATH */
+ L1;
+/* PATH */
+L1:/* PATH */
+ connect/* PATH */
+ L2, L3;
+/* PATH */
+/* ATTRIBUTES: [membership_counter 1] */
+L2: reference C top bottom L4 [4,5];
+ bottom top L4 [2,3);
+/* PATH */
+ connect/* PATH */
+ L4;
+L3: reference B time [1];
+ connect L5;
+/* PATH */
+/* ATTRIBUTES: [membership_counter 1] */
+L4: reference D/* PATH */
+ connect/* PATH */
+ L5;
+/* PATH */
+L5:/* PATH */
+ connect/* PATH */
+ L6;
+/* PATH */
+L6: final/* PATH */
+;
+endmsc;
+msc A;
+inst PC;
+inst Router;
+inst Server;
+PC: instance;
+label e0;
+out c,0 to Router;
+time e1 [0,1);
+endinstance;
+Router: instance;
+concurrent;
+label e1;
+in c,0 from PC;
+label e2;
+out a,1 to Server before e3;
+time e3 [1,2];
+label e3;
+out b,2 to Server;
+endconcurrent;
+endinstance;
+Server: instance;
+in a,1 from Router;
+in b,2 from Router;
+endinstance;
+endmsc;
+msc C;
+inst PC;
+inst Router;
+inst Server;
+PC: instance;
+out a,0 to Router;
+out a,1 to Router;
+endinstance;
+Router: instance;
+in a,0 from PC;
+in b,2 from Server;
+in a,1 from PC;
+endinstance;
+Server: instance;
+out b,2 to Router;
+endinstance;
+endmsc;
+msc B;
+inst PC;
+inst Router;
+inst Server;
+PC: instance;
+in c,0 from Server;
+out b,1 to Router;
+endinstance;
+Router: instance;
+in c,2 from Server;
+in b,1 from PC;
+endinstance;
+Server: instance;
+concurrent;
+out c,2 to Router;
+out c,0 to PC;
+endconcurrent;
+endinstance;
+endmsc;
+msc D;
+inst PC;
+inst Router;
+inst Server;
+PC: instance;
+in b,0 from Router;
+out c,1 to Router;
+endinstance;
+Router: instance;
+concurrent;
+in a,2 from Server;
+in a,3 from Server;
+in b,4 from Server;
+out b,0 to PC;
+endconcurrent;
+in c,1 from PC;
+endinstance;
+Server: instance;
+concurrent;
+out a,2 to Router;
+out a,3 to Router;
+out b,4 to Router;
+endconcurrent;
+endinstance;
+endmsc;
Modified: trunk/tests/membership/partial_mem_easy_pat1.mpr.result
===================================================================
--- trunk/tests/membership/partial_mem_easy_pat1.mpr.result 2011-09-13 11:05:06 UTC (rev 1190)
+++ trunk/tests/membership/partial_mem_easy_pat1.mpr.result 2011-09-13 13:48:20 UTC (rev 1191)
@@ -1 +1,2 @@
+Find Flow algorithm in partial mode is not albe to check time constraints.
Flow "Page_1" found on instances: A.
Modified: trunk/tests/membership/partial_mem_easy_pat2.mpr.result
===================================================================
--- trunk/tests/membership/partial_mem_easy_pat2.mpr.result 2011-09-13 11:05:06 UTC (rev 1190)
+++ trunk/tests/membership/partial_mem_easy_pat2.mpr.result 2011-09-13 13:48:20 UTC (rev 1191)
@@ -1 +1,2 @@
+Find Flow algorithm in partial mode is not albe to check time constraints.
Flow "Page_1" not found on instances: A, B
Modified: trunk/tests/membership/partial_mem_easy_pat3.mpr.result
===================================================================
--- trunk/tests/membership/partial_mem_easy_pat3.mpr.result 2011-09-13 11:05:06 UTC (rev 1190)
+++ trunk/tests/membership/partial_mem_easy_pat3.mpr.result 2011-09-13 13:48:20 UTC (rev 1191)
@@ -1 +1,2 @@
+Find Flow algorithm in partial mode is not albe to check time constraints.
Flow "Page_1" found on instances: A, B.
Modified: trunk/tests/membership/partial_mem_easy_pat4.mpr.result
===================================================================
--- trunk/tests/membership/partial_mem_easy_pat4.mpr.result 2011-09-13 11:05:06 UTC (rev 1190)
+++ trunk/tests/membership/partial_mem_easy_pat4.mpr.result 2011-09-13 13:48:20 UTC (rev 1191)
@@ -1 +1,2 @@
+Find Flow algorithm in partial mode is not albe to check time constraints.
Flow "Page_1" found on instances: A, B, C.
Deleted: trunk/tests/membership/rozcvicka_bmsc.mpr
===================================================================
--- trunk/tests/membership/rozcvicka_bmsc.mpr 2011-09-13 11:05:06 UTC (rev 1190)
+++ trunk/tests/membership/rozcvicka_bmsc.mpr 2011-09-13 13:48:20 UTC (rev 1191)
@@ -1,24 +0,0 @@
-mscdocument Rozcvicka_bmsc;
-msc cele;
-inst Client;
-inst Proxy;
-inst Application_server;
-Client: instance;
-out Register,0 to Proxy;
-in Response,1 from Proxy;
-out Message,2 to Application_server;
-in Response,3 from Application_server;
-endinstance;
-Proxy: instance;
-in Register,0 from Client;
-out Response,1 to Client;
-out Register,4 to Application_server;
-in Response,5 from Application_server;
-endinstance;
-Application_server: instance;
-in Register,4 from Proxy;
-out Response,5 to Proxy;
-in Message,2 from Client;
-out Response,3 to Client;
-endinstance;
-endmsc;
Deleted: trunk/tests/membership/rozcvicka_bmsc.mpr.result
===================================================================
--- trunk/tests/membership/rozcvicka_bmsc.mpr.result 2011-09-13 11:05:06 UTC (rev 1190)
+++ trunk/tests/membership/rozcvicka_bmsc.mpr.result 2011-09-13 13:48:20 UTC (rev 1191)
@@ -1,55 +0,0 @@
-Flow "cele" found.
-Diagram with found flow highlighted.
-mscdocument rozcvicka_hmsc;
-msc HMSC;
-/* PATH */
-initial connect/* PATH */
- L0;
-/* PATH */
-/* ATTRIBUTES: [membership_counter 1] */
-L0: reference prvni/* PATH */
- connect/* PATH */
- L1;
-/* PATH */
-/* ATTRIBUTES: [membership_counter 1] */
-L1: reference druhy/* PATH */
- connect/* PATH */
- L2;
-/* PATH */
-L2: final/* PATH */
-;
-endmsc;
-msc prvni;
-inst Client;
-inst Proxy;
-inst Application_server;
-Client: instance;
-out Register,0 to Proxy;
-in Response,1 from Proxy;
-endinstance;
-Proxy: instance;
-in Register,0 from Client;
-out Response,1 to Client;
-endinstance;
-Application_server: instance;
-endinstance;
-endmsc;
-msc druhy;
-inst Client;
-inst Proxy;
-inst Application_server;
-Client: instance;
-out Message,0 to Application_server;
-in Response,1 from Application_server;
-endinstance;
-Proxy: instance;
-out Register,2 to Application_server;
-in Response,3 from Application_server;
-endinstance;
-Application_server: instance;
-in Register,2 from Proxy;
-out Response,3 to Proxy;
-in Message,0 from Client;
-out Response,1 to Client;
-endinstance;
-endmsc;
Added: trunk/tests/membership/rozcvicka_bmsc1.mpr
===================================================================
--- trunk/tests/membership/rozcvicka_bmsc1.mpr (rev 0)
+++ trunk/tests/membership/rozcvicka_bmsc1.mpr 2011-09-13 13:48:20 UTC (rev 1191)
@@ -0,0 +1,24 @@
+mscdocument Rozcvicka_bmsc;
+msc cele;
+inst Client;
+inst Proxy;
+inst Application_server;
+Client: instance;
+out Register,0 to Proxy;
+in Response,1 from Proxy;
+out Message,2 to Application_server;
+in Response,3 from Application_server;
+endinstance;
+Proxy: instance;
+in Register,0 from Client;
+out Response,1 to Client;
+out Register,4 to Application_server;
+in Response,5 from Application_server;
+endinstance;
+Application_server: instance;
+in Register,4 from Proxy;
+out Response,5 to Proxy;
+in Message,2 from Client;
+out Response,3 to Client;
+endinstance;
+endmsc;
Added: trunk/tests/membership/rozcvicka_bmsc1.mpr.result
===================================================================
--- trunk/tests/membership/rozcvicka_bmsc1.mpr.result (rev 0)
+++ trunk/tests/membership/rozcvicka_bmsc1.mpr.result 2011-09-13 13:48:20 UTC (rev 1191)
@@ -0,0 +1,55 @@
+Flow "cele" found.
+Diagram with found flow highlighted.
+mscdocument rozcvicka_hmsc;
+msc HMSC;
+/* PATH */
+initial connect/* PATH */
+ L0;
+/* PATH */
+/* ATTRIBUTES: [membership_counter 1] */
+L0: reference prvni/* PATH */
+ connect/* PATH */
+ L1;
+/* PATH */
+/* ATTRIBUTES: [membership_counter 1] */
+L1: reference druhy/* PATH */
+ connect/* PATH */
+ L2;
+/* PATH */
+L2: final/* PATH */
+;
+endmsc;
+msc prvni;
+inst Client;
+inst Proxy;
+inst Application_server;
+Client: instance;
+out Register,0 to Proxy;
+in Response,1 from Proxy;
+endinstance;
+Proxy: instance;
+in Register,0 from Client;
+out Response,1 to Client;
+endinstance;
+Application_server: instance;
+endinstance;
+endmsc;
+msc druhy;
+inst Client;
+inst Proxy;
+inst Application_server;
+Client: instance;
+out Message,0 to Application_server;
+in Response,1 from Application_server;
+endinstance;
+Proxy: instance;
+out Register,2 to Application_server;
+in Response,3 from Application_server;
+endinstance;
+Application_server: instance;
+in Register,2 from Proxy;
+out Response,3 to Proxy;
+in Message,0 from Client;
+out Response,1 to Client;
+endinstance;
+endmsc;
Added: trunk/tests/membership/rozcvicka_bmsc2.mpr.result
===================================================================
--- trunk/tests/membership/rozcvicka_bmsc2.mpr.result (rev 0)
+++ trunk/tests/membership/rozcvicka_bmsc2.mpr.result 2011-09-13 13:48:20 UTC (rev 1191)
@@ -0,0 +1,85 @@
+Flow "cele" found.
+Diagram with found flow highlighted.
+mscdocument rozcvicka_long;
+msc HMSC;
+/* PATH */
+initial connect/* PATH */
+ L0;
+/* PATH */
+L0:/* PATH */
+ connect L1,/* PATH */
+ L2;
+L1: reference Query_Error connect L0;
+/* PATH */
+/* ATTRIBUTES: [membership_counter 1] */
+L2: reference Client_registration/* PATH */
+ connect/* PATH */
+ L3;
+/* PATH */
+/* ATTRIBUTES: [membership_counter 1] */
+L3: reference Server_registration/* PATH */
+ connect/* PATH */
+ L4;
+/* PATH */
+L4:/* PATH */
+/* PATH */
+ connect/* PATH */
+ L5,/* PATH */
+ L6;
+/* PATH */
+/* ATTRIBUTES: [membership_counter 1] */
+L5: reference Query_OK/* PATH */
+ connect/* PATH */
+ L4;
+/* PATH */
+L6: final/* PATH */
+;
+endmsc;
+msc Query_Error;
+inst Client;
+inst Application_server;
+Client: instance;
+out Message,0 to Application_server;
+in NOK,1 from Application_server;
+endinstance;
+Application_server: instance;
+in Message,0 from Client;
+out NOK,1 to Client;
+endinstance;
+endmsc;
+msc Client_registration;
+inst Client;
+inst Proxy;
+Client: instance;
+out Register,0 to Proxy;
+in Response,1 from Proxy;
+endinstance;
+Proxy: instance;
+in Register,0 from Client;
+out Response,1 to Client;
+endinstance;
+endmsc;
+msc Server_registration;
+inst Application_server;
+inst Proxy;
+Application_server: instance;
+in Register,0 from Proxy;
+out Response,1 to Proxy;
+endinstance;
+Proxy: instance;
+out Register,0 to Application_server;
+in Response,1 from Application_server;
+endinstance;
+endmsc;
+msc Query_OK;
+inst Client;
+inst Application_server;
+Client: instance;
+out Message,0 to Application_server;
+in Response,1 from Application_server;
+endinstance;
+Application_server: instance;
+in Message,0 from Client;
+out Response,1 to Client;
+endinstance;
+endmsc;
Added: trunk/tests/membership/test_bmsc20_1.mpr.result
===================================================================
--- trunk/tests/membership/test_bmsc20_1.mpr.result (rev 0)
+++ trunk/tests/membership/test_bmsc20_1.mpr.result 2011-09-13 13:48:20 UTC (rev 1191)
@@ -0,0 +1,31 @@
+Flow "Test" found.
+Diagram with found flow highlighted.
+mscdocument test_hmsc20;
+msc Page_1;
+/* PATH */
+initial connect/* PATH */
+ L0;
+/* PATH */
+/* ATTRIBUTES: [membership_counter 1] */
+L0: reference Test/* PATH */
+ connect/* PATH */
+ L1;
+/* PATH */
+L1: final/* PATH */
+;
+endmsc;
+msc Test;
+inst A;
+inst B;
+A: instance;
+out a,0 to B;
+out a,1 to B;
+endinstance;
+B: instance;
+concurrent;
+in a,0 from A before e0;
+label e0;
+in a,1 from A;
+endconcurrent;
+endinstance;
+endmsc;
Added: trunk/tests/membership/test_bmsc20_2.mpr.result
===================================================================
--- trunk/tests/membership/test_bmsc20_2.mpr.result (rev 0)
+++ trunk/tests/membership/test_bmsc20_2.mpr.result 2011-09-13 13:48:20 UTC (rev 1191)
@@ -0,0 +1 @@
+Flow "Test" not found.
Added: trunk/tests/membership/test_bmsc27_1.mpr.result
===================================================================
--- trunk/tests/membership/test_bmsc27_1.mpr.result (rev 0)
+++ trunk/tests/membership/test_bmsc27_1.mpr.result 2011-09-13 13:48:20 UTC (rev 1191)
@@ -0,0 +1 @@
+Flow "Page_1" found.
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ma...@us...> - 2011-10-02 16:35:37
|
Revision: 1200
http://scstudio.svn.sourceforge.net/scstudio/?rev=1200&view=rev
Author: madzin
Date: 2011-10-02 16:35:29 +0000 (Sun, 02 Oct 2011)
Log Message:
-----------
Rewrite difference processing after diff algoritm. Modification is not complete (functionality is similar like in the old vertion).
Modified Paths:
--------------
trunk/src/membership/diff_impl.cpp
trunk/src/membership/diff_impl.h
trunk/src/membership/membership_additional.cpp
trunk/src/membership/membership_additional.h
trunk/src/membership/membership_alg.cpp
trunk/src/membership/membership_base.h
trunk/src/membership/membership_time.cpp
trunk/tests/diff/CMakeLists.txt
Added Paths:
-----------
trunk/tests/diff/flow10.mpr
trunk/tests/diff/spec10.mpr
Modified: trunk/src/membership/diff_impl.cpp
===================================================================
--- trunk/src/membership/diff_impl.cpp 2011-09-26 11:45:53 UTC (rev 1199)
+++ trunk/src/membership/diff_impl.cpp 2011-10-02 16:35:29 UTC (rev 1200)
@@ -24,7 +24,13 @@
const std::map<std::wstring, Difference*>& diff_map);
void diff_identification_settings(MembershipContext* c, const std::map<std::wstring, Difference*>& diff_map);
InstancePtr find_instance(BMscPtr bmsc, std::wstring name);
+void separate_diffrences(MembershipContext* c,
+ const std::map<std::wstring, Difference*>& diff_map,
+ std::map<std::wstring, std::list<Difference*> >& insert_map,
+ std::map<std::wstring, std::list<Difference*> >& remove_map);
+StrictEventPtr search_predecessors_successors(Difference* diff, StrictEvent* original_event);
+
void print_result(BMscPtr msc)
{
InstancePtrList insts = msc->get_instances();
@@ -347,6 +353,120 @@
throw std::runtime_error("Unexpected behaviour.");
}
+void diff_identification_preprocessing(MembershipContext* c,
+ std::map<std::wstring, Difference*>& diff_map)
+{
+ //diffrences which operation is add, separated by instances
+ std::map<std::wstring, std::list<Difference*> > insert_map;
+ //diffrences which operation is remove, separated by instances
+ std::map<std::wstring, std::list<Difference*> > remove_map;
+
+ separate_diffrences(c, diff_map, insert_map, remove_map);
+
+
+ std::map<std::wstring, std::list<Difference*> >::iterator map_it, matching_it;
+ std::set<Difference*>::iterator removes_it, discover;
+ std::set<Difference*> unmatched_differences;
+
+ for(map_it = remove_map.begin(); map_it != remove_map.end(); map_it++)
+ {
+ std::list<Difference*> remove_list = map_it->second;
+ std::list<Difference*>::iterator list_it;
+
+ for(list_it = remove_list.begin(); list_it != remove_list.end(); list_it++)
+ {
+ CompleteMessagePtr msg = boost::dynamic_pointer_cast<CompleteMessage> ((*list_it)->getMessage());
+
+ if(msg == NULL)
+ continue;
+ else
+ {
+ InstancePtr matching_inst;
+
+ if((*list_it)->getLocation()->is_send())
+ matching_inst = msg->get_receiver();
+ else
+ matching_inst = msg->get_sender();
+
+ //get diffrences of matching instance
+ matching_it = remove_map.find(matching_inst->get_label());
+
+ //for advanced remove diffrences matching is it irelevant, because when there is not matching difference it means that one event was on right place (remove_insert exmaple).
+ if(matching_it == remove_map.end())
+ continue;
+
+ std::list<Difference*>::reverse_iterator list_it_2;
+
+ for(list_it_2 = matching_it->second.rbegin(); list_it_2 != matching_it->second.rend(); list_it_2++)
+ {
+ if((*list_it_2)->getMessage() == msg)
+ break;
+ }
+
+ if(list_it_2 != matching_it->second.rend())
+ continue;
+ else
+ unmatched_differences.insert(*list_it);
+ }
+ }
+ }
+
+ //at this moment all candidates for advanced matching are in unmatched_differences
+
+ //copied from advanced matching
+ std::set<Difference*> matched_differences;
+ StrictEvent* original_event;
+ CompleteMessagePtr msg;
+
+std::wcerr << "unmatched size " << unmatched_differences.size() << std::endl;
+
+ for(removes_it = unmatched_differences.begin(); removes_it != unmatched_differences.end(); removes_it++)
+ {
+if(*removes_it == NULL)
+std::wcerr << "pici fakt NULL" << std::endl;
+
+ msg = boost::dynamic_pointer_cast<CompleteMessage> ((*removes_it)->getMessage());
+
+ if(msg == NULL)
+ throw std::runtime_error("Error: unexpected behaviour");
+
+ //get event which we are looking for among other diffrences and their neithbors
+ if((*removes_it)->getDirection() == SEND)
+ original_event = dynamic_cast<StrictEvent*> (msg->get_receive_event());
+ else
+ original_event = dynamic_cast<StrictEvent*> (msg->get_send_event());
+
+ for(discover = unmatched_differences.begin(); discover != unmatched_differences.end(); discover++)
+ {
+ //in case the difference has already been matched, go to a next difference
+ if(matched_differences.find(*discover) != matched_differences.end())
+ continue;
+
+ //in case it processed the same differences, go to a next difference
+ if(*discover == *removes_it)
+ continue;
+
+ if(compare_events(original_event, (*discover)->getLocation().get(), false))
+ {
+ //function returns bool value: true in case the proper event has been found
+ // false in case the proper event has not been found
+ StrictEventPtr new_location_1 = search_predecessors_successors(*discover, original_event);
+
+//TODO dorobit, ze ked to skusim z druhej strany. No a potom ak ani jeden z new_location nebude NULL tak alghoritmus si tipne ze ktory oznaci
+// StrictEventPtr new_location_2 = search_predecessors_successors();
+
+ if(new_location_1 != NULL)
+ {
+ (*discover)->setLocation(new_location_1);
+ matched_differences.insert(*removes_it);
+ matched_differences.insert(*discover);
+ }
+ }
+ }
+ }
+
+}
+
BMscPtr bmsc_bmsc_diff(MembershipContext* c, BMscPtr specification, BMscPtr flow)
{
BMscDuplicator duplicator;
@@ -488,14 +608,19 @@
}
if(i == 0)
+ {
+ diff_identification_preprocessing(c, diff_map);
diff_identification_settings(c, diff_map);
+ }
}
if(!diff_map.empty())
{
process_diffrences(c, dup_flow, diff_map);
- check_attributes(c, specification, dup_flow);
+//TODO skontrolovat to ci to odpoveda novemu konceptu
+//TODO uchovavat si zaznam o vsetkych vytvorenych spravach aby mohli byt spatne bezbolestne odobrate
+// check_attributes(c, specification, dup_flow);
c->clear_attributed_events();
return dup_flow;
@@ -685,14 +810,141 @@
return new_e;
}
-void process_diffrences(MembershipContext* c, BMscPtr dup_flow, const std::map<std::wstring, Difference*>& diff_map)
+CompleteMessagePtr create_complete_message(BMscPtr dup_flow, Difference* diff, Difference* matching_diff)
{
- std::map<std::wstring, std::list<Difference*> > insert_map;
- insert_map = create_insert_map(c, diff_map);
+ if(diff == NULL || matching_diff == NULL)
+ throw std::runtime_error("Error: unexpected behaviour");
+ std::wstring diff_instance, matching_instance;
+
+ //in case the location is NULL (can occure when it is the first event on the instance)
+ //algorithm uses other way to get instance name
+ if(diff->getLocation() != NULL)
+ diff_instance = diff->getLocation()->get_instance()->get_label();
+ else
+ {
+ CompleteMessagePtr msg = boost::dynamic_pointer_cast<CompleteMessage> (diff->getMessage());
+
+ if(diff->getDirection() == SEND)
+ diff_instance = msg->get_sender()->get_label();
+ else
+ diff_instance = msg->get_receiver()->get_label();
+ }
+
+ //in case the location is NULL (can occure when it is the first event on the instance)
+ //algorithm uses other way to get instance name
+ if(matching_diff->getLocation() != NULL)
+ matching_instance = matching_diff->getLocation()->get_instance()->get_label();
+ else
+ {
+ CompleteMessagePtr msg = boost::dynamic_pointer_cast<CompleteMessage> (matching_diff->getMessage());
+
+ if(matching_diff->getDirection() == SEND)
+ matching_instance = msg->get_sender()->get_label();
+ else
+ matching_instance = msg->get_receiver()->get_label();
+ }
+
+ CompleteMessagePtr new_msg = new CompleteMessage(diff->getMessage()->get_label());
+ StrictEventPtr new_e = create_event(dup_flow, diff, diff_instance);
+ StrictEventPtr match_e = create_event(dup_flow, matching_diff, matching_instance);
+
+ new_msg->set_marked(ADDED);
+ new_e->set_marked(ADDED);
+ match_e->set_marked(ADDED);
+
+ if(diff->getDirection() == SEND)
+ new_msg->glue_events(new_e, match_e);
+ else
+ new_msg->glue_events(match_e, new_e);
+
+ return new_msg;
+}
+
+/**
+ * Add new (missing) message to the diagram and remove diffrences from the insert map
+ */
+//TODO zabezpecit aby sa diffrence odoberalo aj v metode add_incomplete_message
+Difference* add_complete_message(MembershipContext* c, BMscPtr dup_flow, StrictEventPtr event,
+ Difference* matching_diff)
+{
+/*
+ std::map<std::wstring, std::list<Difference*> >::iterator insert_it;
+ InstancePtr matching_inst; // matching instance
+
+ //original message which is supposed to be created
+ CompleteMessagePtr msg = boost::dynamic_pointer_cast<CompleteMessage> (diff->getMessage());
+
+ if(diff->getDirection() == SEND)
+ matching_inst = msg->get_receiver();
+ else
+ matching_inst = msg->get_sender();
+
+ insert_it = insert_map.find(matching_inst->get_label());
+
+ if(insert_it == insert_map.end())
+ return diff;
+
+ std::list<Difference*>::reverse_iterator list_it;
+
+ for(list_it = insert_it->second.rbegin(); list_it != insert_it->second.rend(); list_it++)
+ {
+ if(*list_it == NULL)
+ {
+ throw std::runtime_error("Something wrong ");
+ continue;
+ }
+
+ if((*list_it)->getMessage() == msg)
+ break;
+ }
+
+ if(list_it == insert_it->second.rend())
+ return diff;
+
+ CompleteMessagePtr new_msg = create_complete_message(dup_flow, diff, *list_it);
+
+ set_identification(c, new_msg->get_send_event(), msg->get_send_event());
+ set_identification(c, new_msg->get_receive_event(), msg->get_receive_event());
+
+ //remove matching diffrence from the insert map
+ insert_it->second.remove(*list_it);
+
+ //remove diffrence from the insert map
+ std::wstring diff_instance;
+
+ if(diff->getDirection() == SEND)
+ diff_instance = msg->get_sender()->get_label();
+ else
+ diff_instance = msg->get_receiver()->get_label();
+
+ insert_it = insert_map.find(diff_instance);
+
+ if(insert_it == insert_map.end())
+ throw std::runtime_error("Error: unexpected behaviour");
+
+ insert_it->second.remove(diff);
+*/
+ return NULL;
+}
+
+/*
+ * process diffrences which operation is ADD
+ *
+ * the function travers insert map and creates events for all diffrences. It is
+ * necessary for keeping right ordering of recognized differences (otherwise the problem
+ * would be occur when two differences have same location). Created events are stored
+ * into the map "unmatched_differences".
+ *
+ * In the end, "unmatched_differences" map is transformed to the output format.
+ */
+std::map<Difference*, StrictEventPtr> process_inserts(MembershipContext* c, BMscPtr dup_flow,
+ std::map<std::wstring, std::list<Difference*> >& insert_map)
+{
std::map<std::wstring, std::list<Difference*> >::iterator ins_map_it;
- std::map<std::wstring, std::set<Unmatched*> > unmatched_map;
- std::map<std::wstring, std::set<Unmatched*> >::iterator unmatched_map_it;
+ //store momentaly unmatched differences
+ std::map<MscMessage*, std::pair<Difference*, StrictEventPtr> > unmatched_diffs;
+ std::map<MscMessage*, std::pair<Difference*, StrictEventPtr> >::iterator unmatched_it;
for (ins_map_it = insert_map.begin(); ins_map_it != insert_map.end(); ins_map_it++)
{
@@ -712,133 +964,389 @@
continue;
}
+ //process complete message
+ unmatched_it = unmatched_diffs.find(com_msg.get());
+ StrictEventPtr s_e = create_event(dup_flow, *ins_list_it, ins_map_it->first);
- //checks whether exists events which is supposed to be connected with instance
- unmatched_map_it = unmatched_map.find(ins_map_it->first);
-
- //create new record in unmatched_map
- if(unmatched_map_it == unmatched_map.end())
+ if(unmatched_it != unmatched_diffs.end())
{
- std::wstring match_inst;
+ //create message
+ CompleteMessagePtr new_msg = new CompleteMessage((*ins_list_it)->getMessage()->get_label());
+ StrictEventPtr match_e = unmatched_it->second.second;
- if ((*ins_list_it)->getDirection() == SEND)
- match_inst = com_msg->get_receiver()->get_label();
- else
- match_inst = com_msg->get_sender()->get_label();
-
- //check the matching instance, whether has a diffrence for creation of the matching event
- //if the diffrence exist, create unmatched record
- Unmatched* unmatched;
+ new_msg->set_marked(ADDED);
+ s_e->set_marked(ADDED);
+ match_e->set_marked(ADDED);
- if(check_matching_event_creation(insert_map, *ins_list_it))
- {
- StrictEventPtr new_e = create_event(dup_flow, *ins_list_it, ins_map_it->first);
- unmatched = new Unmatched(new_e, message);
- }
- else
- continue;
+ if((*ins_list_it)->getDirection() == SEND)
+ new_msg->glue_events(s_e, match_e);
+ else
+ new_msg->glue_events(match_e, s_e);
- std::map<std::wstring, std::set<Unmatched*> >::iterator match_it = unmatched_map.find(match_inst);
-
- //add to unmatched
- if(match_it == unmatched_map.end())
- {
- std::set<Unmatched*> unmatched_set;
- unmatched_set.insert(unmatched);
- unmatched_map.insert(std::make_pair(match_inst, unmatched_set));
- }
- else
- match_it->second.insert(unmatched);
- continue;
+ //set identification
+ set_identification(c, new_msg->get_send_event(), com_msg->get_send_event());
+ set_identification(c, new_msg->get_receive_event(), com_msg->get_receive_event());
+
+ unmatched_diffs.erase(unmatched_it);
}
+ else
+ //create record to unmatched_diffs
+ unmatched_diffs.insert(std::make_pair(com_msg.get(), std::make_pair(*ins_list_it, s_e)));
+ }
+ }
- bool was_created = false;
- std::set<Unmatched*> unmatched_set = unmatched_map_it->second;
- std::set<Unmatched*>::iterator unmatched_set_it;
-
- for(unmatched_set_it = unmatched_set.begin(); unmatched_set_it != unmatched_set.end(); unmatched_set_it++)
- {
- if(com_msg == (*unmatched_set_it)->getMessage())
- {
- StrictEventPtr new_e = create_event(dup_flow, *ins_list_it, ins_map_it->first);
- StrictEventPtr match_e = (*unmatched_set_it)->getEvent();
+ //transform data to proper output format
+ std::map<Difference*, StrictEventPtr> unmatched_inserts;
- CompleteMessagePtr new_msg = new CompleteMessage(com_msg->get_label());
- new_msg->set_marked(ADDED);
+ for(unmatched_it = unmatched_diffs.begin(); unmatched_it != unmatched_diffs.end(); unmatched_it++)
+ unmatched_inserts.insert(std::make_pair(unmatched_it->second.first, unmatched_it->second.second));
- if((*ins_list_it)->getDirection() == SEND)
- new_msg->glue_events(new_e, match_e);
- else
- new_msg->glue_events(match_e, new_e);
-
- if(new_e->is_send())
- {
- set_identification(c, new_e.get(), com_msg->get_send_event());
- set_identification(c, match_e.get(), com_msg->get_receive_event());
- }
- else
- {
- set_identification(c, match_e.get(), com_msg->get_send_event());
- set_identification(c, new_e.get(), com_msg->get_receive_event());
- }
+ return unmatched_inserts;
+}
- was_created = true;
- break;
- }
- }
+void remove_incomplete_message(Difference* diff)
+{
+ diff->getLocation()->set_marked(REMOVED);
+ diff->getLocation()->get_message()->set_marked(REMOVED);
+}
- if(was_created)
- {
- unmatched_set.erase(unmatched_set_it);
- unmatched_map_it->second = unmatched_set;
+/*
+ * in case the matching diffrence is found, the message is marked otherwise it return unmatched diffrence
+ */
+Difference* remove_complete_message(Difference* diff,
+ std::map<std::wstring, std::list<Difference*> >& remove_map)
+{
+ CompleteMessagePtr msg = boost::dynamic_pointer_cast<CompleteMessage> (diff->getMessage());
+ std::map<std::wstring, std::list<Difference*> >::iterator remove_it;
+ InstancePtr inst;
+
+
+ if(diff->getLocation()->is_send())
+ inst = msg->get_receiver();
+ else
+ inst = msg->get_sender();
+
+ remove_it = remove_map.find(inst->get_label());
+
+ if(remove_it == remove_map.end())
+ return diff;
+
+ std::list<Difference*>::reverse_iterator list_it;
+
+ for(list_it = remove_it->second.rbegin(); list_it != remove_it->second.rend(); list_it++)
+ {
+ if((*list_it)->getMessage() == msg)
+ break;
+ }
+
+ if(list_it != remove_it->second.rend())
+ {
+ diff->getLocation()->set_marked(REMOVED);
+ (*list_it)->getLocation()->set_marked(REMOVED);
+ msg->set_marked(REMOVED);
+
+ remove_it->second.remove(*list_it);
+ return NULL;
+ }
+ else
+ return diff;
+}
+
+/*
+ * process diffrences which operation is REMOVE
+ */
+std::set<Difference*> process_removes(MembershipContext* c, BMscPtr dup_flow,
+ std::map<std::wstring, std::list<Difference*> >& remove_map)
+{
+ std::map<std::wstring, std::list<Difference*> >::iterator map_it;
+ std::set<Difference*> unmatched_differences;
+
+ Difference* unmatched_diff;
+
+ for(map_it = remove_map.begin(); map_it != remove_map.end(); map_it++)
+ {
+ std::list<Difference*> remove_list = map_it->second;
+ std::list<Difference*>::iterator list_it;
+
+ for(list_it = remove_list.begin(); list_it != remove_list.end(); list_it++)
+ {
+ CompleteMessagePtr msg = boost::dynamic_pointer_cast<CompleteMessage> ((*list_it)->getMessage());
+
+ if(msg == NULL)
+ {
+ remove_incomplete_message(*list_it);
+ continue;
}
else
{
- std::wstring match_inst;
+ unmatched_diff = remove_complete_message(*list_it, remove_map);
+
+ if(unmatched_diff != NULL)
+ unmatched_differences.insert(unmatched_diff);
+ }
+ }
+ }
- if ((*ins_list_it)->getDirection() == SEND)
- match_inst = com_msg->get_receiver()->get_label();
- else
- match_inst = com_msg->get_sender()->get_label();
+ return unmatched_differences;
+}
- Unmatched* unmatched;
+/** dostancem diffrence v ktorej event odpoveda originalnemu eventu (to je event ktory bol neoznaceny v sprave ktora by sa mala odobrat)
+*/
+StrictEventPtr search_predecessors_successors(Difference* diff, StrictEvent* original_event)
+{
+ MscMessagePtr original_m = original_event->get_message();
+ StrictEventPtr discover = diff->getLocation();
+ StrictEventPtr candidate = NULL;
- if(check_matching_event_creation(insert_map, *ins_list_it))
- {
- StrictEventPtr new_e = create_event(dup_flow, *ins_list_it, ins_map_it->first);
- unmatched = new Unmatched(new_e, message);
- }
- else
- continue;
+ //check predecessors
+ while(discover != NULL)
+ {
+ if(compare_events(original_event, discover.get(), false))
+ {
+ if(discover->get_message() == original_m)
+ return discover;
+ }
+ else
+ break;
- std::map<std::wstring, std::set<Unmatched*> >::iterator match_it = unmatched_map.find(match_inst);
+ discover = discover->get_predecessor();
+ }
- if(match_it == unmatched_map.end())
+ discover = diff->getLocation();
+
+ //check successors
+ while(discover != NULL)
+ {
+ if(compare_events(original_event, discover.get(), false))
+ {
+ if(discover->get_message() == original_m)
+ return discover;
+ }
+ else
+ break;
+
+ discover = discover->get_successor();
+ }
+
+ return NULL;
+}
+
+/**
+ * in case any event which is supposed to be removed, is unmatched. The algorithm looks
+ * at unmatched diffrences in matching instance. If there is diffrence which semanticly
+ * coresponds with searching event but message pointers are different, the algorithm travers
+ * predecessors and successors.
+ *
+ * The algorithm looks to the predecessor and semanticly compare them in case the event is
+ * diffrent the algorithm starts searching in the successors. In case the event is semanticly
+ * same but the message pointers do not corespond, the algorithm goes to a predecessor of
+ * the predecessor. The same principle is used in traversing the successors.
+ *
+ * TODO to the paper documentation add proof that the event traversing can be finished when
+ * the algorithm finds semanticly different event.
+
+ TODO musim to prechadzat vzdy cele, pretoze ked hladam receive od sendu tak ho nemusim najst, aj ked by som hladal send of receivu tak by sa dal najst. Pozor musim sa pozriet ci uz som dakedy ten diff nespracoval.
+ */
+void advanced_remove_matching(std::set<Difference*>& removes)
+{
+ std::set<Difference*>::iterator removes_it, discover;
+ std::set<Difference*> matched_differences;
+ StrictEvent* original_event; //original matching event, which is not marked to remove
+ CompleteMessagePtr msg;
+
+ for(removes_it = removes.begin(); removes_it != removes.end(); removes_it++)
+ {
+ msg = boost::dynamic_pointer_cast<CompleteMessage> ((*removes_it)->getMessage());
+
+ if(msg == NULL)
+ throw std::runtime_error("Error: unexpected behaviour");
+
+ //get event which we are looking for among other diffrences and their neithbors
+ if((*removes_it)->getDirection() == SEND)
+ original_event = dynamic_cast<StrictEvent*> (msg->get_receive_event());
+ else
+ original_event = dynamic_cast<StrictEvent*> (msg->get_send_event());
+
+ //musim prechadzat od zaciatku lebo niekedy sa to neda zistit iba z jednej strany
+ for(discover = removes.begin(); discover != removes.end(); discover++)
+ {
+ //in case the difference has already been matched, go to a next difference
+ if(matched_differences.find(*discover) != matched_differences.end())
+ continue;
+
+ //in case it processed the same differences, go to a next difference
+ if(*discover == *removes_it)
+ continue;
+
+ if(compare_events(original_event, (*discover)->getLocation().get(), false))
+ {
+ //function returns bool value: true in case the proper event has been found
+ // false in case the proper event has not been found
+//TODO search_predecessors_succ zmenilo rozhranie
+
+ if(search_predecessors_successors(*discover, original_event))
{
- std::set<Unmatched*> match_inst_unmatched_set;
- match_inst_unmatched_set.insert(unmatched);
- unmatched_map.insert(std::make_pair(match_inst, match_inst_unmatched_set));
+ matched_differences.insert(*removes_it);
+ matched_differences.insert(*discover);
+
+ //mark proper events
+ msg->set_marked(REMOVED);
+ msg->get_send_event()->set_marked(REMOVED);
+ msg->get_receive_event()->set_marked(REMOVED);
}
- else
- match_it->second.insert(unmatched);
}
}
}
- //check unmatched diffrences in unmatched map
- for (unmatched_map_it = unmatched_map.begin(); unmatched_map_it != unmatched_map.end(); unmatched_map_it++)
+ for(discover = matched_differences.begin(); discover != matched_differences.end(); discover++)
{
- std::set<Unmatched*> unmatched_set = unmatched_map_it->second;
- std::set<Unmatched*>::iterator unmatched_set_it;
+ removes.erase(*discover);
+ }
+}
- if(!unmatched_set.empty())
- throw std::runtime_error("Unexpected behaviour.");
-
- unmatched_set.clear();
+CompleteMessagePtr process_remove_insert_matching(MembershipContext* c, BMscPtr dup_flow,
+ std::pair<Difference*, StrictEventPtr> insert_diff,
+ Difference* remove_diff)
+{
+ CompleteMessagePtr msg = boost::dynamic_pointer_cast<CompleteMessage> (remove_diff->getMessage());
+
+ if(msg == NULL)
+ throw std::runtime_error("Error: unexpected behaviour");
+
+ //because of remove diffrence, whole message has to be removed
+ msg->set_marked(REMOVED);
+ msg->get_receive_event()->set_marked(REMOVED);
+ msg->get_send_event()->set_marked(REMOVED);
+
+ Event* location;
+
+ //get location of no diff event from the removed message above
+ if(remove_diff->getLocation()->is_send())
+ location = msg->get_receive_event();
+ else
+ location = msg->get_send_event();
+
+ //create temporal difference of recently removed no diff event
+ Difference* new_diff = new Difference();
+ new_diff->setOperation(ADD);
+ new_diff->setLocation(dynamic_cast<StrictEvent*> (location));
+ new_diff->setMessage(insert_diff.first->getMessage(), location->is_send());
+
+ //create message
+ CompleteMessagePtr new_msg = new CompleteMessage(insert_diff.first->getMessage()->get_label());
+ StrictEventPtr match_e = create_event(dup_flow, new_diff, location->get_instance()->get_label());
+
+ new_msg->set_marked(ADDED);
+ insert_diff.second->set_marked(ADDED);
+ match_e->set_marked(ADDED);
+
+ if(insert_diff.first->getDirection() == SEND)
+ new_msg->glue_events(insert_diff.second, match_e);
+ else
+ new_msg->glue_events(match_e, insert_diff.second);
+
+ //set identifications
+ set_identification(c, new_msg->get_send_event(), msg->get_send_event());
+ set_identification(c, new_msg->get_receive_event(), msg->get_receive_event());
+
+ return new_msg;
+}
+
+void match_remove_insert(MembershipContext* c, BMscPtr dup_flow, std::map<Difference*,
+ StrictEventPtr>& unmatched_insert, std::set<Difference*>& unmatched_remove)
+{
+ std::map<Difference*, StrictEventPtr>::iterator insert_it;
+ std::set<Difference*>::iterator remove_it;
+
+ //key: insert diffrences, value: set of remove differences which were unsuccessfully (in case modified diagram does not pass the identification checking) connected with the key
+ std::map<Difference*, std::set<Difference*> > tried_matching;
+
+ std::set<CompleteMessagePtr> created_messages; //messages which are created by the matching
+ CompleteMessagePtr insert_msg, created_msg;
+ std::set<Difference*> matched;
+
+ for(insert_it = unmatched_insert.begin(); insert_it != unmatched_insert.end(); insert_it++)
+ {
+ //in case the difference has been matched, go to a next difference
+ if(matched.find(insert_it->first) != matched.end())
+ continue;
+
+ for(remove_it = unmatched_remove.begin(); remove_it != unmatched_remove.end(); remove_it++)
+ {
+ //in case the difference has been matched, go to a next difference
+ if(matched.find(*remove_it) != matched.end())
+ continue;
+
+ insert_msg = boost::dynamic_pointer_cast<CompleteMessage> (insert_it->first->getMessage());
+
+ if(insert_msg == NULL)
+ throw std::runtime_error("Error: unexpected behaviour");
+
+ Event* insert_event;
+
+ if(insert_it->first->getDirection() == SEND)
+ insert_event = insert_msg->get_send_event();
+ else
+ insert_event = insert_msg->get_receive_event();
+
+ if(compare_events(insert_event, (*remove_it)->getLocation().get(), false))
+ {
+//TODO pridat identifikaciu od remove diffrence z eventu ktory nebol oznaceny na odobratie.
+ created_msg = process_remove_insert_matching(c, dup_flow, *insert_it, *remove_it);
+
+ created_messages.insert(created_msg);
+ matched.insert(*remove_it);
+ matched.insert(insert_it->first);
+ }
+ }
}
+ if(unmatched_remove.size() + unmatched_insert.size() != matched.size())
+ {
+ throw std::runtime_error("Error: internal error");
+ }
}
+void process_diffrences(MembershipContext* c, BMscPtr dup_flow, const std::map<std::wstring, Difference*>& diff_map)
+{
+ //diffrences which operation is add, separated by instances
+ std::map<std::wstring, std::list<Difference*> > insert_map;
+ //diffrences which operation is remove, separated by instances
+ std::map<std::wstring, std::list<Difference*> > remove_map;
+ //unmatched insert differences with created events at proper place
+ std::map<Difference*, StrictEventPtr> unmatched_insert;
+ std::set<Difference*> unmatched_remove;
+
+ //separates differences into two maps by operation flag (add, remove)
+ separate_diffrences(c, diff_map, insert_map, remove_map);
+
+std::map<std::wstring, std::list<Difference*> >::iterator it;
+std::wcerr << "insert map " << insert_map.size() << std::endl;
+for(it = insert_map.begin(); it != insert_map.end(); it++)
+{
+ std::wcerr << " insert list " << it->second.size() << std::endl;
+}
+std::wcerr << "remove map " << insert_map.size() << std::endl;
+for(it = remove_map.begin(); it != remove_map.end(); it++)
+{
+ std::wcerr << " remove list " << it->second.size() << std::endl;
+}
+
+ unmatched_insert = process_inserts(c, dup_flow, insert_map);
+ unmatched_remove = process_removes(c, dup_flow, remove_map);
+
+ //process advanced matching of "remove" differences
+ if(!unmatched_remove.empty())
+ advanced_remove_matching(unmatched_remove);
+
+ if(!unmatched_remove.empty() || !unmatched_insert.empty())
+ {
+ //in case the ordering is wrong, this situation creates one remove difference and
+ //one add diffrence on the same instance
+ match_remove_insert(c, dup_flow, unmatched_insert, unmatched_remove);
+ }
+}
+
bool check_attributes(MembershipContext* c, BMscPtr specification, BMscPtr dup_flow)
{
std::map<std:...
[truncated message content] |