|
From: <ma...@us...> - 2012-02-06 22:34:07
|
Revision: 1308
http://scstudio.svn.sourceforge.net/scstudio/?rev=1308&view=rev
Author: madzin
Date: 2012-02-06 22:34:00 +0000 (Mon, 06 Feb 2012)
Log Message:
-----------
Fix bug - ID: 3480475
Modify the output of searcher algorithms (at this moment just Find Flow).
Modified Paths:
--------------
trunk/src/data/searcher.h
trunk/src/membership/membership_alg.cpp
trunk/src/membership/membership_base.h
trunk/tests/diff/diff_test.cpp
trunk/tests/membership/absolut_time_bmsc01_2.mpr.result
trunk/tests/membership/absolut_time_bmsc02_2.mpr.result
trunk/tests/membership/bmsc_spec4_pat.mpr.result
trunk/tests/membership/complete_absolute_pat3.mpr.result
trunk/tests/membership/complete_absolute_pat8.mpr.result
trunk/tests/membership/complete_pat8_1.mpr.result
trunk/tests/membership/complete_pat8_2.mpr.result
trunk/tests/membership/membership_test.cpp
trunk/tests/membership/test_bmsc28_3.mpr.result
trunk/tests/membership/test_bmsc28_4.mpr.result
trunk/tests/membership/test_bmsc29_2.mpr.result
trunk/tests/membership/test_bmsc30_2.mpr.result
trunk/tests/membership/time_hard_bmsc_pat02.mpr.result
trunk/tests/membership/time_hard_bmsc_pat04.mpr.result
Modified: trunk/src/data/searcher.h
===================================================================
--- trunk/src/data/searcher.h 2012-02-02 19:08:51 UTC (rev 1307)
+++ trunk/src/data/searcher.h 2012-02-06 22:34:00 UTC (rev 1308)
@@ -30,6 +30,76 @@
#pragma warning(disable: 4275)
#endif
+class SearcherResult;
+
+typedef boost::intrusive_ptr<SearcherResult> SearcherResultPtr;
+
+class SearcherResult
+{
+ enum TReportSeverity msg_type;
+ std::wstring msg;
+ std::vector<MscPtr> counterexamples;
+
+ private:
+ //! Number of references to this object.
+ mutable volatile boost::uint32_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 SearcherResult *ptr);
+ friend void intrusive_ptr_release(const SearcherResult *ptr);
+
+ public:
+
+ SearcherResult(enum TReportSeverity type, std::wstring msg, std::vector<MscPtr> examples)
+ {
+ this->msg_type = type;
+ this->msg = msg;
+ this->counterexamples = examples;
+ m_counter = 0;
+ }
+
+ enum TReportSeverity get_msg_type()
+ {
+ return msg_type;
+ }
+
+ std::wstring get_msg()
+ {
+ return msg;
+ }
+
+ std::vector<MscPtr> get_counterexamples()
+ {
+ return counterexamples;
+ }
+};
+
+inline void intrusive_ptr_add_ref(const SearcherResult *ptr)
+{
+ if(ptr != NULL)
+#if BOOST_VERSION > 103500
+ boost::interprocess::detail::atomic_inc32(&ptr->m_counter);
+#else
+ ++ptr->m_counter;
+#endif
+}
+
+inline void intrusive_ptr_release(const SearcherResult *ptr)
+{
+ if(ptr != NULL)
+ {
+#if BOOST_VERSION > 103500
+ // note, atomic_dec32() returns the old value pointed to by mem
+ if(boost::interprocess::detail::atomic_dec32(&ptr->m_counter) == 1)
+#else
+ if(ptr->m_counter-- == 1)
+#endif
+ // the last pointer is being released, delete the objet
+ delete ptr;
+ }
+}
+
+
class Searcher : public Reporter
{
public:
@@ -41,9 +111,9 @@
virtual PreconditionList get_preconditions(MscPtr msc) const = 0;
//! Find the first occurence of needle in haystack.
- virtual std::vector<std::pair<std::wstring, std::vector<MscPtr> > > find(MscPtr msc, std::vector<MscPtr>& bmscs) = 0;
+ virtual std::vector<SearcherResultPtr> 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, std::vector<std::wstring> instances) = 0;
+ virtual std::vector<SearcherResultPtr> find(MscPtr msc, std::vector<MscPtr>& bmscs, std::vector<std::wstring> instances) = 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 2012-02-02 19:08:51 UTC (rev 1307)
+++ trunk/src/membership/membership_alg.cpp 2012-02-06 22:34:00 UTC (rev 1308)
@@ -43,7 +43,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::vector<std::pair<std::wstring, std::vector<MscPtr> > >& messages)
+ std::vector<SearcherResultPtr>& messages)
{
HMscPtr hmsc = boost::dynamic_pointer_cast<HMsc > (msc);
BMscPtr bmsc_f = boost::dynamic_pointer_cast<BMsc > (bmsc);
@@ -58,7 +58,7 @@
c->set_mem(this);
c->set_focused_instances(instances);
c->set_bmsc(bmsc_f);
- c->set_result_messages(messages);
+// c->set_result_messages(messages);
MscPtr result = NULL;
std::wstring focused_instance_names = L"";
@@ -99,7 +99,7 @@
std::vector<MscPtr> result_vec;
result_vec.push_back(result);
- messages.push_back(std::make_pair(msg, result_vec));
+ messages.push_back(new SearcherResult(RS_ERROR, msg, result_vec));
c->clear_attributed_events();
delete c;
@@ -108,12 +108,12 @@
if(c->get_result()->get_corupted_intervals_size().second != 0)
{
- std::wstring msg = L"Flow \"" + bmsc->get_label() + L" not found. Unsatisfied time constraint(s). Some interval(s) are only partially satisfied: ";
+ std::wstring msg = L"Flow \"" + bmsc->get_label() + L"\" not found. Unsatisfied time constraint(s). Some interval(s) are only partially satisfied: ";
std::vector<MscPtr> result_vec;
result_vec.push_back(result);
- messages.push_back(std::make_pair(msg, result_vec));
+ messages.push_back(new SearcherResult(RS_ERROR, msg, result_vec));
c->clear_attributed_events();
delete c;
@@ -128,7 +128,7 @@
msg += L".";
- messages.push_back(std::make_pair(msg, result_vec));
+ messages.push_back(new SearcherResult(RS_NOTICE, msg, result_vec));
c->clear_attributed_events();
delete c;
@@ -177,13 +177,14 @@
if(result != NULL)
{
- std::wstring message;
- message = L"Flow \"" + bmsc_f->get_label() + L"\" not found. Diff: ";
+ std::wstring msg;
+ msg = L"Flow \"" + bmsc_f->get_label() + L"\" not found. Diff: ";
std::vector<MscPtr> diff_result;
diff_result.push_back(result);
- messages.push_back(std::make_pair(message, diff_result));
+ messages.push_back(new SearcherResult(RS_ERROR, msg, diff_result));
+
}
c->clear_attributed_events();
@@ -199,7 +200,7 @@
std::vector<MscPtr> result_vec;
result_vec.push_back(result);
- messages.push_back(std::make_pair(msg, result_vec));
+ messages.push_back(new SearcherResult(RS_ERROR, msg, result_vec));
c->clear_attributed_events();
delete c;
@@ -208,12 +209,12 @@
if(c->get_result()->get_corupted_intervals_size().second != 0)
{
- std::wstring msg = L"Flow \"" + bmsc_f->get_label() + L" not found. Unsatisfied time constraint(s). Some interval(s) are only partially satisfied: ";
+ std::wstring msg = L"Flow \"" + bmsc_f->get_label() + L"\" not found. Unsatisfied time constraint(s). Some interval(s) are only partially satisfied: ";
std::vector<MscPtr> result_vec;
result_vec.push_back(result);
- messages.push_back(std::make_pair(msg, result_vec));
+ messages.push_back(new SearcherResult(RS_ERROR, msg, result_vec));
c->clear_attributed_events();
delete c;
@@ -240,13 +241,13 @@
return NULL;
}
-std::vector<std::pair<std::wstring, std::vector<MscPtr> > > MembershipAlg::find(MscPtr msc,
+std::vector<SearcherResultPtr> MembershipAlg::find(MscPtr msc,
std::vector<MscPtr>& bmscs,
std::vector<std::wstring> instances)
{
MscPtr temp;
bool cover = false;
- std::vector<std::pair<std::wstring, std::vector<MscPtr> > > messages;
+ std::vector<SearcherResultPtr> messages;
HMscPtr hmsc = boost::dynamic_pointer_cast<HMsc>(msc);
BMscPtr bmsc = boost::dynamic_pointer_cast<BMsc>(msc);
BMscGraphDuplicator hmsc_duplicator;
@@ -283,7 +284,7 @@
if(cover)
{
- std::vector<std::pair<std::wstring, std::vector<MscPtr> > > msg;
+ std::vector<SearcherResultPtr> msg;
dup_msc = hmsc_duplicator.duplicate(hmsc);
@@ -296,15 +297,15 @@
msc_cover.push_back(dup_msc);
if(msc_for_cover.size() > 1)
- messages.push_back(std::make_pair(L"Diagram with found flows highlighted.", msc_cover));
+ messages.push_back(new SearcherResult(RS_NOTICE, L"Diagram with found flows highlighted.", msc_cover));
else
- messages.push_back(std::make_pair(L"Diagram with found flow highlighted.", msc_cover));
+ messages.push_back(new SearcherResult(RS_NOTICE, L"Diagram with found flow highlighted.", msc_cover));
}
return messages;
}
-std::vector<std::pair<std::wstring, std::vector<MscPtr> > > MembershipAlg::find(MscPtr msc, std::vector<MscPtr>& bmscs)
+std::vector<SearcherResultPtr> MembershipAlg::find(MscPtr msc, std::vector<MscPtr>& bmscs)
{
std::vector<std::wstring> instances;
return find(msc, bmscs, instances);
Modified: trunk/src/membership/membership_base.h
===================================================================
--- trunk/src/membership/membership_base.h 2012-02-02 19:08:51 UTC (rev 1307)
+++ trunk/src/membership/membership_base.h 2012-02-06 22:34:00 UTC (rev 1308)
@@ -289,7 +289,7 @@
enum DiffType diff_type;
- std::vector<std::pair<std::wstring, std::vector<MscPtr> > > result_messages;
+// std::vector<std::pair<std::wstring, std::vector<MscPtr> > > result_messages;
// bool search_bmsc;
public:
@@ -810,21 +810,22 @@
diff_type = type;
}
- void set_result_messages(std::vector<std::pair<std::wstring, std::vector<MscPtr> > >& messages)
+/*
+ void set_result_messages(std::vector<SearchResultPtr>& 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.push_back(std::make_pair(message, results));
}
-/*
+
void set_search_bmsc()
{
search_bmsc = true;
@@ -1309,7 +1310,7 @@
{
private:
MscPtr find_flow(MscPtr msc, MscPtr bmsc, std::vector<std::wstring> instances,
- std::vector<std::pair<std::wstring, std::vector<MscPtr> > >& messages);
+ std::vector<SearcherResultPtr>& messages);
//! Make diff between specification and flow
MscPtr diff(MembershipContext* c, MscPtr specification, std::vector<MscPtr>& flows);
@@ -1337,9 +1338,9 @@
//! Finds each bmsc flow from the vector in hmsc specification
- virtual std::vector<std::pair<std::wstring, std::vector<MscPtr> > > find(MscPtr hmsc, std::vector<MscPtr>& bmscs);
+ virtual std::vector<SearcherResultPtr> find(MscPtr hmsc, std::vector<MscPtr>& bmscs);
- virtual std::vector<std::pair<std::wstring, std::vector<MscPtr> > > find(MscPtr msc, std::vector<MscPtr>& bmscs, std::vector<std::wstring> instances);
+ virtual std::vector<SearcherResultPtr> find(MscPtr msc, std::vector<MscPtr>& bmscs, std::vector<std::wstring> instances);
MscPtr get_dp_msc(MscPtr msc);
Modified: trunk/tests/diff/diff_test.cpp
===================================================================
--- trunk/tests/diff/diff_test.cpp 2012-02-02 19:08:51 UTC (rev 1307)
+++ trunk/tests/diff/diff_test.cpp 2012-02-06 22:34:00 UTC (rev 1308)
@@ -100,7 +100,7 @@
MembershipAlg mem;
mem.set_printer(&printer);
- std::vector<std::pair<std::wstring, std::vector<MscPtr> > > result;
+ std::vector<SearcherResultPtr> result;
result = mem.find(msc[0], msc_b);
@@ -128,11 +128,11 @@
try
{
- std::vector<std::pair<std::wstring, std::vector<MscPtr> > >::iterator result_it;
+ std::vector<SearcherResultPtr>::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));
+ for(unsigned int i = 0; i < (*result_it)->get_counterexamples().size(); i++)
+ z120.save_msc(std::cout, L"msc_diff", (*result_it)->get_counterexamples().at(i));
}
}
catch(std::exception& exc)
Modified: trunk/tests/membership/absolut_time_bmsc01_2.mpr.result
===================================================================
--- trunk/tests/membership/absolut_time_bmsc01_2.mpr.result 2012-02-02 19:08:51 UTC (rev 1307)
+++ trunk/tests/membership/absolut_time_bmsc01_2.mpr.result 2012-02-06 22:34:00 UTC (rev 1308)
@@ -1,4 +1,4 @@
-Flow "bbb not found. Unsatisfied time constraint(s). Some interval(s) are only partially satisfied:
+Flow "bbb" not found. Unsatisfied time constraint(s). Some interval(s) are only partially satisfied:
mscdocument absolut_time_hmsc01;
msc iha;
/* PATH */
Modified: trunk/tests/membership/absolut_time_bmsc02_2.mpr.result
===================================================================
--- trunk/tests/membership/absolut_time_bmsc02_2.mpr.result 2012-02-02 19:08:51 UTC (rev 1307)
+++ trunk/tests/membership/absolut_time_bmsc02_2.mpr.result 2012-02-06 22:34:00 UTC (rev 1308)
@@ -1,4 +1,4 @@
-Flow "bbb not found. Unsatisfied time constraint(s). Some interval(s) are only partially satisfied:
+Flow "bbb" not found. Unsatisfied time constraint(s). Some interval(s) are only partially satisfied:
mscdocument absolut_time_hmsc02;
msc iha;
/* PATH */
Modified: trunk/tests/membership/bmsc_spec4_pat.mpr.result
===================================================================
--- trunk/tests/membership/bmsc_spec4_pat.mpr.result 2012-02-02 19:08:51 UTC (rev 1307)
+++ trunk/tests/membership/bmsc_spec4_pat.mpr.result 2012-02-06 22:34:00 UTC (rev 1308)
@@ -1,4 +1,4 @@
-Flow "Page_1 not found. Unsatisfied time constraint(s). Some interval(s) are only partially satisfied:
+Flow "Page_1" not found. Unsatisfied time constraint(s). Some interval(s) are only partially satisfied:
mscdocument bmsc_spec4;
msc Page_1;
inst PC;
Modified: trunk/tests/membership/complete_absolute_pat3.mpr.result
===================================================================
--- trunk/tests/membership/complete_absolute_pat3.mpr.result 2012-02-02 19:08:51 UTC (rev 1307)
+++ trunk/tests/membership/complete_absolute_pat3.mpr.result 2012-02-06 22:34:00 UTC (rev 1308)
@@ -1,4 +1,4 @@
-Flow "Page_1 not found. Unsatisfied time constraint(s). Some interval(s) are only partially satisfied:
+Flow "Page_1" not found. Unsatisfied time constraint(s). Some interval(s) are only partially satisfied:
mscdocument complete_absolute;
msc Page_1;
/* PATH */
Modified: trunk/tests/membership/complete_absolute_pat8.mpr.result
===================================================================
--- trunk/tests/membership/complete_absolute_pat8.mpr.result 2012-02-02 19:08:51 UTC (rev 1307)
+++ trunk/tests/membership/complete_absolute_pat8.mpr.result 2012-02-06 22:34:00 UTC (rev 1308)
@@ -1,4 +1,4 @@
-Flow "Page_1 not found. Unsatisfied time constraint(s). Some interval(s) are only partially satisfied:
+Flow "Page_1" not found. Unsatisfied time constraint(s). Some interval(s) are only partially satisfied:
mscdocument complete_absolute;
msc Page_1;
/* PATH */
Modified: trunk/tests/membership/complete_pat8_1.mpr.result
===================================================================
--- trunk/tests/membership/complete_pat8_1.mpr.result 2012-02-02 19:08:51 UTC (rev 1307)
+++ trunk/tests/membership/complete_pat8_1.mpr.result 2012-02-06 22:34:00 UTC (rev 1308)
@@ -1,4 +1,4 @@
-Flow "Page_1 not found. Unsatisfied time constraint(s). Some interval(s) are only partially satisfied:
+Flow "Page_1" not found. Unsatisfied time constraint(s). Some interval(s) are only partially satisfied:
mscdocument complete;
msc Page_1;
/* PATH */
Modified: trunk/tests/membership/complete_pat8_2.mpr.result
===================================================================
--- trunk/tests/membership/complete_pat8_2.mpr.result 2012-02-02 19:08:51 UTC (rev 1307)
+++ trunk/tests/membership/complete_pat8_2.mpr.result 2012-02-06 22:34:00 UTC (rev 1308)
@@ -1,4 +1,4 @@
-Flow "Page_1 not found. Unsatisfied time constraint(s). Some interval(s) are only partially satisfied:
+Flow "Page_1" not found. Unsatisfied time constraint(s). Some interval(s) are only partially satisfied:
mscdocument complete_absolute;
msc Page_1;
/* PATH */
Modified: trunk/tests/membership/membership_test.cpp
===================================================================
--- trunk/tests/membership/membership_test.cpp 2012-02-02 19:08:51 UTC (rev 1307)
+++ trunk/tests/membership/membership_test.cpp 2012-02-06 22:34:00 UTC (rev 1308)
@@ -108,7 +108,7 @@
if(bmsc == NULL)
throw std::runtime_error("Error: Flow typecasting failed");
- std::vector<std::pair<std::wstring, std::vector<MscPtr> > > result;
+ std::vector<SearcherResultPtr> result;
std::vector<MscPtr> bmscs;
bmscs.push_back(bmsc);
@@ -155,14 +155,14 @@
if(!result.empty())
{
- std::vector<std::pair<std::wstring, std::vector<MscPtr> > >::iterator vec_it;
+ std::vector<SearcherResultPtr>::iterator vec_it;
for(vec_it = result.begin(); vec_it != result.end(); vec_it++)
{
- std::wcerr << vec_it->first << std::endl;
- for(unsigned int i = 0; i < vec_it->second.size(); i++)
+ std::wcerr << (*vec_it)->get_msg() << std::endl;
+ for(unsigned int i = 0; i < (*vec_it)->get_counterexamples().size(); i++)
{
- z120.save_msc(std::cout, TOWSTRING(filename), vec_it->second.at(i));
+ z120.save_msc(std::cout, TOWSTRING(filename), (*vec_it)->get_counterexamples().at(i));
}
}
}
Modified: trunk/tests/membership/test_bmsc28_3.mpr.result
===================================================================
--- trunk/tests/membership/test_bmsc28_3.mpr.result 2012-02-02 19:08:51 UTC (rev 1307)
+++ trunk/tests/membership/test_bmsc28_3.mpr.result 2012-02-06 22:34:00 UTC (rev 1308)
@@ -1,4 +1,4 @@
-Flow "Page_2 not found. Unsatisfied time constraint(s). Some interval(s) are only partially satisfied:
+Flow "Page_2" not found. Unsatisfied time constraint(s). Some interval(s) are only partially satisfied:
mscdocument test_bmsc28;
msc Page_1;
inst a;
Modified: trunk/tests/membership/test_bmsc28_4.mpr.result
===================================================================
--- trunk/tests/membership/test_bmsc28_4.mpr.result 2012-02-02 19:08:51 UTC (rev 1307)
+++ trunk/tests/membership/test_bmsc28_4.mpr.result 2012-02-06 22:34:00 UTC (rev 1308)
@@ -1,4 +1,4 @@
-Flow "Page_2 not found. Unsatisfied time constraint(s). Some interval(s) are only partially satisfied:
+Flow "Page_2" not found. Unsatisfied time constraint(s). Some interval(s) are only partially satisfied:
mscdocument test_bmsc28;
msc Page_1;
inst a;
Modified: trunk/tests/membership/test_bmsc29_2.mpr.result
===================================================================
--- trunk/tests/membership/test_bmsc29_2.mpr.result 2012-02-02 19:08:51 UTC (rev 1307)
+++ trunk/tests/membership/test_bmsc29_2.mpr.result 2012-02-06 22:34:00 UTC (rev 1308)
@@ -1,4 +1,4 @@
-Flow "bmsc3 not found. Unsatisfied time constraint(s). Some interval(s) are only partially satisfied:
+Flow "bmsc3" not found. Unsatisfied time constraint(s). Some interval(s) are only partially satisfied:
mscdocument test_hmsc29;
msc iha;
/* PATH */
Modified: trunk/tests/membership/test_bmsc30_2.mpr.result
===================================================================
--- trunk/tests/membership/test_bmsc30_2.mpr.result 2012-02-02 19:08:51 UTC (rev 1307)
+++ trunk/tests/membership/test_bmsc30_2.mpr.result 2012-02-06 22:34:00 UTC (rev 1308)
@@ -1,4 +1,4 @@
-Flow "bmsc3 not found. Unsatisfied time constraint(s). Some interval(s) are only partially satisfied:
+Flow "bmsc3" not found. Unsatisfied time constraint(s). Some interval(s) are only partially satisfied:
mscdocument test_hmsc30;
msc iha;
/* PATH */
Modified: trunk/tests/membership/time_hard_bmsc_pat02.mpr.result
===================================================================
--- trunk/tests/membership/time_hard_bmsc_pat02.mpr.result 2012-02-02 19:08:51 UTC (rev 1307)
+++ trunk/tests/membership/time_hard_bmsc_pat02.mpr.result 2012-02-06 22:34:00 UTC (rev 1308)
@@ -1,4 +1,4 @@
-Flow "Page_1 not found. Unsatisfied time constraint(s). Some interval(s) are only partially satisfied:
+Flow "Page_1" not found. Unsatisfied time constraint(s). Some interval(s) are only partially satisfied:
mscdocument time_hard_bmsc02;
msc Page_1;
inst A;
Modified: trunk/tests/membership/time_hard_bmsc_pat04.mpr.result
===================================================================
--- trunk/tests/membership/time_hard_bmsc_pat04.mpr.result 2012-02-02 19:08:51 UTC (rev 1307)
+++ trunk/tests/membership/time_hard_bmsc_pat04.mpr.result 2012-02-06 22:34:00 UTC (rev 1308)
@@ -1,4 +1,4 @@
-Flow "Page_1 not found. Unsatisfied time constraint(s). Some interval(s) are only partially satisfied:
+Flow "Page_1" not found. Unsatisfied time constraint(s). Some interval(s) are only partially satisfied:
mscdocument time_hard_bmsc04;
msc Page_1;
inst A;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|