|
From: <ba...@us...> - 2008-10-05 18:05:46
|
Revision: 111
http://scstudio.svn.sourceforge.net/scstudio/?rev=111&view=rev
Author: babicaj
Date: 2008-10-05 18:03:03 +0000 (Sun, 05 Oct 2008)
Log Message:
-----------
Structure of HMsc was customized for graphical representation. Traversers of HMsc was modified in appropriate way. It is more than possible that checkers need to be modified too. Sorry for current compilation problem it will be corrected as soon as possible.
Modified Paths:
--------------
trunk/src/check/dfs_bmsc_graph_traverser.cpp
trunk/src/check/dfs_bmsc_graph_traverser.h
trunk/src/check/dfs_hmsc_traverser.cpp
trunk/src/check/dfs_hmsc_traverser.h
trunk/src/check/footprint.cpp
trunk/src/check/footprint.h
trunk/src/check/race_checker.cpp
trunk/src/check/race_checker.h
trunk/src/data/counted_ptr.h
trunk/src/data/msc.cpp
trunk/src/data/msc.h
Added Paths:
-----------
trunk/src/check/refnode_finder.cpp
trunk/src/check/refnode_finder.h
trunk/src/data/msc_visual.h
Modified: trunk/src/check/dfs_bmsc_graph_traverser.cpp
===================================================================
--- trunk/src/check/dfs_bmsc_graph_traverser.cpp 2008-10-04 22:31:47 UTC (rev 110)
+++ trunk/src/check/dfs_bmsc_graph_traverser.cpp 2008-10-05 18:03:03 UTC (rev 111)
@@ -27,67 +27,95 @@
void DFSBMscGraphTraverser::traverse(HMscPtr hmsc)
{
- m_colored_nodes.push_back(InnerNodePList());
- traverse_successors(hmsc->get_start()->get_successors());
+ push_top_attributes();
+ traverse_node(hmsc->get_start().get());
cleanup_traversing_attributes();
}
-bool DFSBMscGraphTraverser::traverse_node(InnerNode* node)
+bool DFSBMscGraphTraverser::traverse_node(HMscNode* node)
{
- Color c = get_color(node);
- if(c==BLACK)
+ if(is_processed(node))
{
- black_node_found(node);
return false;
}
- if(c==GRAY)
- {
- gray_node_found(node);
- return false;
- }
white_node_found(node);
ReferenceNode* ref_node = dynamic_cast<ReferenceNode*>(node);
if(ref_node!=NULL)
{
- HMscPtr hmsc = ref_node->get_hmsc();
- if(hmsc.get()!=NULL)
+ return traverse_node(ref_node);
+ }
+ else
+ {
+ bool ending_successors;
+ ConnectionNode* conn_node = dynamic_cast<ConnectionNode*>(node);
+ if(conn_node)
{
- m_reached_nodes.push_back(InnerNodePList());
- //this line ensures (yet another one) that HMsc will be traversed as many times
- //as it is referenced
- m_colored_nodes.push_back(InnerNodePList());
- //node's successors aren't traversed if end node wasn't found in hmsc
- return traverse_successors(hmsc->get_start()->get_successors()) &&
- (traverse_successors(node->get_successors()) || ref_node->is_end_node());
- //this line ensures (yet another one) that HMsc will traversed as many times
- //as it is referenced
- cleanup_top_attributes();
- m_reached_nodes.pop_back();
+ ending_successors = traverse_successors(conn_node);
}
+ else
+ {
+ StartNode* start_node = dynamic_cast<StartNode*>(node);
+ if(start_node)
+ {
+ ending_successors = traverse_successors(start_node);
+ }
+ else
+ {
+ //node is supposed to be EndNode
+ ending_successors = true;
+ }
+ }
+ node_finished(node);
+ return ending_successors;
}
- bool ending_successors = traverse_successors(node->get_successors());
- node_finished(node);
- return ending_successors || (ref_node!=NULL && ref_node->is_end_node());
}
-bool DFSBMscGraphTraverser::traverse_successors(const InnerNodePSet& successors)
+bool DFSBMscGraphTraverser::traverse_node(ReferenceNode* ref_node)
{
+ HMscPtr hmsc = ref_node->get_hmsc();
+ bool inner = true;
+ if(hmsc.get()!=NULL)
+ {
+ //this line ensures (yet another one) that HMsc will be traversed as many times
+ //as it is referenced
+ push_top_attributes();
+ //node's successors aren't traversed if end node wasn't found in hmsc
+ inner = traverse_successors(hmsc->get_start().get());
+ //this line ensures (yet another one) that HMsc will traversed as many times
+ //as it is referenced
+ cleanup_top_attributes();
+ }
+ return inner && traverse_successors(ref_node);
+}
+
+bool DFSBMscGraphTraverser::traverse_successors(PredecessorNode* predecessor)
+{
bool end_found = false;
- InnerNodePSet::const_iterator successor;
- for(successor=successors.begin();successor!=successors.end();successor++)
+ NodeRelationPtrSet::const_iterator relation;
+ for(relation=predecessor->get_successors().begin();
+ relation!=predecessor->get_successors().end();relation++)
{
- end_found = traverse_node(*successor) || end_found;
+ const NodeRelationPtr& rel = *relation;
+ m_reached_nodes.back().push_back(rel);
+ end_found = traverse_node((HMscNode*)rel->get_successor()) || end_found;
}
return end_found;
}
-void DFSBMscGraphTraverser::cleanup_top_attributes()
+bool DFSBMscGraphTraverser::is_processed(HMscNode* node)
{
- InnerNodePList& top = m_colored_nodes.back();
- InnerNodePList::iterator event;
- for(event=top.begin();event!=top.end();event++)
- (*event)->remove_attribute<Color>(m_color_attribute);
- m_colored_nodes.pop_back();
+ Color c = get_color(node);
+ if(c==BLACK)
+ {
+ black_node_found(node);
+ return true;
+ }
+ if(c==GRAY)
+ {
+ gray_node_found(node);
+ return true;
+ }
+ return false;
}
void DFSBMscGraphTraverser::cleanup_traversing_attributes()
@@ -96,16 +124,10 @@
{
cleanup_top_attributes();
}
- while(!m_reached_nodes.empty())
- {
- m_reached_nodes.pop_back();
- }
-
}
-void DFSBMscGraphTraverser::white_node_found(InnerNode* n)
+void DFSBMscGraphTraverser::white_node_found(HMscNode* n)
{
- m_reached_nodes.back().push_back(n);
WhiteNodeFoundListenerPList::iterator l;
for(l=m_white_node_found_listeners.begin();l!=m_white_node_found_listeners.end();l++)
(*l)->on_white_node_found(n);
@@ -113,21 +135,23 @@
m_colored_nodes.back().push_back(n);
}
-void DFSBMscGraphTraverser::gray_node_found(InnerNode* n)
+void DFSBMscGraphTraverser::gray_node_found(HMscNode* n)
{
GrayNodeFoundListenerPList::iterator l;
for(l=m_gray_node_found_listeners.begin();l!=m_gray_node_found_listeners.end();l++)
(*l)->on_gray_node_found(n);
+ m_reached_nodes.back().pop_back();
}
-void DFSBMscGraphTraverser::black_node_found(InnerNode* n)
+void DFSBMscGraphTraverser::black_node_found(HMscNode* n)
{
BlackNodeFoundListenerPList::iterator l;
for(l=m_black_node_found_listeners.begin();l!=m_black_node_found_listeners.end();l++)
(*l)->on_black_node_found(n);
+ m_reached_nodes.back().pop_back();
}
-void DFSBMscGraphTraverser::node_finished(InnerNode* n)
+void DFSBMscGraphTraverser::node_finished(HMscNode* n)
{
NodeFinishedListenerPList::iterator l;
for(l=m_node_finished_listeners.begin();l!=m_node_finished_listeners.end();l++)
@@ -136,3 +160,19 @@
set_color(n,BLACK);
}
+void DFSBMscGraphTraverser::cleanup_top_attributes()
+{
+ HMscNodePList& top = m_colored_nodes.back();
+ HMscNodePList::iterator event;
+ for(event=top.begin();event!=top.end();event++)
+ (*event)->remove_attribute<Color>(m_color_attribute);
+ m_colored_nodes.pop_back();
+ m_reached_nodes.pop_back();
+}
+
+void DFSBMscGraphTraverser::push_top_attributes()
+{
+ m_colored_nodes.push_back(HMscNodePList());
+ m_reached_nodes.push_back(NodeRelationPtrList());
+}
+
Modified: trunk/src/check/dfs_bmsc_graph_traverser.h
===================================================================
--- trunk/src/check/dfs_bmsc_graph_traverser.h 2008-10-04 22:31:47 UTC (rev 110)
+++ trunk/src/check/dfs_bmsc_graph_traverser.h 2008-10-05 18:03:03 UTC (rev 111)
@@ -24,11 +24,14 @@
#include "data/msc.h"
#include "check/checker.h"
-typedef std::list<InnerNode*> InnerNodePList;
-typedef std::list<InnerNodePList> InnerNodePListList;
+typedef std::list<HMscNode*> HMscNodePList;
+typedef std::list<HMscNodePList> HMscNodePListList;
+typedef std::list<NodeRelationPtr> NodeRelationPtrList;
+typedef std::list<NodeRelationPtrList> NodeRelationPtrListList;
+
/**
- * Listener of founded white InnerNode
+ * Listener of founded white HMscNode
*/
class WhiteNodeFoundListener
{
@@ -39,11 +42,11 @@
}
- virtual void on_white_node_found(InnerNode* n)=0;
+ virtual void on_white_node_found(HMscNode* n)=0;
};
/**
- * Listener of founded gray InnerNode
+ * Listener of founded gray HMscNode
*/
class GrayNodeFoundListener
{
@@ -54,11 +57,11 @@
}
- virtual void on_gray_node_found(InnerNode* n)=0;
+ virtual void on_gray_node_found(HMscNode* n)=0;
};
/**
- * Listener of founded black InnerNode
+ * Listener of founded black HMscNode
*/
class BlackNodeFoundListener
{
@@ -69,11 +72,11 @@
}
- virtual void on_black_node_found(InnerNode* n)=0;
+ virtual void on_black_node_found(HMscNode* n)=0;
};
/**
- * Listener of finished InnerNode
+ * Listener of finished HMscNode
*/
class NodeFinishedListener
{
@@ -84,11 +87,11 @@
}
- virtual void on_node_finished(InnerNode* node)=0;
+ virtual void on_node_finished(HMscNode* node)=0;
};
/**
- * Auxiliary listener of founded white InnerNode.
+ * Auxiliary listener of founded white HMscNode.
*
* Extend this listener to process only ReferenceNodes during traversing.
*/
@@ -101,7 +104,7 @@
}
- virtual void on_white_node_found(InnerNode* n){
+ virtual void on_white_node_found(HMscNode* n){
ReferenceNode* ref = dynamic_cast<ReferenceNode*>(n);
if(ref!=NULL)
{
@@ -113,7 +116,7 @@
};
/**
- * Auxiliary listener of founded gray InnerNode.
+ * Auxiliary listener of founded gray HMscNode.
*
* Extend this listener to process only ReferenceNodes during traversing.
*/
@@ -126,7 +129,7 @@
}
- virtual void on_gray_node_found(InnerNode* n){
+ virtual void on_gray_node_found(HMscNode* n){
ReferenceNode* ref = dynamic_cast<ReferenceNode*>(n);
if(ref!=NULL)
{
@@ -138,7 +141,7 @@
};
/**
- * Auxiliary listener of founded black InnerNode.
+ * Auxiliary listener of founded black HMscNode.
*
* Extend this listener to process only ReferenceNodes during traversing.
*/
@@ -151,7 +154,7 @@
}
- virtual void on_black_node_found(InnerNode* n){
+ virtual void on_black_node_found(HMscNode* n){
ReferenceNode* ref = dynamic_cast<ReferenceNode*>(n);
if(ref!=NULL)
{
@@ -163,7 +166,7 @@
};
/**
- * Auxiliary listener of finished InnerNode.
+ * Auxiliary listener of finished HMscNode.
*
* Extend this listener to process only ReferenceNodes during traversing.
*/
@@ -176,7 +179,7 @@
}
- virtual void on_node_finished(InnerNode* n){
+ virtual void on_node_finished(HMscNode* n){
ReferenceNode* ref = dynamic_cast<ReferenceNode*>(n);
if(ref!=NULL)
{
@@ -197,7 +200,7 @@
typedef std::list<BlackNodeFoundListenerP> BlackNodeFoundListenerPList;
/**
- * Traverses all accessible InnerNodes in HMsc and referenced HMsc in depth
+ * Traverses all accessible HMscNodes in HMsc and referenced HMsc in depth
* first search manner.
*
* HMsc is traversed like BMsc-graph (flattened version of HMsc - each
@@ -205,15 +208,15 @@
* many times as it is referenced. If ReferenceNode references HMsc, this HMsc
* is traversed before successors of referencing node are processed.
*
- * InnerNodes of HMsc are during traversing in different states - with different
+ * HMscNodes of HMsc are during traversing in different states - with different
* color. WHITE color means that node wasn't traversed before. GRAY nodes
* are those which have been already traversed and they are just on the stack -
* not all successors of these events were processed. BLACK nodes are those
* which have been already traversed but aren't yet on the stack - all
* successors have been processed.
*
- * Note that not all InnerNodes must be traversed by this DFSBMscGraphTraverser,
- * imagine InnerNode B which is accessible only from ReferenceNode A but A's
+ * Note that not all HMscNodes must be traversed by this DFSBMscGraphTraverser,
+ * imagine HMscNode B which is accessible only from ReferenceNode A but A's
* HMsc hasn't got any end node.
*
* @warning Non-recursive HMsc is expected.
@@ -224,7 +227,7 @@
public:
/**
- * To change default name of attribute which holds color of InnerNodes use
+ * To change default name of attribute which holds color of HMscNodes use
* color_attribute parameter.
*/
DFSBMscGraphTraverser(const std::string& color_attribute = "msc_graph_traverse_color")
@@ -312,13 +315,13 @@
}
/**
- * Returns reached InnerNodes in particular phase of traversing.
+ * Returns reached HMscNodes in particular phase of traversing.
*
- * The result corresponds to call stack on particular InnerNodes.
+ * The result corresponds to call stack on particular HMscNodes.
*
* Warning: The result is emptied when cleanup_traversing_attributes() is called
*/
- const InnerNodePListList& get_reached_nodes()
+ const NodeRelationPtrListList& get_reached_nodes()
{
return m_reached_nodes;
}
@@ -328,27 +331,34 @@
/**
* Holds nodes with set color attribute
*/
- InnerNodePListList m_colored_nodes;
+ HMscNodePListList m_colored_nodes;
/**
- * Holds currently reached InnerNodes.
+ * Holds currently reached HMscNodes.
*/
- InnerNodePListList m_reached_nodes;
+ NodeRelationPtrListList m_reached_nodes;
/**
* Cleans up traversing attributes from the top of m_colored_nodes
*/
- void cleanup_top_attributes();
+ virtual void cleanup_top_attributes();
/**
* Traverses single node
*/
- virtual bool traverse_node(InnerNode* node);
+ virtual bool traverse_node(HMscNode* node);
/**
* Traverses successors
*/
- virtual bool traverse_successors(const InnerNodePSet& successors);
+ virtual bool traverse_successors(PredecessorNode* predecessor);
+
+ /**
+ * Returns true iff node is just processed false otherwise
+ */
+ virtual bool is_processed(HMscNode* node);
+
+ virtual bool traverse_node(ReferenceNode* node);
/**
* Holds listeners
@@ -381,29 +391,29 @@
std::string m_color_attribute;
/**
- * Called when white InnerNode is found.
+ * Called when white HMscNode is found.
*/
- virtual void white_node_found(InnerNode* n);
+ virtual void white_node_found(HMscNode* n);
/**
- * Called when gray InnerNode is found.
+ * Called when gray HMscNode is found.
*/
- virtual void gray_node_found(InnerNode* n);
+ virtual void gray_node_found(HMscNode* n);
/**
- * Called when black InnerNode is found.
+ * Called when black HMscNode is found.
*/
- virtual void black_node_found(InnerNode* n);
+ virtual void black_node_found(HMscNode* n);
/**
* Called when all successors of e are processed.
*/
- virtual void node_finished(InnerNode* n);
+ virtual void node_finished(HMscNode* n);
/**
* Sets color attribute of e to c value .
*/
- void set_color(InnerNode* n, Color c)
+ void set_color(HMscNode* n, Color c)
{
n->set_attribute<Color>(m_color_attribute,c);
}
@@ -413,11 +423,14 @@
*
* If attribute isn't set it is set to default value WHITE.
*/
- Color get_color(InnerNode* n)
+ Color get_color(HMscNode* n)
{
return n->get_attribute<Color>(m_color_attribute,WHITE);
}
+ virtual void push_top_attributes();
+
+
};
Modified: trunk/src/check/dfs_hmsc_traverser.cpp
===================================================================
--- trunk/src/check/dfs_hmsc_traverser.cpp 2008-10-04 22:31:47 UTC (rev 110)
+++ trunk/src/check/dfs_hmsc_traverser.cpp 2008-10-05 18:03:03 UTC (rev 111)
@@ -18,35 +18,25 @@
#include "check/dfs_hmsc_traverser.h"
-bool DFSHMscTraverser::traverse_node(InnerNode* node)
+bool DFSHMscTraverser::traverse_node(ReferenceNode* ref_node)
{
- Color c = get_color(node);
- if(c==BLACK)
+ HMscPtr hmsc = ref_node->get_hmsc();
+ if(hmsc.get()!=NULL)
{
- black_node_found(node);
- return false;
+ m_reached_nodes.push_back(NodeRelationPtrList());
+ traverse_successors(hmsc->get_start().get());
+ m_reached_nodes.pop_back();
+
}
- if(c==GRAY)
+ return traverse_successors(ref_node);
+}
+
+void DFSHMscTraverser::cleanup_traversing_attributes()
+{
+ cleanup_top_attributes();
+ while(!m_reached_nodes.empty())
{
- gray_node_found(node);
- return false;
+ m_reached_nodes.pop_back();
}
- white_node_found(node);
- ReferenceNode* refNode = dynamic_cast<ReferenceNode*>(node);
- if(refNode!=NULL)
- {
- HMscPtr hmsc = refNode->get_hmsc();
- if(hmsc.get()!=NULL)
- {
- m_reached_nodes.push_back(InnerNodePList());
- //node's successors are traversed in all cases
- traverse_successors(hmsc->get_start()->get_successors());
- m_reached_nodes.pop_back();
- }
- }
- traverse_successors(node->get_successors());
- node_finished(node);
- //return value is no more needed
- return true;
}
Modified: trunk/src/check/dfs_hmsc_traverser.h
===================================================================
--- trunk/src/check/dfs_hmsc_traverser.h 2008-10-04 22:31:47 UTC (rev 110)
+++ trunk/src/check/dfs_hmsc_traverser.h 2008-10-05 18:03:03 UTC (rev 111)
@@ -23,11 +23,11 @@
/**
- * Traverses all ReferenceNodes in HMsc and referenced HMsc in depth
+ * Traverses all HMscNodes in HMsc and referenced HMsc in depth
* first search manner. I.e. unlike DFSBMscGraphTraverser this traverser doesn't
* care about presence of EndNodes in referenced HMsc in ReferenceNodes.
* Successors of the ReferenceNode are traversed no matter there is EndNode in
- * it's HMsc.
+ * it's HMsc. Moreover each HMsc is traversed only one time.
*
* @warning Non-recursive HMsc is expected.
*/
@@ -36,7 +36,7 @@
protected:
- bool traverse_node(InnerNode* node);
+ bool traverse_node(ReferenceNode* node);
public:
@@ -47,6 +47,8 @@
}
+ void cleanup_traversing_attributes();
+
};
Modified: trunk/src/check/footprint.cpp
===================================================================
--- trunk/src/check/footprint.cpp 2008-10-04 22:31:47 UTC (rev 110)
+++ trunk/src/check/footprint.cpp 2008-10-05 18:03:03 UTC (rev 111)
@@ -1,6 +1,207 @@
-#import "check/footprint.h"
+/*
+ * 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 Jindra Babica <ba...@ma...>
+ *
+ * $Id: bmsc_race_checker.cpp 97 2008-06-02 10:40:48Z babicaj $
+ */
+#include "check/footprint.h"
+
bool EDInstancesPtrComparator::operator()(const EDInstancesPtr& a, const EDInstancesPtr& b)
{
return a->operator <(*b.get());
-}
\ No newline at end of file
+}
+
+bool FootprintPtrComparator::operator()(const FootprintPtr& a, const FootprintPtr& b)
+{
+ return a->operator <(*b.get());
+}
+
+EventDependentInstances::EventDependentInstances(Event* event,size_t instances_count)
+{
+ m_event = event;
+ m_instances = BoolVector(instances_count,false);
+}
+
+bool EventDependentInstances::operator<(const EventDependentInstances& di) const
+{
+ return compare(di)<0;
+}
+
+int EventDependentInstances::compare(const EventDependentInstances& di) const
+{
+ if(m_event<di.m_event) return -1;
+ if(di.m_event<m_event) return 1;
+ //compare bool vector as binary number
+ for(int i=0; i<m_instances.size(); i++)
+ {
+ if(m_instances[i]!=di.m_instances[i])
+ return m_instances[i]-di.m_instances[i];
+ }
+ //otherwise this is same as di
+ return 0;
+}
+
+void EventDependentInstances::set_dependent(size_t instance)
+{
+ m_instances[instance] = true;
+}
+
+const BoolVector& EventDependentInstances::get_instances()
+{
+ return m_instances;
+}
+
+Event* EventDependentInstances::get_event()
+{
+ return m_event;
+}
+
+int ExtremeEvents::compare(
+ const EDInstancesPtrSet& first,
+ const EDInstancesPtrSet& second) const
+{
+ EDInstancesPtrSet::const_iterator first_i = first.begin();
+ EDInstancesPtrSet::const_iterator second_i = second.begin();
+ while(first_i!=first.end() && second_i!=second.end())
+ {
+ const EDInstancesPtr first_edis = *first_i;
+ const EDInstancesPtr second_edis = *second_i;
+ int comparision = first_edis->compare(*second_edis.get());
+ if(comparision!=0) return comparision;
+ first_i++;
+ second_i++;
+ }
+ return first.size()-second.size();
+}
+
+ExtremeEvents::ExtremeEvents()
+{
+
+}
+
+ExtremeEvents::ExtremeEvents(size_t instances_count)
+{
+ m_events_instances = EDInstancesPtrSetVector(instances_count);
+}
+
+bool ExtremeEvents::operator<(const ExtremeEvents& other) const
+{
+ const EDInstancesPtrSetVector& other_events = other.get_events_instances();
+ for(size_t i=0;i<m_events_instances.size();i++)
+ {
+ int comparision = compare(m_events_instances[i],other_events[i]);
+ if(comparision!=0)
+ {
+ return comparision<0;
+ }
+ }
+ //otherwise this is supposed to be same as other
+ return false;
+}
+
+void ExtremeEvents::add_extreme_event(size_t instance, EDInstancesPtr& edis)
+{
+ m_events_instances[instance].insert(edis);
+}
+
+const EDInstancesPtrSetVector& ExtremeEvents::get_events_instances() const
+{
+ return m_events_instances;
+}
+
+
+Footprint::Footprint(StartNode* start, size_t instances_count):ExtremeEvents(instances_count)
+{
+ m_path.push_back(start);
+}
+
+Footprint::Footprint(
+ FootprintPtr previous,
+ const InnerNodePList& path,
+ const ExtremeEvents& max_events_less,
+ const ExtremeEvents& max_events_greater)
+ :ExtremeEvents(previous->get_events_instances().size())
+{
+ const EDInstancesPtrSetVector& previous_events = previous->get_events_instances();
+ const EDInstancesPtrSetVector& events_less = max_events_less.get_events_instances();
+ const EDInstancesPtrSetVector& events_greater = max_events_greater.get_events_instances();
+
+ m_previous = previous;
+ m_path.insert(m_path.begin(),path.begin(),path.end());
+ size_t instances_count = previous_events.size();
+
+ for(size_t i=0; i<instances_count; i++)
+ {
+ /*
+ * If events_greater[i] contains any EDInstances these will become part
+ * of new Footprint - doesn't care about previous_events[i]
+ */
+ if(events_greater[i].size()>0)
+ {
+ m_events_instances[i] = events_greater[i];
+ }
+ else if(previous_events[i].size()>0)
+ {
+ /*
+ * Let previous_edi be a EvendDependntInstaces in previous_events[i]. Find
+ * less_edi (EventDependentInstances) from events_less and instance
+ * index j such that (less_edi.m_instances[j]==true and
+ * previous_edi.m_instances[j]==true).
+ *
+ * Let new_edi be copied previous_edi (the new_edi will be inserted into
+ * m_events_instances[i]). If there is any less_edi and index j as
+ * described in previous paragraph then new_edi.m_instances[j]==true.
+ */
+ EDInstancesPtrSet::const_iterator previous_edi;
+ for(previous_edi=previous_events[i].begin();previous_edi!=previous_events[i].end();previous_edi++)
+ {
+ EDInstancesPtr new_edi = new EventDependentInstances(**previous_edi);
+ const BoolVector& previous_edi_instances = (*previous_edi)->get_instances();
+ for(size_t j=0;j<instances_count;j++)
+ {
+ EDInstancesPtrSet::const_iterator less_edi;
+ for(less_edi=events_less[j].begin();less_edi!=events_less[j].end();less_edi++)
+ {
+ const BoolVector& less_edi_instances = (*less_edi)->get_instances();
+ size_t y=0;
+ for(;y<instances_count;y++)
+ {
+ if(previous_edi_instances[y]&&less_edi_instances[y])
+ {
+ break;
+ }
+ }
+ if(y!=instances_count)
+ {
+ break;
+ }
+ }
+ if(less_edi!=events_less[j].end())
+ {
+ new_edi->set_dependent(j);
+ break;
+ }
+ }
+ m_events_instances[i].insert(new_edi);
+ }
+ }
+ }
+}
+
+PredecessorNode* Footprint::get_node()
+{
+ return m_path.back();
+}
+
Modified: trunk/src/check/footprint.h
===================================================================
--- trunk/src/check/footprint.h 2008-10-04 22:31:47 UTC (rev 110)
+++ trunk/src/check/footprint.h 2008-10-05 18:03:03 UTC (rev 111)
@@ -1,3 +1,21 @@
+/*
+ * 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 Jindra Babica <ba...@ma...>
+ *
+ * $Id: bmsc_race_checker.cpp 97 2008-06-02 10:40:48Z babicaj $
+ */
+
#ifndef _FOOTPRINT_H
#define _FOOTPRINT_H
@@ -3,4 +21,5 @@
#include <map>
#include <set>
+#include <list>
#include "data/msc.h"
@@ -13,6 +32,8 @@
typedef std::vector<bool> BoolVector;
typedef counted_ptr<EventDependentInstances> EDInstancesPtr;
typedef counted_ptr<Footprint> FootprintPtr;
+typedef std::list<InnerNode*> InnerNodePList;
+typedef std::list<PredecessorNode*> PredecessorNodePList;
class EDInstancesPtrComparator
{
@@ -20,10 +41,17 @@
bool operator()(const EDInstancesPtr& a, const EDInstancesPtr& b);
};
+class FootprintPtrComparator
+{
+public:
+ bool operator()(const FootprintPtr& a, const FootprintPtr& b);
+};
+
typedef std::set<EDInstancesPtr,EDInstancesPtrComparator> EDInstancesPtrSet;
+typedef std::vector<EDInstancesPtrSet> EDInstancesPtrSetVector;
/**
- * Represents dependent Instances -- contain lesser/grater (depends on chosen semantic)
+ * Represents dependent Instances -- contain lesser/greater (depends on chosen semantic)
* Event then the Event with specified m_event in this class.
*/
class EventDependentInstances
@@ -39,8 +67,8 @@
/**
* Each Instance i must have its own number. For this vector m_instances holds:
- * m_instances[i]==true iff i contains any greater/lesser Event than the Event e with
- * id == m_event_id.
+ * m_instances[i]==true iff i contains any greater/lesser Event than the Event
+ * m_event.
*/
BoolVector m_instances;
@@ -49,45 +77,25 @@
/**
*
*/
- EventDependentInstances(Event* event,size_t instances_count)
- {
- m_event = event;
- m_instances = BoolVector(instances_count,false);
- }
+ EventDependentInstances(Event* event,size_t instances_count);
/**
* Used in std::set as comparision method
*
* The di is supposed to have m_instances as large as this one has.
*/
- bool operator<(const EventDependentInstances& di) const
- {
- return compare(di)<0;
- }
+ bool operator<(const EventDependentInstances& di) const;
/**
* Returns -1 for this<di, 0 for this==di and 1 for this>di
*/
- int compare(const EventDependentInstances& di) const
- {
- if(m_event<di.m_event) return -1;
- if(di.m_event<m_event) return 1;
- //compare bool vector as binary number
- for(int i=0; i<m_instances.size(); i++)
- {
- if(m_instances[i]!=di.m_instances[i])
- return m_instances[i]-di.m_instances[i];
- }
- //otherwise this is same as di
- return 0;
- }
+ int compare(const EventDependentInstances& di) const;
- void set_dependent(size_t instance)
- {
- m_instances[instance] = true;
- }
+ void set_dependent(size_t instance);
+ const BoolVector& get_instances();
+ Event* get_event();
};
@@ -100,43 +108,39 @@
* Holds greater/lesser Instances of Events accessible under id of Event's
* Instance.
*/
- EDInstancesPtrSet m_events_instances;
+ EDInstancesPtrSetVector m_events_instances;
+ /**
+ * Compares first and second like they would be a strings.
+ *
+ * Compares element by element, if any less/greater element in first is found
+ * than an element of second at the same position, first is declared to be
+ * less/greater than second.
+ *
+ * Returns x<0 if first < second, 0 if first == second, x>0 if first > second
+ */
+ int compare(
+ const EDInstancesPtrSet& first,
+ const EDInstancesPtrSet& second) const;
+
public:
- ExtremeEvents()
- {
- }
+ ExtremeEvents();
+ ExtremeEvents(size_t instances_count);
+
/**
- * Compares ExtremeEvents by items.
+ * Compares ExtremeEvents item by item.
+ *
+ * Items are supposed to be separate EDInstancesPtrSets which are elements
+ * of m_events_instances. Empty item i (empty EDInstancesPtrSet) is supposed
+ * to be less than anything else which is not empty.
*/
- bool operator<(const ExtremeEvents& extreme) const
- {
- EDInstancesPtrSet::const_iterator my_i = m_events_instances.begin();
- EDInstancesPtrSet::const_iterator extreme_i = extreme.m_events_instances.begin();
- while(my_i!=m_events_instances.end() && extreme_i!=extreme.m_events_instances.end())
- {
- const EDInstancesPtr my_edis = *my_i;
- const EDInstancesPtr extreme_edis = *extreme_i;
- int comparision = my_edis->compare(*extreme_edis.get());
- if(comparision!=0) return comparision<0;
- my_i++;
- extreme_i++;
- }
- //otherwise this is same as extreme
- return false;
- }
+ bool operator<(const ExtremeEvents& other) const;
- void add_extreme_event(EDInstancesPtr& ...
[truncated message content] |
|
From: <ba...@us...> - 2008-10-12 15:02:54
|
Revision: 112
http://scstudio.svn.sourceforge.net/scstudio/?rev=112&view=rev
Author: babicaj
Date: 2008-10-12 15:02:42 +0000 (Sun, 12 Oct 2008)
Log Message:
-----------
Traversers modified with respect to graphical information, checkers need to be updated
Modified Paths:
--------------
trunk/src/check/dfs_bmsc_graph_traverser.cpp
trunk/src/check/dfs_bmsc_graph_traverser.h
trunk/src/check/dfs_events_traverser.cpp
trunk/src/check/dfs_events_traverser.h
trunk/src/check/dfs_hmsc_traverser.cpp
trunk/src/check/dfs_instance_events_traverser.cpp
trunk/src/check/refnode_finder.cpp
trunk/src/check/refnode_finder.h
trunk/src/data/msc.cpp
trunk/src/data/msc.h
trunk/src/data/msc_visual.h
Modified: trunk/src/check/dfs_bmsc_graph_traverser.cpp
===================================================================
--- trunk/src/check/dfs_bmsc_graph_traverser.cpp 2008-10-05 18:03:03 UTC (rev 111)
+++ trunk/src/check/dfs_bmsc_graph_traverser.cpp 2008-10-12 15:02:42 UTC (rev 112)
@@ -32,8 +32,16 @@
cleanup_traversing_attributes();
}
+void DFSBMscGraphTraverser::traverse(HMscNode* node)
+{
+ push_top_attributes();
+ traverse_node(node);
+ cleanup_traversing_attributes();
+}
+
bool DFSBMscGraphTraverser::traverse_node(HMscNode* node)
{
+ m_reached_elements.back().push_back(node);
if(is_processed(node))
{
return false;
@@ -96,8 +104,9 @@
relation!=predecessor->get_successors().end();relation++)
{
const NodeRelationPtr& rel = *relation;
- m_reached_nodes.back().push_back(rel);
+ m_reached_elements.back().push_back(rel.get());
end_found = traverse_node((HMscNode*)rel->get_successor()) || end_found;
+ m_reached_elements.back().pop_back();
}
return end_found;
}
@@ -132,7 +141,6 @@
for(l=m_white_node_found_listeners.begin();l!=m_white_node_found_listeners.end();l++)
(*l)->on_white_node_found(n);
set_color(n,GRAY);
- m_colored_nodes.back().push_back(n);
}
void DFSBMscGraphTraverser::gray_node_found(HMscNode* n)
@@ -140,7 +148,7 @@
GrayNodeFoundListenerPList::iterator l;
for(l=m_gray_node_found_listeners.begin();l!=m_gray_node_found_listeners.end();l++)
(*l)->on_gray_node_found(n);
- m_reached_nodes.back().pop_back();
+ m_reached_elements.back().pop_back();
}
void DFSBMscGraphTraverser::black_node_found(HMscNode* n)
@@ -148,7 +156,7 @@
BlackNodeFoundListenerPList::iterator l;
for(l=m_black_node_found_listeners.begin();l!=m_black_node_found_listeners.end();l++)
(*l)->on_black_node_found(n);
- m_reached_nodes.back().pop_back();
+ m_reached_elements.back().pop_back();
}
void DFSBMscGraphTraverser::node_finished(HMscNode* n)
@@ -156,7 +164,7 @@
NodeFinishedListenerPList::iterator l;
for(l=m_node_finished_listeners.begin();l!=m_node_finished_listeners.end();l++)
(*l)->on_node_finished(n);
- m_reached_nodes.back().pop_back();
+ m_reached_elements.back().pop_back();
set_color(n,BLACK);
}
@@ -167,12 +175,12 @@
for(event=top.begin();event!=top.end();event++)
(*event)->remove_attribute<Color>(m_color_attribute);
m_colored_nodes.pop_back();
- m_reached_nodes.pop_back();
+ m_reached_elements.pop_back();
}
void DFSBMscGraphTraverser::push_top_attributes()
{
m_colored_nodes.push_back(HMscNodePList());
- m_reached_nodes.push_back(NodeRelationPtrList());
+ m_reached_elements.push_back(MscElementPList());
}
Modified: trunk/src/check/dfs_bmsc_graph_traverser.h
===================================================================
--- trunk/src/check/dfs_bmsc_graph_traverser.h 2008-10-05 18:03:03 UTC (rev 111)
+++ trunk/src/check/dfs_bmsc_graph_traverser.h 2008-10-12 15:02:42 UTC (rev 112)
@@ -26,8 +26,8 @@
typedef std::list<HMscNode*> HMscNodePList;
typedef std::list<HMscNodePList> HMscNodePListList;
-typedef std::list<NodeRelationPtr> NodeRelationPtrList;
-typedef std::list<NodeRelationPtrList> NodeRelationPtrListList;
+typedef std::list<MscElement*> MscElementPList;
+typedef std::list<MscElementPList> MscElementPListList;
/**
@@ -245,6 +245,8 @@
*/
virtual void traverse(HMscPtr hmsc);
+ virtual void traverse(HMscNode* node);
+
/**
* Cleans up traversing attributes
*/
@@ -321,9 +323,9 @@
*
* Warning: The result is emptied when cleanup_traversing_attributes() is called
*/
- const NodeRelationPtrListList& get_reached_nodes()
+ const MscElementPListList& get_reached_elements()
{
- return m_reached_nodes;
+ return m_reached_elements;
}
protected:
@@ -334,9 +336,9 @@
HMscNodePListList m_colored_nodes;
/**
- * Holds currently reached HMscNodes.
+ * Holds currently reached HMscElements.
*/
- NodeRelationPtrListList m_reached_nodes;
+ MscElementPListList m_reached_elements;
/**
* Cleans up traversing attributes from the top of m_colored_nodes
Modified: trunk/src/check/dfs_events_traverser.cpp
===================================================================
--- trunk/src/check/dfs_events_traverser.cpp 2008-10-05 18:03:03 UTC (rev 111)
+++ trunk/src/check/dfs_events_traverser.cpp 2008-10-12 15:02:42 UTC (rev 112)
@@ -32,66 +32,70 @@
const InstancePtrList& instances = bmsc->get_instances();
for(instance=instances.begin(); instance!=instances.end(); instance++)
{
- traverse_area((*instance)->get_first());
+ traverse_area((*instance)->get_first().get());
}
cleanup_traversing_attributes();
}
-void DFSEventsTraverser::traverse_area(EventAreaPtr area)
+void DFSEventsTraverser::traverse_area(EventArea* area)
{
- //area is really set
- if(area.get())
- try
+ StrictOrderArea* strict = dynamic_cast<StrictOrderArea*>(area);
+ if(strict)
+ {
+ if(strict->is_empty())
+ traverse_area(strict->get_next().get());
+ else
+ traverse_strict_event(strict->get_first().get());
+ }
+ else
+ {
+ CoregionArea* coregion = dynamic_cast<CoregionArea*>(area);
+ //Does CoregionArea have any event?
+ if(coregion->is_empty())
+ traverse_area(coregion->get_next().get());
+ else
{
- StrictOrderAreaPtr strict = area;
- if(strict->is_empty())
- traverse_area(strict->get_next());
- else
- traverse_strict_event(strict->get_first().get());
+ const CoregionEventPSet& minimals = coregion->get_minimal_events();
+ CoregionEventPSet::const_iterator min;
+ for(min=minimals.begin(); min!=minimals.end(); min++)
+ traverse_coregion_event(*min);
}
- catch(std::bad_cast& bd)
- {
- CoregionAreaPtr coregion = area;
- //Does CoregionArea have any event?
- if(coregion->is_empty())
- traverse_area(coregion->get_next());
- else
- {
- const CoregionEventPSet& minimals = coregion->get_minimal_events();
- CoregionEventPSet::const_iterator min;
- for(min=minimals.begin(); min!=minimals.end(); min++)
- traverse_coregion_event(*min);
- }
- }
+ }
}
void DFSEventsTraverser::traverse_strict_event(StrictEvent* event)
{
if(!is_processed(event))
{
+ m_reached_elements.push_back(event);
traverse_matching_event(event);
if(event->get_successor().get())
traverse_strict_event(event->get_successor().get());
else
- traverse_area(event->get_area()->get_next());
+ traverse_area(event->get_area()->get_next().get());
event_finished(event);
}
}
void DFSEventsTraverser::traverse_coregion_event(CoregionEvent* event)
{
+ m_reached_elements.push_back(event);
if(!is_processed(event))
{
traverse_matching_event(event);
if(event->get_successors().size()!=0)
{
- const CoregionEventPSet& successors = event->get_successors();
- CoregionEventPSet::const_iterator successor;
+ const CoregEventRelPtrSet& successors = event->get_successors();
+ CoregEventRelPtrSet::const_iterator successor;
for(successor=successors.begin(); successor!=successors.end(); successor++)
- traverse_coregion_event(*successor);
+ {
+ m_reached_elements.push_back((*successor).get());
+ traverse_coregion_event((*successor)->get_successor());
+ m_reached_elements.pop_back();
+ }
}
else
- traverse_area(event->get_area()->get_next());
+ traverse_area(event->get_area()->get_next().get());
event_finished(event);
}
}
@@ -100,6 +104,7 @@
{
if(event->is_send() && event->get_matching_event())
{
+ m_reached_elements.push_back(event->get_message().get());
StrictEvent* strict = dynamic_cast<StrictEvent*>(event->get_matching_event());
if(strict)
{
@@ -110,6 +115,7 @@
CoregionEvent* e = dynamic_cast<CoregionEvent*>(event->get_matching_event());
traverse_coregion_event(e);
}
+ m_reached_elements.pop_back();
}
}
@@ -142,7 +148,6 @@
{
set_color(e,GRAY);
m_colored_events.push_back(e);
- m_reached_events.push_back(e);
WhiteEventFoundListenerPList::iterator l;
for(l=white_event_found_listeners.begin();l!=white_event_found_listeners.end();l++)
(*l)->on_white_event_found(e);
@@ -153,6 +158,7 @@
GrayEventFoundListenerPList::iterator l;
for(l=gray_event_found_listeners.begin();l!=gray_event_found_listeners.end();l++)
(*l)->on_gray_event_found(e);
+ m_reached_elements.pop_back();
}
void DFSEventsTraverser::black_event_found(Event* e)
@@ -160,6 +166,7 @@
BlackEventFoundListenerPList::iterator l;
for(l=black_event_found_listeners.begin();l!=black_event_found_listeners.end();l++)
(*l)->on_black_event_found(e);
+ m_reached_elements.pop_back();
}
void DFSEventsTraverser::event_finished(Event* e)
@@ -168,7 +175,7 @@
EventFinishedListenerPList::iterator l;
for(l=event_finished_listeners.begin();l!=event_finished_listeners.end();l++)
(*l)->on_event_finished(e);
- m_reached_events.pop_back();
+ m_reached_elements.pop_back();
}
EventPList* DFSEventsTraverser::topology_order(BMscPtr b)
Modified: trunk/src/check/dfs_events_traverser.h
===================================================================
--- trunk/src/check/dfs_events_traverser.h 2008-10-05 18:03:03 UTC (rev 111)
+++ trunk/src/check/dfs_events_traverser.h 2008-10-12 15:02:42 UTC (rev 112)
@@ -23,6 +23,7 @@
#include "check/checker.h"
typedef std::list<Event*> EventPList;
+typedef std::list<MscElement*> MscElementPList;
/**
* Listener of founded white Event
@@ -156,9 +157,9 @@
*/
virtual void cleanup_traversing_attributes();
- const EventPList& get_reached_events()
+ const MscElementPList& get_reached_elements()
{
- return m_reached_events;
+ return m_reached_elements;
}
static EventPList* topology_order(BMscPtr b);
@@ -166,9 +167,9 @@
protected:
/**
- * Holds list path to currently reached event
+ * Holds path to currently reached event
*/
- EventPList m_reached_events;
+ MscElementPList m_reached_elements;
/**
* List of colored events during traversing.
@@ -205,7 +206,7 @@
*/
static const std::string color_attribute;
- virtual void traverse_area(EventAreaPtr area);
+ virtual void traverse_area(EventArea* area);
virtual void traverse_strict_event(StrictEvent* event);
Modified: trunk/src/check/dfs_hmsc_traverser.cpp
===================================================================
--- trunk/src/check/dfs_hmsc_traverser.cpp 2008-10-05 18:03:03 UTC (rev 111)
+++ trunk/src/check/dfs_hmsc_traverser.cpp 2008-10-12 15:02:42 UTC (rev 112)
@@ -23,9 +23,9 @@
HMscPtr hmsc = ref_node->get_hmsc();
if(hmsc.get()!=NULL)
{
- m_reached_nodes.push_back(NodeRelationPtrList());
+ m_reached_elements.push_back(MscElementPList());
traverse_successors(hmsc->get_start().get());
- m_reached_nodes.pop_back();
+ m_reached_elements.pop_back();
}
return traverse_successors(ref_node);
@@ -34,9 +34,9 @@
void DFSHMscTraverser::cleanup_traversing_attributes()
{
cleanup_top_attributes();
- while(!m_reached_nodes.empty())
+ while(!m_reached_elements.empty())
{
- m_reached_nodes.pop_back();
+ m_reached_elements.pop_back();
}
}
Modified: trunk/src/check/dfs_instance_events_traverser.cpp
===================================================================
--- trunk/src/check/dfs_instance_events_traverser.cpp 2008-10-05 18:03:03 UTC (rev 111)
+++ trunk/src/check/dfs_instance_events_traverser.cpp 2008-10-12 15:02:42 UTC (rev 112)
@@ -21,35 +21,41 @@
void DFSInstanceEventsTraverser::traverse_strict_event(StrictEvent* event)
{
+ m_reached_elements.push_back(event);
if(!is_processed(event))
{
if(event->get_successor().get())
traverse_strict_event(event->get_successor().get());
else
- traverse_area(event->get_area()->get_next());
+ traverse_area(event->get_area()->get_next().get());
event_finished(event);
}
}
void DFSInstanceEventsTraverser::traverse(Instance* instance)
{
- traverse_area(instance->get_first());
+ traverse_area(instance->get_first().get());
cleanup_traversing_attributes();
}
void DFSInstanceEventsTraverser::traverse_coregion_event(CoregionEvent* event)
{
+ m_reached_elements.push_back(event);
if(!is_processed(event))
{
- if(event->get_successors().size()!=0)
+ if(event->has_successors())
{
- const CoregionEventPSet& successors = event->get_successors();
- CoregionEventPSet::const_iterator successor;
+ const CoregEventRelPtrSet& successors = event->get_successors();
+ CoregEventRelPtrSet::const_iterator successor;
for(successor=successors.begin(); successor!=successors.end(); successor++)
- traverse_coregion_event(*successor);
+ {
+ m_reached_elements.push_back((*successor).get());
+ traverse_coregion_event((*successor)->get_successor());
+ m_reached_elements.pop_back();
+ }
}
else
- traverse_area(event->get_area()->get_next());
+ traverse_area(event->get_area()->get_next().get());
event_finished(event);
}
}
Modified: trunk/src/check/refnode_finder.cpp
===================================================================
--- trunk/src/check/refnode_finder.cpp 2008-10-05 18:03:03 UTC (rev 111)
+++ trunk/src/check/refnode_finder.cpp 2008-10-12 15:02:42 UTC (rev 112)
@@ -20,6 +20,7 @@
bool ReferenceNodeFinder::traverse_node(HMscNode* node)
{
+ m_reached_elements.back().push_back(node);
if(is_processed(node))
{
//return value is no more needed
@@ -40,13 +41,3 @@
//return value is no more needed
return true;
}
-
-void ReferenceNodeFinder::traverse(HMscNode* node)
-{
- PredecessorNode* pred = dynamic_cast<PredecessorNode*>(node);
- if(pred){
- push_top_attributes();
- traverse_successors(pred);
- cleanup_traversing_attributes();
- }
-}
Modified: trunk/src/check/refnode_finder.h
===================================================================
--- trunk/src/check/refnode_finder.h 2008-10-05 18:03:03 UTC (rev 111)
+++ trunk/src/check/refnode_finder.h 2008-10-12 15:02:42 UTC (rev 112)
@@ -35,14 +35,6 @@
}
- /**
- * \brief Traverses HMsc of the node until ReferenceNodes are found.
- *
- * This traverser continues in traversing until first ReferenceNode successors
- * of the node are found.
- */
- void traverse(HMscNode* node);
-
protected:
bool traverse_node(HMscNode* node);
Modified: trunk/src/data/msc.cpp
===================================================================
--- trunk/src/data/msc.cpp 2008-10-05 18:03:03 UTC (rev 111)
+++ trunk/src/data/msc.cpp 2008-10-12 15:02:42 UTC (rev 112)
@@ -56,11 +56,6 @@
return m_owner->find_ptr(this);
}
-inline Instance* Event::get_instance()
-{
- return m_area->get_instance();
-}
-
inline StrictOrderArea* StrictEvent::get_strict_order_area()
{
return dynamic_cast<StrictOrderArea*>(m_area);
@@ -68,38 +63,14 @@
CoregionArea::~CoregionArea()
{
- CoregionEventPSet::iterator e;
- CoregionEventPQueue to_delete;
- for(e=m_minimal_events.begin();e!=m_minimal_events.end();e++)
- {
- to_delete.push(*e);
- }
- while(!to_delete.empty())
- {
- CoregionEvent* event = to_delete.front();
- to_delete.pop();
- CoregionEventPSet::iterator e;
- for(e=event->m_predecessors.begin();e!=event->m_predecessors.end();e++)
- (*e)->m_successors.erase(event);
- for(e=event->m_successors.begin();e!=event->m_successors.end();e++)
- {
- (*e)->m_predecessors.erase(event);
- to_delete.push(*e);
- }
- if(event->is_matched())
- {
- if(event->is_receive())
- event->get_matching_event()->get_message()->set_sender(NULL);
- else
- event->get_matching_event()->get_message()->set_receiver(NULL);
- }
- delete event;
- }
}
-CoregionEvent::CoregionEvent(CoregionArea* area)
+void CoregionArea::add_event(CoregionEventPtr e)
{
- m_area = area;
+ //TODO: check whether it is possible to insert e
+ m_events.insert(e);
+ add_minimal_event(e.get());
+ add_maximal_event(e.get());
}
CoregionEvent::~CoregionEvent()
@@ -107,22 +78,24 @@
}
-inline void CoregionEvent::add_successor(CoregionEvent* e)
+inline void CoregionEvent::add_successor(CoregEventRelPtr e)
{
+ //TODO: check whether e's successor is really in the same coregion area
m_successors.insert(e);
+ e->set_predecessor(this);
get_coregion_area()->remove_maximal_event(this);
- e->m_predecessors.insert(this);
- get_coregion_area()->remove_minimal_event(e);
+ e->get_successor()->m_predecessors.insert(e);
+ e->get_successor()->get_coregion_area()->remove_minimal_event(e->get_successor());
}
-void CoregionEvent::remove_successor(CoregionEvent* e)
+void CoregionEvent::remove_successor(CoregEventRelPtr e)
{
m_successors.erase(e);
- if(m_successors.size()==0)
+ if(!has_successors())
get_coregion_area()->add_maximal_event(this);
- e->m_predecessors.erase(this);
- if(e->m_predecessors.size()==0)
- get_coregion_area()->add_minimal_event(e);
+ e->get_successor()->m_predecessors.erase(e);
+ if(!e->get_successor()->has_predecessors())
+ get_coregion_area()->add_minimal_event(e->get_successor());
}
CoregionArea* CoregionEvent::get_coregion_area()
Modified: trunk/src/data/msc.h
===================================================================
--- trunk/src/data/msc.h 2008-10-05 18:03:03 UTC (rev 111)
+++ trunk/src/data/msc.h 2008-10-12 15:02:42 UTC (rev 112)
@@ -82,6 +82,7 @@
typedef counted_ptr<CoregionEvent> CoregionEventPtr;
typedef std::list<CoregionEventPtr> CoregionEventPtrList;
+typedef std::set<CoregionEventPtr> CoregionEventPtrSet;
typedef std::set<CoregionEvent*> CoregionEventPSet;
typedef std::list<CoregionEvent*> CoregionEventPList;
typedef std::queue<CoregionEvent*> CoregionEventPQueue;
@@ -124,38 +125,13 @@
protected:
- /**
- * \brief Creates MscElement referencing the original one.
- *
- * Used to create counter example with reference to original element which
- * should be accessible from the new one.
- */
- MscElement(MscElement* original=NULL, bool marked=false)
+ MscElement(bool marked=false)
{
- m_original = original;
m_marked = marked;
}
- virtual ~MscElement()
- {
+ virtual ~MscElement();
- }
-
- /**
- * \brief Pointer to original version of MscElement.
- *
- * Checking algorithms returns as their result violating example of BMsc or
- * path in HMsc. To show exact violating example they must often change the
- * original version of BMsc or HMsc. However, it is neccessary to keep
- * original unmodified version, therefore they must create copy of the
- * structure that violated some property.
- *
- * Moreover it is neccessary to keep relationship between original MscElement
- * and the newly created one. Therefore algorithms keep this relation in this
- * attribute.
- */
- MscElement* m_original;
-
public:
/**
@@ -274,11 +250,54 @@
m_attributes.erase(i);
}
}
+
+ bool get_marked()
+ {
+ return m_marked;
+ }
+
+ void set_marked(bool marked)
+ {
+ m_marked = marked;
+ }
+};
+template <class T>
+class MscElementTmpl : public MscElement
+{
+protected:
+
/**
+ * \brief Pointer to original version of MscElement.
+ *
+ * Checking algorithms returns as their result violating example of BMsc or
+ * path in HMsc. To show exact violating example they must often change the
+ * original version of BMsc or HMsc. However, it is neccessary to keep
+ * original unmodified version, therefore they must create copy of the
+ * structure that violated some property.
+ *
+ * Moreover it is neccessary to keep relationship between original MscElement
+ * and the newly created one. Therefore algorithms keep this relation in this
+ * attribute.
+ */
+ T* m_original;
+
+ /**
+ * \brief Creates MscElement referencing the original one.
+ *
+ * Used to create counter example with reference to original element which
+ * should be accessible from the new one.
+ */
+ MscElementTmpl<T>(T* original=NULL, bool marked=false):MscElement(marked)
+ {
+ m_original = original;
+ }
+
+public:
+ /**
* Getter for m_original.
*/
- MscElement* get_original()
+ T* get_original()
{
return m_original;
}
@@ -286,26 +305,16 @@
/**
* Setter for m_original.
*/
- void set_original(MscElement* e)
+ void set_original(T* e)
{
m_original = e;
}
-
- bool get_marked()
- {
- return m_marked;
- }
-
- void set_marked(bool marked)
- {
- m_marked = marked;
- }
};
/**
* \brief Represents virtual base class for BMsc and HMsc.
*/
-class Msc:public MscElement
+class Msc:public MscElementTmpl<Msc>
{
protected:
@@ -315,7 +324,7 @@
*/
std::string m_label;
- Msc(Msc* original=NULL):MscElement(original)
+ Msc(Msc* original=NULL):MscElementTmpl<Msc>(original)
{
}
@@ -400,7 +409,7 @@
/**
* \brief Base abstract class for node of HMsc
*/
-class HMscNode:public MscElement
+class HMscNode:public MscElementTmpl<HMscNode>
{
std::string m_label;
@@ -414,7 +423,7 @@
/**
* This is an abstract class
*/
- HMscNode(HMscNode* original=NULL):MscElement(original)
+ HMscNode(HMscNode* original=NULL):MscElementTmpl<HMscNode>(original)
{}
public:
@@ -456,7 +465,7 @@
};
-class NodeRelation:MscElement
+class NodeRelation:public MscElementTmpl<NodeRelation>
{
protected:
@@ -469,7 +478,7 @@
public:
NodeRelation(SuccessorNode* successor, PredecessorNode* predecessor,
- const PolyLine& line)
+ const PolyLine& line):MscElementTmpl<NodeRelation>()
{
m_successor = successor;
m_predecessor = predecessor;
@@ -820,13 +829,23 @@
* There isn't used std::list or something similar because it is necessary
* to have next EventArea accessible from the previous one.
*/
-class Instance:public MscElement
+class Instance:public MscElementTmpl<Instance>
{
/**
- * Label of process.
+ * Label of instance -- name of concrete instance
*/
std::string m_label;
+
+ /**
+ * Kind of instance -- name of particular type of instance
+ */
+ std::string m_kind;
+
+ /**
+ * Form of instance axis (line/column)
+ */
+ InstanceAxisForm m_form;
/**
* EventAreas which occure at instance as first one.
@@ -840,8 +859,10 @@
*/
BMsc* m_bmsc;
- float m_height;
+ Size m_height;
+ Size m_width;
+
public:
/**
@@ -858,7 +879,7 @@
* @param msc - BMsc which Instance will occure in
* @param original - original Instance, used when creating counter example
*/
- Instance(BMsc* msc, Instance* original):MscElement(original)
+ Instance(BMsc* msc, Instance* original):MscElementTmpl<Instance>(original)
{
m_bmsc = msc;
}
@@ -899,12 +920,12 @@
return m_bmsc;
}
- float get_height()
+ Size get_height()
{
return m_height;
}
- void set_height(float height)
+ void set_height(Size height)
{
m_height = height;
}
@@ -915,7 +936,7 @@
/**
* \brief Message sent by Instances.
*/
-class MscMessage:public MscElement
+class MscMessage:public MscElementTmpl<MscMessage>
{
/**
* Label of message.
@@ -956,7 +977,7 @@
* @param original - original MscMessage
*/
MscMessage(Instance* sender, Instance* receiver, MscMessage* original):
- MscElement(original)
+ MscElementTmpl<MscMessage>(original)
{
m_sender = sender;
m_receiver = receiver;
@@ -1004,10 +1025,14 @@
/**
* \brief Event which occurs in EventArea.
*/
-class Event:public MscElement
+class Event:public MscElementTmpl<Event>
{
protected:
+
+ Coordinate m_y;
+
+ PositionOnAxis m_position;
/**
* Label of message whose this is send or receive event.
@@ -1021,53 +1046,27 @@
* @warning counted_ptr mustn't be used because of possible cyclic dependency
*/
Event* m_matching_event;
-
+
/**
- * EventArea which this Event occures in.
- *
- * @warning counted_ptr mustn't be used because of possible cyclic dependency
- */
- EventArea* m_area;
-
- Event(){}
-
- /**
- * @param area - EventArea which event occures in
- */
- Event(EventArea* area)
- {
- m_area = area;
- }
-
- /**
- * @param area - EventArea which Event occures in
* @param message - message which is sent from this Event or is received
* @param original - original Event of this Event
- *
- * TODO: throw exception if message hasn't got same sender or receiver as area.
*/
- Event(EventArea* area, MscMessagePtr message, Event* original=NULL)
- :MscElement(original)
+ Event(MscMessagePtr message, Event* original=NULL)
+ :MscElementTmpl<Event>(original)
{
- m_area = area;
m_message = message;
}
/**
- * @param area - EventArea which Event occures in
* @param message - matching Event of this Event (send or receive Event)
* @param original - original Event of this Event
*
* It is supposed parameter matching to have set message which will be same
* for this Event.
- *
- * TODO: throw exception if message hasn't got same sender or receiver as area
- * or matching hasn't got set message
*/
- Event(EventArea* area, Event* matching, Event* original=NULL)
- :MscElement(original)
+ Event(Event* matching, Event* original=NULL)
+ :MscElementTmpl<Event>(original)
{
- m_area = area;
m_message = matching->m_message;
m_matching_event = matching;
matching->m_matching_event = this;
@@ -1132,21 +1131,70 @@
/**
* Returns instance which this event occures at
*/
- Instance* get_instance();
+ virtual Instance* get_instance()=0;
+};
+
+
+template <class TArea>
+class EventTmpl:public Event
+{
+protected:
+
/**
+ * EventArea which this Event occures in.
+ *
+ * @warning counted_ptr mustn't be used because of possible cyclic dependency
+ */
+ TArea* m_area;
+
+ /**
+ * @param message - message which is sent from this Event or is received
+ * @param original - original Event of this Event
+ */
+ EventTmpl(MscMessagePtr message, Event* original=NULL)
+ :Event(message,original)
+ {
+ }
+
+ /**
+ * @param message - matching Event of this Event (send or receive Event)
+ * @param original - original Event of this Event
+ *
+ * It is supposed parameter matching to have set message which will be same
+ * for this Event.
+ */
+ EventTmpl(Event* matching, Event* original=NULL)
+ :Event(matching,original)
+ {
+ }
+
+public:
+
+ /**
* Returns EventArea which this Event occures in
*/
- EventArea* get_area()
+ TArea* get_area()
{
return m_area;
}
+
+ void set_area(TArea* area)
+ {
+ m_area = area;
+ }
+
+ Instance* get_instance()
+ {
+ return m_area->get_instance();
+ }
+
};
/**
* \brief Event occurring in StrictOrderArea
*/
-class StrictEvent: public Event
+class StrictEvent: public EventTmpl<StrictOrderArea>
{
protected:
@@ -1168,8 +1216,8 @@
/**
* See Event constructor for details
*/
- StrictEvent(StrictOrderArea* area, MscMessagePtr message, Event* original=NULL)
- :Event((EventArea*)area,message,original)
+ StrictEvent(MscMessagePtr message, Event* original=NULL)
+ :EventTmpl<StrictOrderArea>(message,original)
{
m_predecessor = NULL;
}
@@ -1177,8 +1225,8 @@
/**
* See Event constructor for details
*/
- StrictEvent(StrictOrderArea* area, Event* matching_event, Event* original=NULL)
- :Event((EventArea*)area,matching_event,original)
+ StrictEvent(Event* matching_event, Event* original=NULL)
+ :EventTmpl<StrictOrderArea>(matching_event,original)
{
m_predecessor = NULL;
}
@@ -1234,30 +1282,73 @@
StrictOrderArea* get_strict_order_area();
};
+class CoregionEventRelation:public MscElementTmpl<CoregionEventRelation>
+{
+private:
+
+ CoregionEvent* m_predecessor;
+
+ CoregionEvent* m_successor;
+
+ PolyLine m_line;
+
+public:
+
+ CoregionEventRelation(CoregionEvent* predecessor, CoregionEvent* successor,
+ const PolyLine& line = NULL):MscElementTmpl<CoregionEventRelation>()
+ {
+ m_predecessor = predecessor;
+ m_successor = successor;
+ m_line = line;
+ }
+
+ CoregionEvent* get_predecessor()
+ {
+ return m_predecessor;
+ }
+
+ CoregionEvent* get_successor()
+ {
+ return m_successor;
+ }
+
+ void set_predecessor(CoregionEvent* predecessor)
+ {
+ m_predecessor = predecessor;
+ }
+
+ void set_successor(CoregionEvent* successor)
+ {
+ m_successor = successor;
+ }
+};
+
+typedef counted_ptr<CoregionEventRelation> CoregEventRelPtr;
+typedef std::set<CoregEventRelPtr> CoregEventRelPtrSet;
+
+
/**
* \brief Event occurring in CoregionArea
*/
-class CoregionEvent: public Event
+class CoregionEvent: public EventTmpl<CoregionArea>
{
/**
* Successors of this event
- *
- * @warning counted_ptrs mustn't be used because of possible cyclic dependency
*/
- CoregionEventPSet m_successors;
+ CoregEventRelPtrSet m_successors;
/**
* Predecessors of this event.
*/
- CoregionEventPSet m_predecessors;
+ CoregEventRelPtrSet m_predecessors;
public:
/**
* See Event constructor for details
*/
- CoregionEvent(CoregionArea* area, MscMessagePtr message, Event* original=NULL)
- :Event((EventArea*)area, message,original)
+ CoregionEvent(MscMessagePtr message, Event* original=NULL)
+ :EventTm...
[truncated message content] |
|
From: <ba...@us...> - 2008-11-09 14:10:18
|
Revision: 114
http://scstudio.svn.sourceforge.net/scstudio/?rev=114&view=rev
Author: babicaj
Date: 2008-11-09 14:10:12 +0000 (Sun, 09 Nov 2008)
Log Message:
-----------
Previous version didn't support positioning of incomplete message. It was necessary to change ChannelMapper interface to reflect these changes.
Modified Paths:
--------------
trunk/src/check/checker.h
trunk/src/check/deadlock_checker.cpp
trunk/src/check/deadlock_checker.h
trunk/src/data/msc.cpp
trunk/src/data/msc.h
trunk/src/data/msc_visual.h
Modified: trunk/src/check/checker.h
===================================================================
--- trunk/src/check/checker.h 2008-10-19 15:53:21 UTC (rev 113)
+++ trunk/src/check/checker.h 2008-11-09 14:10:12 UTC (rev 114)
@@ -139,24 +139,11 @@
}
/**
- * Returns true if m1 belongs to the same channel as m2.
- */
- virtual bool same_channel(const MscMessagePtr& m1, const MscMessagePtr& m2) const=0;
-
- /**
* Returns true if e1's message belongs to the same channel as e2's message.
*/
- bool same_channel(const Event* e1, const Event* e2) const
- {
- return same_channel(e1->get_message(),e2->get_message());
- }
+ virtual bool same_channel(const Event* e1, const Event* e2) const=0;
/**
- * Returns index of channel which message belongs into.
- */
- virtual size_t channel(const MscMessagePtr& m)=0;
-
- /**
* Returns index of channel which event's message belongs into.
*
* @warning event must have set message
@@ -211,9 +198,9 @@
/**
* Returns true if m1 belongs to the same channel as m2.
*/
- bool same_channel(const MscMessagePtr& m1, const MscMessagePtr& m2) const
+ bool same_channel(const Event* e1, const Event* e2) const
{
- return MessagePart::same_channel(m1,m2);
+ return MessagePart::same_channel(e1,e2);
}
/**
@@ -221,15 +208,7 @@
*/
size_t channel(const Event* event)
{
- return channel(event->get_message());
- }
-
- /**
- * Returns index of channel which message belongs into.
- */
- size_t channel(const MscMessagePtr& m)
- {
- MessagePart part(m);
+ MessagePart part(event);
typename ChannelMap::iterator i = m_channels.find(part);
if(i==m_channels.end())
{
@@ -292,10 +271,10 @@
public:
- SRMessagePart(MscMessagePtr m)
+ SRMessagePart(const Event* e)
{
- m_sender = m->get_sender()->get_label();
- m_receiver = m->get_receiver()->get_label();
+ m_sender = e->get_sender_label();
+ m_receiver = e->get_receiver_label();
}
/**
@@ -312,10 +291,14 @@
* Channels of message m1 and m2 are same if and only if m1 has got same
* sender and receiver as m2.
*/
- static bool same_channel(const MscMessagePtr& m1, const MscMessagePtr& m2)
+ static bool same_channel(const Event* e1, const Event* e2)
{
- return m1->get_sender()==m2->get_sender() &&
- m1->get_receiver()==m2->get_receiver();
+ if((e1->is_send() && e2->is_send()) || (e1->is_receive() && e2->is_receive()))
+ {
+ return e1->get_sender_label()==e2->get_sender_label() &&
+ e2->get_receiver_label()==e2->get_receiver_label();
+ }
+ return false;
}
};
@@ -338,11 +321,11 @@
public:
- SRLMessagePart(MscMessagePtr m)
+ SRLMessagePart(const Event* e)
{
- m_sender = m->get_sender()->get_label();
- m_receiver = m->get_receiver()->get_label();
- m_label = m->get_label();
+ m_sender = e->get_sender_label();
+ m_receiver = e->get_receiver_label();
+ m_label = e->get_message()->get_label();
}
bool operator<(const SRLMessagePart& mp) const
@@ -354,14 +337,14 @@
}
/**
- * Channels of message m1 and m2 are same if and only if m1 has got same
- * sender, receiver and label as m2.
+ * Channels of message of e1 and e2 are same if and only if e1 has got same
+ * sender, receiver and label as e2.
*/
- static bool same_channel(const MscMessagePtr& m1,const MscMessagePtr& m2)
+ static bool same_channel(const Event* e1,const Event* e2)
{
- return m1->get_sender()->get_label()==m2->get_sender()->get_label() &&
- m1->get_receiver()->get_label()==m2->get_receiver()->get_label() &&
- m1->get_label()==m2->get_label();
+ return e1->get_sender_label()==e2->get_sender_label() &&
+ e1->get_receiver_label()==e2->get_receiver_label() &&
+ e1->get_message()->get_label()==e2->get_message()->get_label();
}
};
Modified: trunk/src/check/deadlock_checker.cpp
===================================================================
--- trunk/src/check/deadlock_checker.cpp 2008-10-19 15:53:21 UTC (rev 113)
+++ trunk/src/check/deadlock_checker.cpp 2008-11-09 14:10:12 UTC (rev 114)
@@ -68,7 +68,7 @@
get_depth(node) = m_current_depth;
if (dynamic_cast<ReferenceNode*> (node))
{
- m_reference_depth.push(m_current_depth);
+ m_depths.push(m_current_depth);
}
//set deadlock free attribute
bool& deadlock_free = get_deadlock_free(node);
@@ -88,19 +88,19 @@
throw DeadlockException();
}
//this node is no more on traversing stack
- m_reference_depth.pop();
+ m_depths.pop();
}
m_current_depth--;
}
void DeadlockListener::on_gray_node_found(HMscNode* node)
{
- //m_reference_depth can be empty
- if (!m_reference_depth.empty())
+ //m_depths can be empty
+ if (!m_depths.empty())
{
//depth of node is surely set (in on_white_node_found())
size_t node_depth = get_depth(node);
- size_t top_reference_depth = m_reference_depth.top();
+ size_t top_reference_depth = m_depths.top();
//there is some ReferenceNode on path from node to previous white HMscNode
if (top_reference_depth >= m_current_depth)
{
Modified: trunk/src/check/deadlock_checker.h
===================================================================
--- trunk/src/check/deadlock_checker.h 2008-10-19 15:53:21 UTC (rev 113)
+++ trunk/src/check/deadlock_checker.h 2008-11-09 14:10:12 UTC (rev 114)
@@ -70,7 +70,7 @@
/**
* Depths of founded ReferenceNodes
*/
- std::stack<size_t> m_reference_depth;
+ std::stack<size_t> m_depths;
std::string m_deadlock_free_attribute;
Modified: trunk/src/data/msc.cpp
===================================================================
--- trunk/src/data/msc.cpp 2008-10-19 15:53:21 UTC (rev 113)
+++ trunk/src/data/msc.cpp 2008-11-09 14:10:12 UTC (rev 114)
@@ -102,3 +102,13 @@
{
return dynamic_cast<CoregionArea*>(m_area);
}
+
+Instance* CompleteMessage::get_sender() const
+{
+ return m_send_event->get_instance();
+}
+
+Instance* CompleteMessage::get_receiver() const
+{
+ return m_receive_event->get_instance();
+}
Modified: trunk/src/data/msc.h
===================================================================
--- trunk/src/data/msc.h 2008-10-19 15:53:21 UTC (rev 113)
+++ trunk/src/data/msc.h 2008-11-09 14:10:12 UTC (rev 114)
@@ -943,85 +943,162 @@
*/
std::string m_label;
+public:
+
/**
+ * @param sender - sending instance
+ * @param receiver - receiving instance
+ * @param label - label of message
+ */
+ MscMessage(const std::string& label="",MscMessage* original=NULL):
+ MscElementTmpl<MscMessage>(original),m_label(label)
+ {
+ }
+
+ virtual ~MscMessage()
+ {
+
+ }
+
+ /**
+ * Getter for m_label.
+ */
+ const std::string& get_label() const
+ {
+ return m_label;
+ }
+
+};
+
+class CompleteMessage:public MscMessage
+{
+
+ /**
* Sender of message.
*
* @warning counted_ptr mustn't be used because of possible cyclic dependency
*/
- Instance* m_sender;
+ Event* m_send_event;
/**
* Receiver of message.
*
* @warning counted_ptr mustn't be used because of possible cyclic dependency
*/
- Instance* m_receiver;
-
+ Event* m_receive_event;
+
public:
/**
- * @param sender - sending instance
- * @param receiver - receiving instance
+ * @param sender - sending event
+ * @param receiver - receiving event
* @param label - label of message
*/
- MscMessage(Instance* sender, Instance* receiver, const std::string& label)
+ CompleteMessage(const std::string& label):
+ MscMessage(label),m_send_event(NULL),m_receive_event(NULL)
{
- m_sender = sender;
- m_receiver = receiver;
- m_label = label;
}
/**
- * @param sender - sending instance
- * @param receiver - receiving instance
- * @param original - original MscMessage
+ * Retrieves instance of m_send_event
*/
- MscMessage(Instance* sender, Instance* receiver, MscMessage* original):
- MscElementTmpl<MscMessage>(original)
- {
- m_sender = sender;
- m_receiver = receiver;
- m_label = original->m_label;
- }
-
- virtual ~MscMessage()
- {
-
- }
-
+ Instance* get_sender() const;
+
/**
* Getter for m_sender.
*/
- Instance* get_sender() const {return m_sender;}
+ Event* get_send_event() const
+ {
+ return m_send_event;
+ }
/**
* Setter for m_sender
*/
- void set_sender(Instance* sender)
+ void set_send_event(Event* sender)
{
- m_sender = sender;
+ m_send_event = sender;
}
/**
- * Getter for m_receiver.
+ * Retrieves instance of m_receive_event
*/
- Instance* get_receiver() const {return m_receiver;}
-
+ Instance* get_receiver() const;
+
/**
* Getter for m_receiver.
*/
- void set_receiver(Instance* receiver)
+ Event* get_receive_event() const
{
- m_receiver = receiver;
+ return m_receive_event;
}
/**
- * Getter for m_label.
+ * Getter for m_receiver.
*/
- const std::string& get_label() const {return m_label;}
+ void set_receive_event(Event* receiver)
+ {
+ m_receive_event = receiver;
+ }
+};
+typedef counted_ptr<CompleteMessage> CompleteMessagePtr;
+
+typedef enum
+{
+ LOST,
+ FOUND
+} IncompleteMsgType;
+
+class IncompleteMessage: public MscMessage
+{
+
+protected:
+
+ Point m_dot_position;
+
+ std::string m_instance_label;
+
+ IncompleteMsgType m_type;
+
+public:
+
+ IncompleteMessage(const IncompleteMsgType& type=LOST, const std::string& label="",
+ const std::string& instance_label="", IncompleteMessage* original= NULL,
+ const Point& dot_position=Point()):
+ MscMessage(label,original),m_instance_label(instance_label),m_type(type),
+ m_dot_position(dot_position)
+ {
+ }
+
+ Point& get_dot_position()
+ {
+ return m_dot_position;
+ }
+
+ const std::string& get_instance_label() const
+ {
+ return m_instance_label;
+ }
+
+ const IncompleteMsgType& get_type() const
+ {
+ return m_type;
+ }
+
+ bool is_lost() const
+ {
+ return m_type==LOST;
+ }
+
+ bool is_found() const
+ {
+ return m_type==FOUND;
+ }
};
+typedef counted_ptr<IncompleteMessage> IncompleteMessagePtr;
+
/**
* \brief Event which occurs in EventArea.
*/
@@ -1031,53 +1108,46 @@
protected:
Coordinate m_y;
-
- PositionOnAxis m_position;
/**
* Label of message whose this is send or receive event.
*/
MscMessagePtr m_message;
-
- /**
- * Opposite (send/receive) event of this event. Undefined in case of lost or
- * found message.
- *
- * @warning counted_ptr mustn't be used because of possible cyclic dependency
- */
- Event* m_matching_event;
/**
- * @param message - message which is sent from this Event or is received
* @param original - original Event of this Event
*/
- Event(MscMessagePtr message, Event* original=NULL)
+ Event(Event* original=NULL)
:MscElementTmpl<Event>(original)
{
- m_message = message;
}
-
- /**
- * @param message - matching Event of this Event (send or receive Event)
- * @param original - original Event of this Event
- *
- * It is supposed parameter matching to have set message which will be same
- * for this Event.
- */
- Event(Event* matching, Event* original=NULL)
- :MscElementTmpl<Event>(original)
+
+ CompleteMessage* get_complete() const
{
- m_message = matching->m_message;
- m_matching_event = matching;
- matching->m_matching_event = this;
+ return dynamic_cast<CompleteMessage*>(m_message.get());
}
+
+ IncompleteMessage* get_incomplete() const
+ {
+ return dynamic_cast<IncompleteMessage*>(m_message.get());
+ }
public:
virtual ~Event()
{
if(is_matched())
- m_matching_event->set_matching_event(NULL);
+ {
+ CompleteMessage* complete = get_complete();
+ if(is_send())
+ {
+ complete->set_send_event(NULL);
+ }
+ else
+ {
+ complete->set_receive_event(NULL);
+ }
+ }
}
/**
@@ -1087,51 +1157,134 @@
{
return m_message;
}
-
+
/**
- * Getter for m_matching_event.
+ * Return instance of CompleteMessage in case m_message contains the instance,
+ * undefined NULL otherwise
*/
- Event* get_matching_event() const
+ CompleteMessagePtr get_complete_message()
{
- return m_matching_event;
+ try
+ {
+ CompleteMessagePtr complete = m_message;
+ return complete;
+ }
+ catch(std::bad_cast bc)
+ {
+ return CompleteMessagePtr();
+ }
}
+
+ /**
+ * Return instance of CompleteMessage in case m_message contains the instance,
+ * undefined NULL otherwise
+ */
+ IncompleteMessagePtr get_incomplete_message()
+ {
+ try
+ {
+ IncompleteMessagePtr incomplete = m_message;
+ return incomplete;
+ }
+ catch(std::bad_cast bc)
+ {
+ return IncompleteMessagePtr();
+ }
+ }
/**
- * Setter for m_matching_event.
+ * Retrives matching event of this Event in case this Event has complete
+ * message, otherwise it returns NULL
*/
- void set_matching_event(Event* matching)
+ Event* get_matching_event()
{
- m_matching_event = matching;
+ if(is_matched())
+ {
+ CompleteMessage* complete = get_complete();
+ return (is_send()?complete->get_receive_event():complete->get_send_event());
+ }
+ return NULL;
}
/**
* True iff is sending event.
*/
- bool is_send()
+ bool is_send() const
{
- return get_instance()==m_message->get_sender();
+ if(is_matched())
+ {
+ CompleteMessage* complete = get_complete();
+ return complete->get_send_event()==this;
+ }
+ else
+ {
+ IncompleteMessage* incomplete = get_incomplete();
+ return incomplete->is_lost();
+ }
}
/**
* True iff is receiving event.
*/
- bool is_receive()
+ bool is_receive() const
{
- return get_instance()==m_message->get_receiver();
+ return !is_send();
}
/**
- * Returns true if m_matching_event is set.
+ * Returns true if m_message is complete.
*/
- bool is_matched()
+ bool is_matched() const
{
- return m_matching_event!=NULL;
+ return get_complete();
}
/**
* Returns instance which this event occures at
*/
- virtual Instance* get_instance()=0;
+ virtual Instance* get_instance() const=0;
+
+ const std::string& get_receiver_label() const
+ {
+ if(is_matched())
+ {
+ CompleteMessage* complete = get_complete();
+ return complete->get_receiver()->get_label();
+ }
+ else
+ {
+ if(is_send())
+ {
+ IncompleteMessage* incomplete = get_incomplete();
+ return incomplete->get_instance_label();
+ }
+ else
+ {
+ return get_instance()->get_label();
+ }
+ }
+ }
+
+ const std::string& get_sender_label() const
+ {
+ if(is_matched())
+ {
+ CompleteMessage* complete = get_complete();
+ return complete->get_sender()->get_label();
+ }
+ else
+ {
+ if(is_receive())
+ {
+ IncompleteMessage* incomplete = get_incomplete();
+ return incomplete->get_instance_label();
+ }
+ else
+ {
+ return get_instance()->get_label();
+ }
+ }
+ }
};
@@ -1149,25 +1302,12 @@
TArea* m_area;
/**
- * @param message - message which is sent from this Event or is received
* @param original - original Event of this Event
*/
- EventTmpl(MscMessagePtr message, Event* original=NULL)
- :Event(message,original)
+ EventTmpl(Event* original=NULL)
+ :Event(original)
{
}
-
- /**
- * @param message - matching Event of this Event (send or receive Event)
- * @param original - original Event of this Event
- *
- * It is supposed parameter matching to have set message which will be same
- * for this Event.
- */
- EventTmpl(Event* matching, Event* original=NULL)
- :Event(matching,original)
- {
- }
public:
@@ -1216,21 +1356,12 @@
/**
* See Event constructor for details
*/
- StrictEvent(MscMessagePtr message, Event* original=NULL)
- :EventTmpl<StrictOrderArea>(message,original)
+ StrictEvent(Event* original=NULL)
+ :EventTmpl<StrictOrderArea>(original)
{
m_predecessor = NULL;
}
- /**
- * See Event constructor for details
- */
- StrictEvent(Event* matching_event, Event* original=NULL)
- :EventTmpl<StrictOrderArea>(matching_event,original)
- {
- m_predecessor = NULL;
- }
-
virtual ~StrictEvent()
{
@@ -1347,20 +1478,11 @@
/**
* See Event constructor for details
*/
- CoregionEvent(MscMessagePtr message, Event* original=NULL)
- :EventTmpl<CoregionArea>(message,original)
+ CoregionEvent(Event* original=NULL)
+ :EventTmpl<CoregionArea>(original)
{
-
}
- /**
- * See Event constructor for details
- */
- CoregionEvent(Event* matching)
- :EventTmpl<CoregionArea>(matching)
- {
- }
-
virtual ~CoregionEvent();
/**
Modified: trunk/src/data/msc_visual.h
===================================================================
--- trunk/src/data/msc_visual.h 2008-10-19 15:53:21 UTC (rev 113)
+++ trunk/src/data/msc_visual.h 2008-11-09 14:10:12 UTC (rev 114)
@@ -33,12 +33,6 @@
COLUMN
} InstanceAxisForm;
-typedef enum
-{
- LEFT,
- RIGHT
-} PositionOnAxis;
-
class Point
{
private:
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <got...@us...> - 2008-11-23 22:03:05
|
Revision: 121
http://scstudio.svn.sourceforge.net/scstudio/?rev=121&view=rev
Author: gotthardp
Date: 2008-11-23 22:03:00 +0000 (Sun, 23 Nov 2008)
Log Message:
-----------
Removed warnings on Win32
Modified Paths:
--------------
trunk/src/check/deadlock_checker.cpp
trunk/src/check/fifo_checker.h
trunk/src/check/livelock_checker.cpp
trunk/src/data/msc.h
Modified: trunk/src/check/deadlock_checker.cpp
===================================================================
--- trunk/src/check/deadlock_checker.cpp 2008-11-23 20:43:27 UTC (rev 120)
+++ trunk/src/check/deadlock_checker.cpp 2008-11-23 22:03:00 UTC (rev 121)
@@ -171,7 +171,7 @@
{
traverser.traverse(hmsc);
}
- catch (DeadlockException& e)
+ catch (DeadlockException)
{
p = create_counter_example(traverser.get_reached_elements());
traverser.cleanup_traversing_attributes();
Modified: trunk/src/check/fifo_checker.h
===================================================================
--- trunk/src/check/fifo_checker.h 2008-11-23 20:43:27 UTC (rev 120)
+++ trunk/src/check/fifo_checker.h 2008-11-23 22:03:00 UTC (rev 121)
@@ -78,14 +78,14 @@
SRChannelMapperPtr p = chm;
return true;
}
- catch(std::bad_cast& b)
+ catch(std::bad_cast)
{
try
{
SRLChannelMapperPtr p = chm;
return true;
}
- catch(std::bad_cast& b){}
+ catch(std::bad_cast){}
}
return false;
}
Modified: trunk/src/check/livelock_checker.cpp
===================================================================
--- trunk/src/check/livelock_checker.cpp 2008-11-23 20:43:27 UTC (rev 120)
+++ trunk/src/check/livelock_checker.cpp 2008-11-23 22:03:00 UTC (rev 121)
@@ -95,7 +95,7 @@
{
traverser.traverse(hmsc);
}
- catch(LivelockException& e)
+ catch(LivelockException)
{
p = create_counter_example(traverser.get_reached_elements());
}
Modified: trunk/src/data/msc.h
===================================================================
--- trunk/src/data/msc.h 2008-11-23 20:43:27 UTC (rev 120)
+++ trunk/src/data/msc.h 2008-11-23 22:03:00 UTC (rev 121)
@@ -767,7 +767,7 @@
p = m_msc;
return p;
}
- catch(std::bad_cast& c){}
+ catch(std::bad_cast){}
return p;
}
@@ -784,7 +784,7 @@
p = m_msc;
return p;
}
- catch(std::bad_cast& c){}
+ catch(std::bad_cast){}
return p;
}
@@ -1268,9 +1268,9 @@
/**
* Returns true if m_message is complete.
*/
- bool is_matched() const
+ int is_matched() const
{
- return get_complete();
+ return get_complete() != NULL;
}
/**
@@ -1469,12 +1469,12 @@
m_successor = successor;
}
- bool is_first()
+ int is_first() const
{
return m_predecessor==NULL;
}
- bool is_last()
+ int is_last() const
{
return m_successor==NULL;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ba...@us...> - 2008-11-28 20:26:13
|
Revision: 122
http://scstudio.svn.sourceforge.net/scstudio/?rev=122&view=rev
Author: babicaj
Date: 2008-11-28 20:26:06 +0000 (Fri, 28 Nov 2008)
Log Message:
-----------
Modified Paths:
--------------
trunk/src/check/msc_duplicators.cpp
trunk/src/data/msc.cpp
trunk/src/data/msc.h
Modified: trunk/src/check/msc_duplicators.cpp
===================================================================
--- trunk/src/check/msc_duplicators.cpp 2008-11-23 22:03:00 UTC (rev 121)
+++ trunk/src/check/msc_duplicators.cpp 2008-11-28 20:26:06 UTC (rev 122)
@@ -1,469 +1,469 @@
-/*
- * 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 Jindra Babica <ba...@ma...>
- *
- * $Id$
- */
+/*
+ * 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 Jindra Babica <ba...@ma...>
+ *
+ * $Id$
+ */
-#include "check/msc_duplicators.h"
-#include "check/dfs_instance_events_traverser.h"
-
-const std::string BMSC_DUPLICATOR_TRAVERSING_ATTR = "BDcolor";
-const std::string BMSC_DUPLICATOR_COPY_ATTR = "BDcopy";
-const std::string BMSC_GRAPH_DUPLICATOR_COPY_ATTR = "BGDcopy";
-const std::string BMSC_GRAPH_DUPLICATOR_REF_ATTR = "BGDreferencing";
-const std::string BMSC_GRAPH_DUPLICATOR_ENDLIST_ATTR = "BGDendlist";
-
-BMscDuplicator::BMscDuplicator()
-{
-}
-
-BMscPtr BMscDuplicator::duplicate_bmsc(BMscPtr &bmsc)
-{
- BMscPtr new_bmsc;
- if(bmsc.get())
- {
- new_bmsc = new BMsc(bmsc.get());
- DFSAreaTraverser traverser(BMSC_DUPLICATOR_TRAVERSING_ATTR);
- EventsCreatorListener events_creator(this,&traverser,new_bmsc.get());
- traverser.add_white_event_found_listener(&events_creator);
- traverser.add_black_event_found_listener(&events_creator);
- traverser.add_gray_event_found_listener(&events_creator);
- traverser.traverse(bmsc);
- traverser.remove_all_listeners();
- MessagesCreatorListener messages_creator(this);
- traverser.add_white_event_found_listener(&messages_creator);
- traverser.traverse(bmsc);
- }
- return new_bmsc;
-}
-
-Event*& BMscDuplicator::get_copy(Event* e)
-{
- bool just_set;
- Event*& copy = e->get_attribute<Event*>(BMSC_DUPLICATOR_COPY_ATTR,NULL,just_set);
- if(just_set)
- {
- m_modified_elements.push_back(e);
- }
- return copy;
-}
-
-BMscDuplicator::~BMscDuplicator()
-{
- EventPList::const_iterator i;
- for(i=m_modified_elements.begin();i!=m_modified_elements.end();i++)
- {
- (*i)->remove_attribute<Event*>(BMSC_DUPLICATOR_COPY_ATTR);
- }
-}
-
-BMscPtr BMscDuplicator::duplicate(BMscPtr& bmsc)
-{
- BMscDuplicator duplicator;
- return duplicator.duplicate_bmsc(bmsc);
-}
-
-EventsCreatorListener::EventsCreatorListener(BMscDuplicator* duplicator, DFSAreaTraverser* traverser, BMsc* bmsc):
- m_duplicator(duplicator),
- m_traverser(traverser),
- m_bmsc(bmsc),
- m_last_instance(NULL),
- m_last_area(NULL),
- m_last_new_instance(NULL),
- m_last_new_area(NULL)
-{
-
-}
-
-void EventsCreatorListener::on_white_event_found(Event* e)
-{
- if(m_last_instance!=e->get_instance())
- {
- InstancePtr new_instance = new Instance(e->get_instance());
- m_bmsc->add_instance(new_instance);
- m_last_instance = e->get_instance();
- m_last_new_instance = new_instance.get();
- }
- if(m_last_area!=e->get_general_area())
- {
- StrictOrderArea* strict = dynamic_cast<StrictOrderArea*>(e->get_general_area());
- EventAreaPtr area;
- if(strict)
- {
- area = new StrictOrderArea(strict);
- }
- else
- {
- area = new CoregionArea(dynamic_cast<CoregionArea*>(e->get_general_area()));
- }
- m_last_new_area = area.get();
- m_last_new_instance->add_area(area);
- m_last_area = e->get_general_area();
- }
- EventPtr new_event = m_last_new_area->add_event();
- new_event->set_original(e);
- Event*& copy = m_duplicator->get_copy(e);
- copy = new_event.get();
- create_successor(e);
-}
-
-CoregionEvent* EventsCreatorListener::get_preceding_event()
-{
- const MscElementPList& elements = m_traverser->get_reached_elements();
- if(elements.size()>1)
- {
- //in this case currently traversed event isn't alone in elements
- MscElementPList::const_iterator i = elements.end();
- i--; i--;
- return dynamic_cast<CoregionEvent*>(*i);
- }
- return NULL;
-}
-
-void EventsCreatorListener::on_gray_event_found(Event* e)
-{
- create_successor(e);
-}
-
-void EventsCreatorListener::on_black_event_found(Event* e)
-{
- create_successor(e);
-}
-
-void EventsCreatorListener::create_successor(Event* e)
-{
- CoregionEvent* coreg_new_event = dynamic_cast<CoregionEvent*>(e);
- if(coreg_new_event)
- {
- CoregionEvent* preceding = get_preceding_event();
- if(preceding)
- {
- preceding->add_successor(coreg_new_event);
- }
- }
-}
-
-MessagesCreatorListener::MessagesCreatorListener(BMscDuplicator* duplicator):
-m_duplicator(duplicator)
-{
-
-}
-
-void MessagesCreatorListener::on_white_event_found(Event* e)
-{
- Event* event_copy = m_duplicator->get_copy(e);
- if(e->is_matched())
- {
- if(e->is_send())
- {
- MscMessagePtr complete = new CompleteMessage(e,NULL,e->get_complete_message().get());
- event_copy->set_message(complete);
- Event* matching_copy = m_duplicator->get_copy(e->get_matching_event());
- matching_copy->set_message(complete);
- }
- }
- else
- {
- MscMessagePtr incomplete = new IncompleteMessage(e->get_incomplete_message().get());
- event_copy->set_message(incomplete);
- }
-}
-
-////////////////////////////////////////////////////////////////////////
-
-GraphCreatorListener::GraphCreatorListener(HMsc* hmsc):
-m_hmsc(hmsc)
-{
-}
-
-void GraphCreatorListener::on_white_node_found(HMscNode *n)
-{
- HMscNodePtr node;
- ReferenceNode* reference = dynamic_cast<ReferenceNode*>(n);
- if(reference)
- {
- on_white_node_found(reference);
- }
- else
- {
- ConnectionNode* connection = dynamic_cast<ConnectionNode*>(n);
- if(connection)
- {
- on_white_node_found(connection);
- }
- else
- {
- EndNode* end = dynamic_cast<EndNode*>(n);
- if(end)
- {
- on_white_node_found(end);
- }
- else
- {
- StartNode* start = dynamic_cast<StartNode*>(n);
- on_white_node_found(start);
- }
- }
- }
-}
-
-
-void GraphCreatorListener::on_white_node_found(ReferenceNode* n)
-{
- BMscPtr bmsc = n->get_bmsc();
- HMscNodePtr new_node;
- if(bmsc.get())
- {
- BMscPtr new_bmsc = BMscDuplicator::duplicate(bmsc);
- ReferenceNode* reference = new ReferenceNode(n);
- reference->set_msc(new_bmsc);
- new_node = reference;
- }
- else
- {
- ConnectionNode* connection = new ConnectionNode(n);
- new_node = connection;
- ReferenceNode*& attribute = get_referencing_node(n->get_hmsc().get());
- attribute = n;
- }
- process_new_node(n,new_node);
-}
-
-void GraphCreatorListener::on_white_node_found(StartNode* n)
-{
- if(is_root_element(n))
- {
- //in this case duplicated Startnode was already created
- m_new_nodes.push_back(m_hmsc->get_start().get());
- set_copy(n,m_hmsc->get_start().get());
- }
-}
-
-void GraphCreatorListener::on_white_node_found(EndNode* n)
-{
- HMscNodePtr new_node;
- if(is_root_element(n))
- {
- EndNode* end = new EndNode(n);
- new_node = end;
- }
- else
- {
- ConnectionNode* connection = new ConnectionNode(n);
- new_node = connection;
- add_to_end_list(connection);
- }
- process_new_node(n,new_node);
-}
-
-ConnectionNodePList& GraphCreatorListener::get_end_list(ReferenceNode* reference)
-{
- static ConnectionNodePList empty;
- //attribute is removed when reference is finished in traversing
- return reference->get_attribute<ConnectionNodePList>(BMSC_GRAPH_DUPLICATOR_ENDLIST_ATTR,empty);
-}
-
-void GraphCreatorListener::add_to_end_list(ConnectionNode* new_end)
-{
- HMsc* original_hmsc = new_end->get_original()->get_owner();
- ReferenceNode* original_reference = get_referencing_node(original_hmsc);
- ConnectionNodePList& end_list = get_end_list(original_reference);
- end_list.push_back(new_end);
-}
-
-void GraphCreatorListener::on_white_node_found(ConnectionNode* n)
-{
- PredecessorNode* predecessor = get_predecessor();
- HMscNodePtr new_node = new ConnectionNode(n);
- process_new_node(n,new_node);
-}
-
-void GraphCreatorListener::process_new_node(HMscNode* old_node, HMscNodePtr& new_node)
-{
- m_hmsc->add_node(new_node);
- add_new_successor(new_node.get());
- m_new_nodes.push_back(new_node.get());
- set_copy(old_node,new_node.get());
-}
-
-bool GraphCreatorListener::is_root_element(HMscNode* n)
-{
- return n->get_owner()==m_hmsc->get_original();
-}
-
-void GraphCreatorListener::set_copy(HMscNode* n, HMscNode* copy)
-{
- HMscNode*& attribute = get_copy(n);
- attribute = copy;
-}
-
-HMscNode*& GraphCreatorListener::get_copy(HMscNode* n)
-{
- bool just_set;
- HMscNode*& copy = n->get_attribute<HMscNode*>(BMSC_DUPLICATOR_COPY_ATTR,NULL,just_set);
- if(just_set)
- {
- m_modified_elements.push_back(n);
- }
- return copy;
-}
-
-PredecessorNode* GraphCreatorListener::get_predecessor()
-{
- return dynamic_cast<PredecessorNode*>(m_new_nodes.back());
-}
-
-void GraphCreatorListener::process_nonwhite_node(HMscNode* n)
-{
- HMscNode* copy = get_copy(n);
- add_new_successor(copy);
-}
-
-void GraphCreatorListener::on_gray_node_found(HMscNode* n)
-{
- process_nonwhite_node(n);
-}
-
-void GraphCreatorListener::on_black_node_found(HMscNode* n)
-{
- process_nonwhite_node(n);
-}
-
-void GraphCreatorListener::on_node_finished(HMscNode* n)
-{
- HMscNodePtr node;
- ReferenceNode* reference = dynamic_cast<ReferenceNode*>(n);
- if(reference)
- {
- on_node_finished(reference);
- }
- else
- {
- ConnectionNode* connection = dynamic_cast<ConnectionNode*>(n);
- if(connection)
- {
- on_node_finished(connection);
- }
- else
- {
- EndNode* end = dynamic_cast<EndNode*>(n);
- if(end)
- {
- on_node_finished(end);
- }
- else
- {
- StartNode* start = dynamic_cast<StartNode*>(n);
- on_node_finished(start);
- }
- }
- }
-}
-
-void GraphCreatorListener::on_node_finished(ReferenceNode* n)
-{
- n->remove_attribute<ConnectionNodePList>(BMSC_GRAPH_DUPLICATOR_ENDLIST_ATTR);
- m_new_nodes.pop_back();
-}
-
-void GraphCreatorListener::on_node_finished(StartNode* n)
-{
- if(is_root_element(n))
- {
- m_new_nodes.pop_back();
- }
-}
-
-void GraphCreatorListener::on_node_finished(EndNode* n)
-{
- m_new_nodes.pop_back();
-}
-
-void GraphCreatorListener::on_node_finished(ConnectionNode* n)
-{
- m_new_nodes.pop_back();
-}
-
-ReferenceNode*& GraphCreatorListener::get_referencing_node(HMsc* hmsc)
-{
- bool just_set;
- ReferenceNode*& reference = hmsc->get_attribute<ReferenceNode*>(BMSC_GRAPH_DUPLICATOR_REF_ATTR,NULL,just_set);
- if(just_set)
- {
- m_modified_hmscs.push_back(hmsc);
- }
- return reference;
-}
-
-void GraphCreatorListener::add_new_successor(HMscNode* new_successor)
-{
- SuccessorNode* new_succ = dynamic_cast<SuccessorNode*>(new_successor);
- PredecessorNode* predecessor = get_predecessor();
- ConnectionNode* connection = dynamic_cast<ConnectionNode*>(predecessor);
- if(connection)
- {
- ReferenceNode* original_reference = dynamic_cast<ReferenceNode*>(connection->get_original());
- if(original_reference &&
- new_successor->get_original()->get_owner()==original_reference->get_owner())
- {
- //connection was transformed from ReferenceNode and probably contains end_list,
- //elements of the end_list must become predecessors of new_successor which
- //must be from same HMsc as original_reference
- ConnectionNodePList& end_list = get_end_list(original_reference);
- ConnectionNodePList::const_iterator i;
- for(i=end_list.begin();i!=end_list.end();i++)
- {
- (*i)->add_successor(new_succ);
- }
- return;
- }
- }
- predecessor->add_successor(new_succ);
-}
-
-GraphCreatorListener::~GraphCreatorListener()
-{
- while(!m_modified_elements.empty())
- {
- MscElement* e = m_modified_elements.back();
- e->remove_attribute<HMscNode*>(BMSC_DUPLICATOR_COPY_ATTR);
- m_modified_elements.pop_back();
- }
- while(!m_modified_hmscs.empty())
- {
- HMsc* h = m_modified_hmscs.back();
- h->remove_attribute<ReferenceNode*>(BMSC_GRAPH_DUPLICATOR_REF_ATTR);
- m_modified_hmscs.pop_back();
- }
-}
-
-HMscPtr BMscGraphDuplicator::duplicate(HMscPtr& hmsc)
-{
- HMscPtr new_hmsc;
- if(hmsc.get())
- {
- new_hmsc = new HMsc(hmsc.get());
- GraphCreatorListener listener(new_hmsc.get());
- DFSBMscGraphTraverser traverser;
- traverser.add_black_node_found_listener(&listener);
- traverser.add_gray_node_found_listener(&listener);
- traverser.add_node_finished_listener(&listener);
- traverser.add_white_node_found_listener(&listener);
- traverser.traverse(hmsc);
- }
- return new_hmsc;
-}
-
-
+#include "check/msc_duplicators.h"
+#include "check/dfs_instance_events_traverser.h"
+
+const std::string BMSC_DUPLICATOR_TRAVERSING_ATTR = "BDcolor";
+const std::string BMSC_DUPLICATOR_COPY_ATTR = "BDcopy";
+const std::string BMSC_GRAPH_DUPLICATOR_COPY_ATTR = "BGDcopy";
+const std::string BMSC_GRAPH_DUPLICATOR_REF_ATTR = "BGDreferencing";
+const std::string BMSC_GRAPH_DUPLICATOR_ENDLIST_ATTR = "BGDendlist";
+
+BMscDuplicator::BMscDuplicator()
+{
+}
+
+BMscPtr BMscDuplicator::duplicate_bmsc(BMscPtr &bmsc)
+{
+ BMscPtr new_bmsc;
+ if(bmsc.get())
+ {
+ new_bmsc = new BMsc(bmsc.get());
+ DFSAreaTraverser traverser(BMSC_DUPLICATOR_TRAVERSING_ATTR);
+ EventsCreatorListener events_creator(this,&traverser,new_bmsc.get());
+ traverser.add_white_event_found_listener(&events_creator);
+ traverser.add_black_event_found_listener(&events_creator);
+ traverser.add_gray_event_found_listener(&events_creator);
+ traverser.traverse(bmsc);
+ traverser.remove_all_listeners();
+ MessagesCreatorListener messages_creator(this);
+ traverser.add_white_event_found_listener(&messages_creator);
+ traverser.traverse(bmsc);
+ }
+ return new_bmsc;
+}
+
+Event*& BMscDuplicator::get_copy(Event* e)
+{
+ bool just_set;
+ Event*& copy = e->get_attribute<Event*>(BMSC_DUPLICATOR_COPY_ATTR,NULL,just_set);
+ if(just_set)
+ {
+ m_modified_elements.push_back(e);
+ }
+ return copy;
+}
+
+BMscDuplicator::~BMscDuplicator()
+{
+ EventPList::const_iterator i;
+ for(i=m_modified_elements.begin();i!=m_modified_elements.end();i++)
+ {
+ (*i)->remove_attribute<Event*>(BMSC_DUPLICATOR_COPY_ATTR);
+ }
+}
+
+BMscPtr BMscDuplicator::duplicate(BMscPtr& bmsc)
+{
+ BMscDuplicator duplicator;
+ return duplicator.duplicate_bmsc(bmsc);
+}
+
+EventsCreatorListener::EventsCreatorListener(BMscDuplicator* duplicator, DFSAreaTraverser* traverser, BMsc* bmsc):
+ m_duplicator(duplicator),
+ m_traverser(traverser),
+ m_bmsc(bmsc),
+ m_last_instance(NULL),
+ m_last_area(NULL),
+ m_last_new_instance(NULL),
+ m_last_new_area(NULL)
+{
+
+}
+
+void EventsCreatorListener::on_white_event_found(Event* e)
+{
+ if(m_last_instance!=e->get_instance())
+ {
+ InstancePtr new_instance = new Instance(e->get_instance());
+ m_bmsc->add_instance(new_instance);
+ m_last_instance = e->get_instance();
+ m_last_new_instance = new_instance.get();
+ }
+ if(m_last_area!=e->get_general_area())
+ {
+ StrictOrderArea* strict = dynamic_cast<StrictOrderArea*>(e->get_general_area());
+ EventAreaPtr area;
+ if(strict)
+ {
+ area = new StrictOrderArea(strict);
+ }
+ else
+ {
+ area = new CoregionArea(dynamic_cast<CoregionArea*>(e->get_general_area()));
+ }
+ m_last_new_area = area.get();
+ m_last_new_instance->add_area(area);
+ m_last_area = e->get_general_area();
+ }
+ EventPtr new_event = m_last_new_area->add_event();
+ new_event->set_original(e);
+ Event*& copy = m_duplicator->get_copy(e);
+ copy = new_event.get();
+ create_successor(e);
+}
+
+CoregionEvent* EventsCreatorListener::get_preceding_event()
+{
+ const MscElementPList& elements = m_traverser->get_reached_elements();
+ if(elements.size()>1)
+ {
+ //in this case currently traversed event isn't alone in elements
+ MscElementPList::const_iterator i = elements.end();
+ i--; i--;
+ return dynamic_cast<CoregionEvent*>(*i);
+ }
+ return NULL;
+}
+
+void EventsCreatorListener::on_gray_event_found(Event* e)
+{
+ create_successor(e);
+}
+
+void EventsCreatorListener::on_black_event_found(Event* e)
+{
+ create_successor(e);
+}
+
+void EventsCreatorListener::create_successor(Event* e)
+{
+ CoregionEvent* coreg_new_event = dynamic_cast<CoregionEvent*>(e);
+ if(coreg_new_event)
+ {
+ CoregionEvent* preceding = get_preceding_event();
+ if(preceding)
+ {
+ preceding->add_successor(coreg_new_event);
+ }
+ }
+}
+
+MessagesCreatorListener::MessagesCreatorListener(BMscDuplicator* duplicator):
+m_duplicator(duplicator)
+{
+
+}
+
+void MessagesCreatorListener::on_white_event_found(Event* e)
+{
+ Event* event_copy = m_duplicator->get_copy(e);
+ if(e->is_matched())
+ {
+ if(e->is_send())
+ {
+ MscMessagePtr complete = new CompleteMessage(e,NULL,e->get_complete_message().get());
+ event_copy->set_message(complete);
+ Event* matching_copy = m_duplicator->get_copy(e->get_matching_event());
+ matching_copy->set_message(complete);
+ }
+ }
+ else
+ {
+ MscMessagePtr incomplete = new IncompleteMessage(e->get_incomplete_message().get());
+ event_copy->set_message(incomplete);
+ }
+}
+
+////////////////////////////////////////////////////////////////////////
+
+GraphCreatorListener::GraphCreatorListener(HMsc* hmsc):
+m_hmsc(hmsc)
+{
+}
+
+void GraphCreatorListener::on_white_node_found(HMscNode *n)
+{
+ HMscNodePtr node;
+ ReferenceNode* reference = dynamic_cast<ReferenceNode*>(n);
+ if(reference)
+ {
+ on_white_node_found(reference);
+ }
+ else
+ {
+ ConnectionNode* connection = dynamic_cast<ConnectionNode*>(n);
+ if(connection)
+ {
+ on_white_node_found(connection);
+ }
+ else
+ {
+ EndNode* end = dynamic_cast<EndNode*>(n);
+ if(end)
+ {
+ on_white_node_found(end);
+ }
+ else
+ {
+ StartNode* start = dynamic_cast<StartNode*>(n);
+ on_white_node_found(start);
+ }
+ }
+ }
+}
+
+
+void GraphCreatorListener::on_white_node_found(ReferenceNode* n)
+{
+ BMscPtr bmsc = n->get_bmsc();
+ HMscNodePtr new_node;
+ if(bmsc.get())
+ {
+ BMscPtr new_bmsc = BMscDuplicator::duplicate(bmsc);
+ ReferenceNode* reference = new ReferenceNode(n);
+ reference->set_msc(new_bmsc);
+ new_node = reference;
+ }
+ else
+ {
+ ConnectionNode* connection = new ConnectionNode(n);
+ new_node = connection;
+ ReferenceNode*& attribute = get_referencing_node(n->get_hmsc().get());
+ attribute = n;
+ }
+ process_new_node(n,new_node);
+}
+
+void GraphCreatorListener::on_white_node_found(StartNode* n)
+{
+ if(is_root_element(n))
+ {
+ //in this case duplicated Startnode was already created
+ m_new_nodes.push_back(m_hmsc->get_start().get());
+ set_copy(n,m_hmsc->get_start().get());
+ }
+}
+
+void GraphCreatorListener::on_white_node_found(EndNode* n)
+{
+ HMscNodePtr new_node;
+ if(is_root_element(n))
+ {
+ EndNode* end = new EndNode(n);
+ new_node = end;
+ }
+ else
+ {
+ ConnectionNode* connection = new ConnectionNode(n);
+ new_node = connection;
+ add_to_end_list(connection);
+ }
+ process_new_node(n,new_node);
+}
+
+ConnectionNodePList& GraphCreatorListener::get_end_list(ReferenceNode* reference)
+{
+ static ConnectionNodePList empty;
+ //attribute is removed when reference is finished in traversing
+ return reference->get_attribute<ConnectionNodePList>(BMSC_GRAPH_DUPLICATOR_ENDLIST_ATTR,empty);
+}
+
+void GraphCreatorListener::add_to_end_list(ConnectionNode* new_end)
+{
+ HMsc* original_hmsc = new_end->get_original()->get_owner();
+ ReferenceNode* original_reference = get_referencing_node(original_hmsc);
+ ConnectionNodePList& end_list = get_end_list(original_reference);
+ end_list.push_back(new_end);
+}
+
+void GraphCreatorListener::on_white_node_found(ConnectionNode* n)
+{
+ PredecessorNode* predecessor = get_predecessor();
+ HMscNodePtr new_node = new ConnectionNode(n);
+ process_new_node(n,new_node);
+}
+
+void GraphCreatorListener::process_new_node(HMscNode* old_node, HMscNodePtr& new_node)
+{
+ m_hmsc->add_node(new_node);
+ add_new_successor(new_node.get());
+ m_new_nodes.push_back(new_node.get());
+ set_copy(old_node,new_node.get());
+}
+
+bool GraphCreatorListener::is_root_element(HMscNode* n)
+{
+ return n->get_owner()==m_hmsc->get_original();
+}
+
+void GraphCreatorListener::set_copy(HMscNode* n, HMscNode* copy)
+{
+ HMscNode*& attribute = get_copy(n);
+ attribute = copy;
+}
+
+HMscNode*& GraphCreatorListener::get_copy(HMscNode* n)
+{
+ bool just_set;
+ HMscNode*& copy = n->get_attribute<HMscNode*>(BMSC_DUPLICATOR_COPY_ATTR,NULL,just_set);
+ if(just_set)
+ {
+ m_modified_elements.push_back(n);
+ }
+ return copy;
+}
+
+PredecessorNode* GraphCreatorListener::get_predecessor()
+{
+ return dynamic_cast<PredecessorNode*>(m_new_nodes.back());
+}
+
+void GraphCreatorListener::process_nonwhite_node(HMscNode* n)
+{
+ HMscNode* copy = get_copy(n);
+ add_new_successor(copy);
+}
+
+void GraphCreatorListener::on_gray_node_found(HMscNode* n)
+{
+ process_nonwhite_node(n);
+}
+
+void GraphCreatorListener::on_black_node_found(HMscNode* n)
+{
+ process_nonwhite_node(n);
+}
+
+void GraphCreatorListener::on_node_finished(HMscNode* n)
+{
+ HMscNodePtr node;
+ ReferenceNode* reference = dynamic_cast<ReferenceNode*>(n);
+ if(reference)
+ {
+ on_node_finished(reference);
+ }
+ else
+ {
+ ConnectionNode* connection = dynamic_cast<ConnectionNode*>(n);
+ if(connection)
+ {
+ on_node_finished(connection);
+ }
+ else
+ {
+ EndNode* end = dynamic_cast<EndNode*>(n);
+ if(end)
+ {
+ on_node_finished(end);
+ }
+ else
+ {
+ StartNode* start = dynamic_cast<StartNode*>(n);
+ on_node_finished(start);
+ }
+ }
+ }
+}
+
+void GraphCreatorListener::on_node_finished(ReferenceNode* n)
+{
+ n->remove_attribute<ConnectionNodePList>(BMSC_GRAPH_DUPLICATOR_ENDLIST_ATTR);
+ m_new_nodes.pop_back();
+}
+
+void GraphCreatorListener::on_node_finished(StartNode* n)
+{
+ if(is_root_element(n))
+ {
+ m_new_nodes.pop_back();
+ }
+}
+
+void GraphCreatorListener::on_node_finished(EndNode* n)
+{
+ m_new_nodes.pop_back();
+}
+
+void GraphCreatorListener::on_node_finished(ConnectionNode* n)
+{
+ m_new_nodes.pop_back();
+}
+
+ReferenceNode*& GraphCreatorListener::get_referencing_node(HMsc* hmsc)
+{
+ bool just_set;
+ ReferenceNode*& reference = hmsc->get_attribute<ReferenceNode*>(BMSC_GRAPH_DUPLICATOR_REF_ATTR,NULL,just_set);
+ if(just_set)
+ {
+ m_modified_hmscs.push_back(hmsc);
+ }
+ return reference;
+}
+
+void GraphCreatorListener::add_new_successor(HMscNode* new_successor)
+{
+ SuccessorNode* new_succ = dynamic_cast<SuccessorNode*>(new_successor);
+ PredecessorNode* predecessor = get_predecessor();
+ ConnectionNode* connection = dynamic_cast<ConnectionNode*>(predecessor);
+ if(connection)
+ {
+ ReferenceNode* original_reference = dynamic_cast<ReferenceNode*>(connection->get_original());
+ if(original_reference &&
+ new_successor->get_original()->get_owner()==original_reference->get_owner())
+ {
+ //connection was transformed from ReferenceNode and probably contains end_list,
+ //elements of the end_list must become predecessors of new_successor which
+ //must be from same HMsc as original_reference
+ ConnectionNodePList& end_list = get_end_list(original_reference);
+ ConnectionNodePList::const_iterator i;
+ for(i=end_list.begin();i!=end_list.end();i++)
+ {
+ (*i)->add_successor(new_succ);
+ }
+ return;
+ }
+ }
+ predecessor->add_successor(new_succ);
+}
+
+GraphCreatorListener::~GraphCreatorListener()
+{
+ while(!m_modified_elements.empty())
+ {
+ MscElement* e = m_modified_elements.back();
+ e->remove_attribute<HMscNode*>(BMSC_DUPLICATOR_COPY_ATTR);
+ m_modified_elements.pop_back();
+ }
+ while(!m_modified_hmscs.empty())
+ {
+ HMsc* h = m_modified_hmscs.back();
+ h->remove_attribute<ReferenceNode*>(BMSC_GRAPH_DUPLICATOR_REF_ATTR);
+ m_modified_hmscs.pop_back();
+ }
+}
+
+HMscPtr BMscGraphDuplicator::duplicate(HMscPtr& hmsc)
+{
+ HMscPtr new_hmsc;
+ if(hmsc.get())
+ {
+ new_hmsc = new HMsc(hmsc.get());
+ GraphCreatorListener listener(new_hmsc.get());
+ DFSBMscGraphTraverser traverser;
+ traverser.add_black_node_found_listener(&listener);
+ traverser.add_gray_node_found_listener(&listener);
+ traverser.add_node_finished_listener(&listener);
+ traverser.add_white_node_found_listener(&listener);
+ traverser.traverse(hmsc);
+ }
+ return new_hmsc;
+}
+
+
Modified: trunk/src/data/msc.cpp
===================================================================
--- trunk/src/data/msc.cpp 2008-11-23 22:03:00 UTC (rev 121)
+++ trunk/src/data/msc.cpp 2008-11-28 20:26:06 UTC (rev 122)
@@ -73,6 +73,10 @@
node->set_owner(this);
}
+void HMsc::remode_node(HMscNode* node)
+{
+}
+
////////////////////////////////////
/*inline StrictOrderArea* StrictEvent::get_strict_order_area()
Modified: trunk/src/data/msc.h
===================================================================
--- trunk/src/data/msc.h 2008-11-23 22:03:00 UTC (rev 121)
+++ trunk/src/data/msc.h 2008-11-28 20:26:06 UTC (rev 122)
@@ -691,6 +691,8 @@
}
void add_node(HMscNodePtr node);
+
+ void remode_node(HMscNode* node);
void remove_node(HMscNodePtr node)
{
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ba...@us...> - 2008-11-29 21:18:19
|
Revision: 125
http://scstudio.svn.sourceforge.net/scstudio/?rev=125&view=rev
Author: babicaj
Date: 2008-11-29 21:18:12 +0000 (Sat, 29 Nov 2008)
Log Message:
-----------
RaceChecker integrated into new build -- needs to be tested (coming soon)
Modified Paths:
--------------
trunk/src/check/CMakeLists.txt
trunk/src/check/pseudocode/CMakeLists.txt
trunk/src/check/pseudocode/msc_duplicators.cpp
trunk/src/check/pseudocode/msc_duplicators.h
trunk/src/check/pseudocode/refnode_finder.h
trunk/src/check/pseudocode/utils.h
trunk/src/check/race/CMakeLists.txt
trunk/src/check/race/bmsc_race_checker.cpp
trunk/src/check/race/footprint.cpp
trunk/src/check/race/footprint.h
trunk/src/check/race/race_checker.cpp
trunk/src/check/race/race_checker.h
trunk/src/data/CMakeLists.txt
trunk/src/data/dfs_bmsc_graph_traverser.h
trunk/src/data/dfs_events_traverser.h
trunk/src/data/dfs_instance_events_traverser.cpp
trunk/src/data/dfs_instance_events_traverser.h
trunk/src/data/msc.cpp
trunk/src/data/msc.h
Added Paths:
-----------
trunk/src/check/pseudocode/utils.cpp
trunk/src/check/race/export.h
Modified: trunk/src/check/CMakeLists.txt
===================================================================
--- trunk/src/check/CMakeLists.txt 2008-11-29 11:22:31 UTC (rev 124)
+++ trunk/src/check/CMakeLists.txt 2008-11-29 21:18:12 UTC (rev 125)
@@ -3,6 +3,6 @@
# plug-ins
ADD_SUBDIRECTORY(liveness)
ADD_SUBDIRECTORY(order)
-# ADD_SUBDIRECTORY(race)
+ADD_SUBDIRECTORY(race)
# $Id$
Modified: trunk/src/check/pseudocode/CMakeLists.txt
===================================================================
--- trunk/src/check/pseudocode/CMakeLists.txt 2008-11-29 11:22:31 UTC (rev 124)
+++ trunk/src/check/pseudocode/CMakeLists.txt 2008-11-29 21:18:12 UTC (rev 125)
@@ -5,7 +5,10 @@
visual_closure_initiator.h
refnode_finder.cpp
refnode_finder.h
+ utils.cpp
utils.h
+ msc_duplicators.cpp
+ msc_duplicators.h
)
TARGET_LINK_LIBRARIES(scpseudocode
Modified: trunk/src/check/pseudocode/msc_duplicators.cpp
===================================================================
--- trunk/src/check/pseudocode/msc_duplicators.cpp 2008-11-29 11:22:31 UTC (rev 124)
+++ trunk/src/check/pseudocode/msc_duplicators.cpp 2008-11-29 21:18:12 UTC (rev 125)
@@ -16,7 +16,7 @@
* $Id$
*/
-#include "check/msc_duplicators.h"
+#include "check/pseudocode/msc_duplicators.h"
#include "data/dfs_instance_events_traverser.h"
const std::string BMSC_DUPLICATOR_TRAVERSING_ATTR = "BDcolor";
Modified: trunk/src/check/pseudocode/msc_duplicators.h
===================================================================
--- trunk/src/check/pseudocode/msc_duplicators.h 2008-11-29 11:22:31 UTC (rev 124)
+++ trunk/src/check/pseudocode/msc_duplicators.h 2008-11-29 21:18:12 UTC (rev 125)
@@ -19,6 +19,7 @@
#include "data/msc.h"
#include "data/dfs_area_traverser.h"
#include "data/dfs_bmsc_graph_traverser.h"
+#include "check/pseudocode/export.h"
typedef std::list<Event*> EventPList;
typedef std::list<ReferenceNode*> ReferenceNodePList;
@@ -82,7 +83,7 @@
* Duplicated BMsc's elemenents have set attribute original to the original
* BMsc's elements.
*/
-class BMscDuplicator
+class SCPSEUDOCODE_EXPORT BMscDuplicator
{
protected:
@@ -176,7 +177,7 @@
* of the same kind are transformed into ConnectionNodes referencing original
* EndNodes.
*/
-class BMscGraphDuplicator
+class SCPSEUDOCODE_EXPORT BMscGraphDuplicator
{
public:
Modified: trunk/src/check/pseudocode/refnode_finder.h
===================================================================
--- trunk/src/check/pseudocode/refnode_finder.h 2008-11-29 11:22:31 UTC (rev 124)
+++ trunk/src/check/pseudocode/refnode_finder.h 2008-11-29 21:18:12 UTC (rev 125)
@@ -21,6 +21,7 @@
#include <list>
#include "data/dfs_bmsc_graph_traverser.h"
+#include "check/pseudocode/export.h"
typedef std::list<HMscNode*> HMscNodePList;
typedef counted_ptr<HMscNodePList> HMscNodePListPtr;
@@ -67,7 +68,7 @@
/**
* \brief See method traverse(HMscNode* node) for purpose.
*/
-class ReferenceNodeFinder: public DFSBMscGraphTraverser
+class SCPSEUDOCODE_EXPORT ReferenceNodeFinder: public DFSBMscGraphTraverser
{
public:
Added: trunk/src/check/pseudocode/utils.cpp
===================================================================
--- trunk/src/check/pseudocode/utils.cpp (rev 0)
+++ trunk/src/check/pseudocode/utils.cpp 2008-11-29 21:18:12 UTC (rev 125)
@@ -0,0 +1,63 @@
+#include "check/pseudocode/utils.h"
+
+//////////////////////////////////////////////////////////
+
+WhiteNodeMarker::WhiteNodeMarker(const std::string& mark):
+m_mark(mark)
+{
+}
+
+WhiteNodeMarker::~WhiteNodeMarker()
+{
+ cleanup_attributes();
+}
+
+void WhiteNodeMarker::cleanup_attributes()
+{
+ remove_attributes<HMscNodePList,bool>(m_modified,m_mark);
+}
+
+void WhiteNodeMarker::on_white_node_found(HMscNode* n)
+{
+ bool& mark = get_mark(n);
+ mark = true;
+}
+
+bool& WhiteNodeMarker::get_mark(HMscNode* n)
+{
+ bool just_set;
+ bool& mark = n->get_attribute(m_mark,false,just_set);
+ if(just_set)
+ {
+ m_modified.push_back(n);
+ }
+ return mark;
+}
+
+//////////////////////////////////////////////////////////
+
+
+NoendingNodesEliminator::NoendingNodesEliminator()
+{
+ m_back_traverser.add_white_node_found_listener(&m_marker);
+}
+
+void NoendingNodesEliminator::eliminate(HMscPtr& hmsc)
+{
+ m_back_traverser.traverse(hmsc);
+ HMscNodePList noending;
+ HMscNodePtrSet::const_iterator i;
+ for(i=hmsc->get_nodes().begin();i!=hmsc->get_nodes().end();i++)
+ {
+ if(!m_marker.get_mark((*i).get()))
+ {
+ noending.push_back((*i).get());
+ }
+ }
+ m_marker.cleanup_attributes();
+ HMscNodePList::const_iterator n;
+ for(n=noending.begin();n!=noending.end();n++)
+ {
+ (*n)->get_owner()->remove_node(*n);
+ }
+}
Modified: trunk/src/check/pseudocode/utils.h
===================================================================
--- trunk/src/check/pseudocode/utils.h 2008-11-29 11:22:31 UTC (rev 124)
+++ trunk/src/check/pseudocode/utils.h 2008-11-29 21:18:12 UTC (rev 125)
@@ -3,7 +3,10 @@
#include <string>
+#include "data/dfs_events_traverser.h"
#include "data/dfs_bmsc_graph_traverser.h"
+#include "data/dfsb_hmsc_traverser.h"
+#include "check/pseudocode/export.h"
typedef std::map<std::string,size_t> StringSizeTMap;
@@ -103,6 +106,68 @@
}
};
+template<class MscElementContainer,class AttributeType>
+void remove_attributes(MscElementContainer& container, const std::string& name)
+{
+ MscElementContainer::const_iterator i;
+ for(i=container.begin();i!=container.end();i++)
+ {
+ (*i)->remove_attribute<AttributeType>(name);
+ }
+}
+
+/**
+ * /brief Eliminates from hmsc nodes which are not reachable from
+ * end nodes of hmsc.
+ */
+void eliminate_noending_nodes(HMscPtr& hmsc);
+
+/**
+ * /brief Marks white nodes by boolean true
+ */
+class SCPSEUDOCODE_EXPORT WhiteNodeMarker: public WhiteNodeFoundListener
+{
+protected:
+
+ HMscNodePList m_modified;
+
+ std::string m_mark;
+
+public:
+
+ WhiteNodeMarker(const std::string& mark="mark");
+
+ ~WhiteNodeMarker();
+
+ void cleanup_attributes();
+
+ void on_white_node_found(HMscNode* n);
+
+ bool& get_mark(HMscNode* n);
+};
+
+/**
+ * /brief Eliminates nodes which are not reachable from end node.
+ *
+ * Currently supports only BMsc graph, please extend implementation if
+ * neccessary.
+ */
+class NoendingNodesEliminator
+{
+protected:
+
+ WhiteNodeMarker m_marker;
+
+ DFSBHMscTraverser m_back_traverser;
+
+public:
+
+ NoendingNodesEliminator();
+
+ void eliminate(HMscPtr& hmsc);
+
+};
+
#endif /* _UTILS_H */
// $Id$
Modified: trunk/src/check/race/CMakeLists.txt
===================================================================
--- trunk/src/check/race/CMakeLists.txt 2008-11-29 11:22:31 UTC (rev 124)
+++ trunk/src/check/race/CMakeLists.txt 2008-11-29 21:18:12 UTC (rev 125)
@@ -5,6 +5,11 @@
footprint.h
)
+TARGET_LINK_LIBRARIES(scrace
+ scmsc
+ scpseudocode
+)
+
INSTALL(TARGETS scrace
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib
Modified: trunk/src/check/race/bmsc_race_checker.cpp
===================================================================
--- trunk/src/check/race/bmsc_race_checker.cpp 2008-11-29 11:22:31 UTC (rev 124)
+++ trunk/src/check/race/bmsc_race_checker.cpp 2008-11-29 21:18:12 UTC (rev 125)
@@ -16,7 +16,7 @@
* $Id$
*/
-#include "check/race/bmsc_race_checker.h"
+#include "check/race/race_checker.h"
void MinimalEventsInitiator::on_white_node_found(ReferenceNode* node)
{
Added: trunk/src/check/race/export.h
===================================================================
--- trunk/src/check/race/export.h (rev 0)
+++ trunk/src/check/race/export.h 2008-11-29 21:18:12 UTC (rev 125)
@@ -0,0 +1,37 @@
+/*
+ * 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 Petr Gotthard <pet...@ce...>
+ *
+ * $Id$
+ */
+
+#ifndef _SCRACE_EXPORT_H
+#define _SCRACE_EXPORT_H
+
+#if defined(_MSC_VER)
+#pragma warning(disable: 4251)
+
+#if defined(scrace_EXPORTS)
+#define SCRACE_EXPORT __declspec(dllexport)
+#else
+#define SCRACE_EXPORT __declspec(dllimport)
+#endif
+
+#else
+#define SCRACE_EXPORT
+#endif
+
+#endif /* _SCRACE_EXPORT_H */
+
+// $Id$
Property changes on: trunk/src/check/race/export.h
___________________________________________________________________
Added: svn:keywords
+ Id
Added: svn:eol-style
+ native
Modified: trunk/src/check/race/footprint.cpp
===================================================================
--- trunk/src/check/race/footprint.cpp 2008-11-29 11:22:31 UTC (rev 124)
+++ trunk/src/check/race/footprint.cpp 2008-11-29 21:18:12 UTC (rev 125)
@@ -16,7 +16,7 @@
* $Id$
*/
-#include "check/footprint.h"
+#include "check/race/footprint.h"
bool EDInstancesPtrComparator::operator()(const EDInstancesPtr& a, const EDInstancesPtr& b)
{
@@ -44,7 +44,7 @@
if(m_event<di.m_event) return -1;
if(di.m_event<m_event) return 1;
//compare bool vector as binary number
- for(int i=0; i<m_instances.size(); i++)
+ for(size_t i=0; i<m_instances.size(); i++)
{
if(m_instances[i]!=di.m_instances[i])
return m_instances[i]-di.m_instances[i];
@@ -129,7 +129,7 @@
Footprint::Footprint(
FootprintPtr previous,
- const InnerNodePList& path,
+ const MscElementPList& path,
const ExtremeEvents& max_events_less,
const ExtremeEvents& max_events_greater)
:ExtremeEvents(previous->get_events_instances().size())
@@ -200,9 +200,9 @@
}
}
-PredecessorNode* Footprint::get_node()
+ReferenceNode* Footprint::get_node()
{
- return m_path.back();
+ return dynamic_cast<ReferenceNode*>(m_path.back());
}
// $Id$
Modified: trunk/src/check/race/footprint.h
===================================================================
--- trunk/src/check/race/footprint.h 2008-11-29 11:22:31 UTC (rev 124)
+++ trunk/src/check/race/footprint.h 2008-11-29 21:18:12 UTC (rev 125)
@@ -32,8 +32,7 @@
typedef std::vector<bool> BoolVector;
typedef counted_ptr<EventDependentInstances> EDInstancesPtr;
typedef counted_ptr<Footprint> FootprintPtr;
-typedef std::list<InnerNode*> InnerNodePList;
-typedef std::list<PredecessorNode*> PredecessorNodePList;
+typedef std::list<MscElement*> MscElementPList;
class EDInstancesPtrComparator
{
@@ -163,7 +162,7 @@
* All remaining members of this m_path are supposed to be
* ConnectionNodes.
*/
- PredecessorNodePList m_path;
+ MscElementPList m_path;
/**
* Previous Footprint which was this one created from.
@@ -194,11 +193,11 @@
*/
Footprint(
FootprintPtr previous,
- const InnerNodePList& path,
+ const MscElementPList& path,
const ExtremeEvents& max_events_less,
const ExtremeEvents& max_events_greater);
- PredecessorNode* get_node();
+ ReferenceNode* get_node();
};
#endif /* _FOOTPRINT_H */
Modified: trunk/src/check/race/race_checker.cpp
===================================================================
--- trunk/src/check/race/race_checker.cpp 2008-11-29 11:22:31 UTC (rev 124)
+++ trunk/src/check/race/race_checker.cpp 2008-11-29 21:18:12 UTC (rev 125)
@@ -20,6 +20,7 @@
#include "check/race/race_checker.h"
+#include "check/pseudocode/msc_duplicators.h"
ExtremeEvents& MinimalEventsInitiator::get_events(BMsc* b)
{
@@ -37,7 +38,7 @@
InstancePtrList::const_iterator i;
for(i=instances.begin();i!=instances.end();i++)
{
- EventPList* events = DFSInstanceEventsTraverser::topology_order((*i).get());
+ EventPListPtr events = DFSInstanceEventsTraverser::topology_order((*i).get());
EventPList::const_iterator e1;
for(e1 = events->begin();e1!=events->end();e1++)
{
@@ -57,7 +58,6 @@
if(e2==events->end())
minimal_events.push_back(*e1);
}
- delete events;
}
/*
For each Event e1 from minimal_events find Instances containing less Events
@@ -112,7 +112,7 @@
InstancePtrList::const_iterator i;
for(i=instances.begin();i!=instances.end();i++)
{
- EventPList* events = DFSInstanceEventsTraverser::topology_order((*i).get());
+ EventPListPtr events = DFSInstanceEventsTraverser::topology_order((*i).get());
EventPList::const_iterator e1 = events->begin();
while(e1!=events->end())
{
@@ -134,7 +134,6 @@
maximal_events.push_back(*e1);
e1++;
}
- delete events;
}
/*
* For any Event e1 from maximal_events find Instances containing any Event e2
@@ -201,47 +200,47 @@
BMsc* RaceChecker::create_counter_example(Event* e1, Event* e2)
{
BMsc* bmsc = new BMsc(e1->get_instance()->get_bmsc());
- InstancePtr common_instance = new Instance(bmsc,e1->get_instance());
- bmsc->add_instance(common_instance);
- BoolVector& e2_causal = m_causal_initiator.get_causal_closure(e2);
- size_t e1_index = m_visual_initiator.get_topology_index(e1);
- MscMessagePtr e1_message;
- if(e1->is_send())
- e1_message = new MscMessage(
- common_instance.get(),NULL,e1->get_message().get());
- else
- e1_message = new MscMessage(
- NULL,common_instance.get(),e1->get_message().get());
- MscMessagePtr e2_message;
- if(e2->is_send())
- e2_message = new MscMessage(
- common_instance.get(),NULL,e2->get_message().get());
- else
- e2_message = new MscMessage(
- NULL,common_instance.get(),e2->get_message().get());
- //e2 << e1
- if(e2_causal[e1_index])
- {
- StrictOrderAreaPtr common_strict = new StrictOrderArea(
- common_instance.get());
- StrictEventPtr e1_strict = new StrictEvent(common_strict.get(),e1_message,e1);
- StrictEventPtr e2_strict = new StrictEvent(common_strict.get(),e2_message,e2);
- common_strict->set_first(e1_strict);
- e1_strict->set_successor(e2_strict);
- common_instance->set_first(common_strict);
- }
- //e2 || e1
- else
- {
- CoregionAreaPtr common_coregion = new CoregionArea(common_instance.get());
- CoregionEvent* e1_coregion = new CoregionEvent(
- common_coregion.get(),e1_message,e1);
- CoregionEvent* e2_coregion = new CoregionEvent(
- common_coregion.get(),e2_message,e2);
- common_coregion->add_minimal_event(e1_coregion);
- common_coregion->add_minimal_event(e2_coregion);
- common_instance->set_first(common_coregion);
- }
+ //InstancePtr common_instance = new Instance(bmsc,e1->get_instance());
+ //bmsc->add_instance(common_instance);
+ //BoolVector& e2_causal = m_causal_initiator.get_causal_closure(e2);
+ //size_t e1_index = m_visual_initiator.get_topology_index(e1);
+ //MscMessagePtr e1_message;
+ //if(e1->is_send())
+ // e1_message = new MscMessage(
+ // common_instance.get(),NULL,e1->get_message().get());
+ //else
+ // e1_message = new MscMessage(
+ // NULL,common_instance.get(),e1->get_message().get());
+ //MscMessagePtr e2_message;
+ //if(e2->is_send())
+ // e2_message = new MscMessage(
+ // common_instance.get(),NULL,e2->get_message().get());
+ //else
+ // e2_message = new MscMessage(
+ // NULL,common_instance.get(),e2->get_message().get());
+ ////e2 << e1
+ //if(e2_causal[e1_index])
+ //{
+ // StrictOrderAreaPtr common_strict = new StrictOrderArea(
+ // common_instance.get());
+ // StrictEventPtr e1_strict = new StrictEvent(common_strict.get(),e1_message,e1);
+ // StrictEventPtr e2_strict = new StrictEvent(common_strict.get(),e2_message,e2);
+ // common_strict->set_first(e1_strict);
+ // e1_strict->set_successor(e2_strict);
+ // common_instance->set_first(common_strict);
+ //}
+ ////e2 || e1
+ //else
+ //{
+ // CoregionAreaPtr common_coregion = new CoregionArea(common_instance.get());
+ // CoregionEvent* e1_coregion = new CoregionEvent(
+ // common_coregion.get(),e1_message,e1);
+ // CoregionEvent* e2_coregion = new CoregionEvent(
+ // common_coregion.get(),e2_message,e2);
+ // common_coregion->add_minimal_event(e1_coregion);
+ // common_coregion->add_minimal_event(e2_coregion);
+ // common_instance->set_first(common_coregion);
+ //}
return bmsc;
}
@@ -311,12 +310,13 @@
HMscPtr RaceChecker::check(HMscPtr hmsc, ChannelMapperPtr mapper)
{
- //TODO:transform hmsc into BMsc graph
+ //transform hmsc into BMsc graph
+ HMscPtr transformed = BMscGraphDuplicator::duplicate(hmsc);
//compute causal closure of all BMsc and check BMscs to be race free
HMscPtr res = check_bmscs(hmsc,mapper);
if(res.get())
return res;
- //precompute possible things for race checking - e.g. MinP
+ //precompute possible things for race checking - e.g. MinP
prepare_hmsc(hmsc,mapper);
//check hmsc to be race free
return check_hmsc(hmsc,mapper);
@@ -324,9 +324,18 @@
HMscPtr RaceChecker::check_hmsc(HMscPtr hmsc,ChannelMapperPtr mapper)
{
+ HMscPtr error;
FootprintTraverser t(hmsc.get(),mapper.get(),m_instance_marker.get_count(),
&m_min_events_initiator,&m_max_events_initiator);
- t.traverse();
+ try
+ {
+ t.traverse();
+ }
+ catch(RaceInHMscException& e)
+ {
+ error = create_counter_example(e);
+ }
+ return error;
}
/**
@@ -344,24 +353,25 @@
}
catch(RaceInBMscException& e)
{
- counter_example = create_counter_example(traverser.get_reached_nodes(),e.get_example());
+ counter_example = create_counter_example(traverser.get_reached_elements(),e.get_example());
}
return counter_example;
}
-HMscPtr RaceChecker::create_counter_example(const InnerNodePListList& path, BMscPtr example)
+HMscPtr RaceChecker::create_counter_example(const MscElementPListList& path, BMscPtr example)
{
//TODO: create counter example
- return HMscPtr();
+ return HMscPtr(new HMsc());
}
-HMscPtr create_counter_example(RaceInHMscException* e)
+HMscPtr RaceChecker::create_counter_example(RaceInHMscException& e)
{
//TODO: create counter example
- delete e;
- return HMscPtr();
+ return HMscPtr(new HMsc());
}
+////////////////////////////////////////////////////////////////////////////////////
+
FootprintTraverser::FootprintTraverser(
HMsc* hmsc,
ChannelMapper* mapper,
@@ -389,7 +399,7 @@
{
m_footprint = extract_todo();
done.insert(m_footprint);
- traverse(m_footprint->get_node());
+ ReferenceNodeFinder::traverse(m_footprint->get_node());
}
}
@@ -397,7 +407,7 @@
{
check_race(node->get_bmsc().get());
FootprintPtr f = new Footprint(
- m_footprint,this->get_reached_nodes().back(),
+ m_footprint,this->get_reached_elements().back(),
m_max->get_events_less(node->get_bmsc().get()),
m_max->get_events_greater(node->get_bmsc().get()));
if(todo.find(f)!=todo.end() && done.find(f)!=done.end())
@@ -426,7 +436,7 @@
Event* a_event = (*a)->get_event();
if(a_event->is_receive() && !m_mapper->same_channel(a_event,b_event))
{
- throw new RaceInHMscException(m_footprint,b_event,a_event,get_reached_nodes().back());
+ throw new RaceInHMscException(m_footprint,b_event,a_event,get_reached_elements().back());
}
else if(a_event->is_send())
{
@@ -441,7 +451,7 @@
}
if(j==a_instances.size())
{
- throw new RaceInHMscException(m_footprint,b_event,a_event,get_reached_nodes().back());
+ throw new RaceInHMscException(m_footprint,b_event,a_event,get_reached_elements().back());
}
}
}
@@ -450,4 +460,33 @@
}
}
+////////////////////////////////////////////////////////////////////////////////
+
+RaceInHMscException::RaceInHMscException(FootprintPtr& footprint,Event* first, Event* second,
+ const MscElementPList& path_to_second):
+ m_footprint(footprint),m_first(first),
+ m_second(second),m_path_to_second(path_to_second)
+{
+}
+
+FootprintPtr& RaceInHMscException::get_footprint()
+{
+ return m_footprint;
+}
+
+Event* RaceInHMscException::get_first()
+{
+ return m_first;
+}
+
+Event* RaceInHMscException::get_second()
+{
+ return m_second;
+}
+
+MscElementPList& RaceInHMscException::get_path_to_second()
+{
+ return m_path_to_second;
+}
+
// $Id$
Modified: trunk/src/check/race/race_checker.h
===================================================================
--- trunk/src/check/race/race_checker.h 2008-11-29 11:22:31 UTC (rev 124)
+++ trunk/src/check/race/race_checker.h 2008-11-29 21:18:12 UTC (rev 125)
@@ -28,6 +28,7 @@
#include "check/pseudocode/utils.h"
#include "check/pseudocode/refnode_finder.h"
#include "check/race/footprint.h"
+#include "check/race/export.h"
class BMscRaceCheckingListener;
class RaceInBMscException;
@@ -159,7 +160,7 @@
void traverse();
- void traverse(PredecessorNode* node);
+ //void traverse(PredecessorNode* node);
};
@@ -191,7 +192,7 @@
/**
*
*/
- HMscPtr create_counter_example(RaceInHMscException* e);
+ HMscPtr create_counter_example(RaceInHMscException& e);
/**
* Precomputes neccessary things for race checking
@@ -206,7 +207,7 @@
/**
* Creates counter example in case there is any race violating BMsc
*/
- HMscPtr create_counter_example(const InnerNodePListList& path, BMscPtr example);
+ HMscPtr create_counter_example(const MscElementPListList& path, BMscPtr example);
HMscPtr check_hmsc(HMscPtr hmsc, ChannelMapperPtr mapper);
@@ -364,17 +365,22 @@
FootprintPtr m_footprint;
Event* m_first;
Event* m_second;
- InnerNodePList m_path_to_second;
+ MscElementPList m_path_to_second;
public:
- RaceInHMscException(FootprintPtr footprint,Event* first, Event* second,
- const InnerNodePList& path_to_second);
+ RaceInHMscException(FootprintPtr& footprint,Event* first, Event* second,
+ const MscElementPList& path_to_second);
~RaceInHMscException() throw ()
{
}
+
+ FootprintPtr& get_footprint();
+ Event* get_first();
+ Event* get_second();
+ MscElementPList& get_path_to_second();
};
#endif /* _HMSC_RACE_CHECKER_H */
Modified: trunk/src/data/CMakeLists.txt
===================================================================
--- trunk/src/data/CMakeLists.txt 2008-11-29 11:22:31 UTC (rev 124)
+++ trunk/src/data/CMakeLists.txt 2008-11-29 21:18:12 UTC (rev 125)
@@ -3,8 +3,8 @@
msc.cpp
msc.h
msc_visual.h
-# dfs_area_traverser.cpp
-# dfs_area_traverser.h
+ dfs_area_traverser.cpp
+ dfs_area_traverser.h
dfs_events_traverser.cpp
dfs_events_traverser.h
dfs_hmsc_traverser.cpp
Modified: trunk/src/data/dfs_bmsc_graph_traverser.h
===================================================================
--- trunk/src/data/dfs_bmsc_graph_traverser.h 2008-11-29 11:22:31 UTC (rev 124)
+++ trunk/src/data/dfs_bmsc_graph_traverser.h 2008-11-29 21:18:12 UTC (rev 125)
@@ -33,7 +33,7 @@
/**
* Listener of founded white HMscNode
*/
-class WhiteNodeFoundListener
+class SCMSC_EXPORT WhiteNodeFoundListener
{
public:
@@ -48,7 +48,7 @@
/**
* Listener of founded gray HMscNode
*/
-class GrayNodeFoundListener
+class SCMSC_EXPORT GrayNodeFoundListener
{
public:
@@ -63,7 +63,7 @@
/**
* Listener of founded black HMscNode
*/
-class BlackNodeFoundListener
+class SCMSC_EXPORT BlackNodeFoundListener
{
public:
@@ -78,7 +78,7 @@
/**
* Listener of finished HMscNode
*/
-class NodeFinishedListener
+class SCMSC_EXPORT NodeFinishedListener
{
public:
@@ -95,7 +95,7 @@
*
* Extend this listener to process only ReferenceNodes during traversing.
*/
-class WhiteRefNodeFoundListener:public WhiteNodeFoundListener
+class SCMSC_EXPORT WhiteRefNodeFoundListener:public WhiteNodeFoundListener
{
public:
@@ -120,7 +120,7 @@
*
* Extend this listener to process only ReferenceNodes during traversing.
*/
-class GrayRefNodeFoundListener:public GrayNodeFoundListener
+class SCMSC_EXPORT GrayRefNodeFoundListener:public GrayNodeFoundListener
{
public:
@@ -145,7 +145,7 @@
*
* Extend this listener to process only ReferenceNodes during traversing.
*/
-class BlackRefNodeFoundListener:public BlackNodeFoundListener
+class SCMSC_EXPORT BlackRefNodeFoundListener:public BlackNodeFoundListener
{
public:
@@ -170,7 +170,7 @@
*
* Extend this listener to process only ReferenceNodes during traversing.
*/
-class RefNodeFinishedListener:public NodeFinishedListener
+class SCMSC_EXPORT RefNodeFinishedListener:public NodeFinishedListener
{
public:
Modified: trunk/src/data/dfs_events_traverser.h
===================================================================
--- trunk/src/data/dfs_events_traverser.h 2008-11-29 11:22:31 UTC (rev 124)
+++ trunk/src/data/dfs_events_traverser.h 2008-11-29 21:18:12 UTC (rev 125)
@@ -28,7 +28,7 @@
/**
* Listener of founded white Event
*/
-class WhiteEventFoundListener
+class SCMSC_EXPORT WhiteEventFoundListener
{
public:
@@ -43,7 +43,7 @@
/**
* Listener of founded white Event
*/
-class GrayEventFoundListener
+class SCMSC_EXPORT GrayEventFoundListener
{
public:
@@ -58,7 +58,7 @@
/**
* Listener of founded black Event
*/
-class BlackEventFoundListener
+class SCMSC_EXPORT BlackEventFoundListener
{
public:
@@ -73,7 +73,7 @@
/**
* Listener of finished Event
*/
-class EventFinishedListener
+class SCMSC_EXPORT EventFinishedListener
{
public:
Modified: trunk/src/data/dfs_instance_events_traverser.cpp
===================================================================
--- trunk/src/data/dfs_instance_events_traverser.cpp 2008-11-29 11:22:31 UTC (rev 124)
+++ trunk/src/data/dfs_instance_events_traverser.cpp 2008-11-29 21:18:12 UTC (rev 125)
@@ -67,11 +67,11 @@
}
}
-EventPList* DFSInstanceEventsTraverser::topology_order(Instance* i)
+EventPListPtr DFSInstanceEventsTraverser::topology_order(Instance* i)
{
- EventPList* topology = new EventPList;
+ EventPListPtr topology = new EventPList;
DFSInstanceEventsTraverser traverser;
- TopologyOrderListener listener(topology);
+ TopologyOrderListener listener(topology.get());
traverser.add_event_finished_listener(&listener);
traverser.traverse(i);
return topology;
Modified: trunk/src/data/dfs_instance_events_traverser.h
===================================================================
--- trunk/src/data/dfs_instance_events_traverser.h 2008-11-29 11:22:31 UTC (rev 124)
+++ trunk/src/data/dfs_instance_events_traverser.h 2008-11-29 21:18:12 UTC (rev 125)
@@ -21,6 +21,8 @@
#include "data/dfs_events_traverser.h"
+typedef counted_ptr<EventPList> EventPListPtr;
+
/**
* Processes only Instances' Events during depth first search.
*
@@ -37,7 +39,7 @@
using DFSEventsTraverser::traverse;
- static EventPList* topology_order(Instance* i);
+ static EventPListPtr topology_order(Instance* i);
protected:
Modified: trunk/src/data/msc.cpp
===================================================================
--- trunk/src/data/msc.cpp 2008-11-29 11:22:31 UTC (rev 124)
+++ trunk/src/data/msc.cpp 2008-11-29 21:18:12 UTC (rev 125)
@@ -34,6 +34,18 @@
n->get_predecessor()->m_successors.erase(n);
}
+void SuccessorNode::remove_predecessors()
+{
+ NodeRelationPtrSet::iterator i;
+ for(i=m_predecessors.begin();i!=m_predecessors.end();i++)
+ {
+ (*i)->get_predecessor()->remove_successor(*i);
+ }
+ m_predecessors.clear();
+}
+
+////////////////////////////////////////////////////////////////////////////
+
NodeRelationPtr PredecessorNode::add_successor(SuccessorNode* succ)
{
NodeRelationPtr n(new NodeRelation(this,succ));
@@ -48,6 +60,16 @@
n->get_successor()->m_predecessors.erase(n);
}
+void PredecessorNode::remove_successors()
+{
+ NodeRelationPtrSet::iterator i;
+ for(i=m_successors.begin();i!=m_successors.end();i++)
+ {
+ (*i)->get_successor()->remove_predecessor(*i);
+ }
+ m_successors.clear();
+}
+
/////////////////////////////////////////////////////////////////
HMscNode::HMscNode(HMscNode* original):MscElementTmpl<HMscNode>(original),
@@ -72,9 +94,33 @@
node->set_owner(this);
}
-void HMsc::remode_node(HMscNode* node)
+void HMsc::remove_node(HMscNode* node)
{
+ HMscNodePtrSet::iterator i;
+ for(i=m_nodes.begin();i!=m_nodes.end();i++)
+ {
+ if((*i).get()==node)
+ {
+ remove_node(*i);
+ break;
+ }
+ }
}
+
+void HMsc::remove_node(HMscNodePtr node)
+{
+ PredecessorNode* pred = dynamic_cast<PredecessorNode*>(node.get());
+ if(pred)
+ {
+ pred->remove_successors();
+ }
+ SuccessorNode* suc = dynamic_cast<SuccessorNode*>(node.get());
+ if(suc)
+ {
+ suc->remove_predecessors();
+ }
+ m_nodes.erase(node);
+}
////////////////////////////////////
Modified: trunk/src/data/msc.h
===================================================================
--- trunk/src/data/msc.h 2008-11-29 11:22:31 UTC (rev 124)
+++ trunk/src/data/msc.h 2008-11-29 21:18:12 UTC (rev 12...
[truncated message content] |
|
From: <got...@us...> - 2008-12-02 11:21:44
|
Revision: 127
http://scstudio.svn.sourceforge.net/scstudio/?rev=127&view=rev
Author: gotthardp
Date: 2008-12-02 11:21:40 +0000 (Tue, 02 Dec 2008)
Log Message:
-----------
Fixed (all but one) problems detected by gcc 4.3.0. The build is still broken.
Modified Paths:
--------------
trunk/src/check/pseudocode/utils.h
trunk/src/data/msc.cpp
trunk/src/data/msc.h
Modified: trunk/src/check/pseudocode/utils.h
===================================================================
--- trunk/src/check/pseudocode/utils.h 2008-12-01 20:46:33 UTC (rev 126)
+++ trunk/src/check/pseudocode/utils.h 2008-12-02 11:21:40 UTC (rev 127)
@@ -69,7 +69,7 @@
template<class MscElementContainer,class AttributeType>
void remove_attributes(MscElementContainer& container, const std::string& name)
{
- MscElementContainer::const_iterator i;
+ typename MscElementContainer::const_iterator i;
for(i=container.begin();i!=container.end();i++)
{
(*i)->remove_attribute<AttributeType>(name);
Modified: trunk/src/data/msc.cpp
===================================================================
--- trunk/src/data/msc.cpp 2008-12-01 20:46:33 UTC (rev 126)
+++ trunk/src/data/msc.cpp 2008-12-02 11:21:40 UTC (rev 127)
@@ -28,7 +28,7 @@
return n;
}
-void SuccessorNode::remove_predecessor(NodeRelationPtr& n)
+void SuccessorNode::remove_predecessor(const NodeRelationPtr& n)
{
m_predecessors.erase(n);
n->get_predecessor()->m_successors.erase(n);
@@ -54,7 +54,7 @@
return n;
}
-void PredecessorNode::remove_successor(NodeRelationPtr& n)
+void PredecessorNode::remove_successor(const NodeRelationPtr& n)
{
m_successors.erase(n);
n->get_successor()->m_predecessors.erase(n);
Modified: trunk/src/data/msc.h
===================================================================
--- trunk/src/data/msc.h 2008-12-01 20:46:33 UTC (rev 126)
+++ trunk/src/data/msc.h 2008-12-02 11:21:40 UTC (rev 127)
@@ -538,7 +538,7 @@
NodeRelationPtr add_predecessor(PredecessorNode* pred);
- void remove_predecessor(NodeRelationPtr& n);
+ void remove_predecessor(const NodeRelationPtr& n);
void remove_predecessors();
@@ -588,7 +588,7 @@
/**
* Removes successor.
*/
- void remove_successor(NodeRelationPtr& n);
+ void remove_successor(const NodeRelationPtr& n);
void remove_successors();
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <got...@us...> - 2009-01-03 16:36:30
|
Revision: 148
http://scstudio.svn.sourceforge.net/scstudio/?rev=148&view=rev
Author: gotthardp
Date: 2009-01-03 16:36:24 +0000 (Sat, 03 Jan 2009)
Log Message:
-----------
data: Fixed Visual Studio portability.
view/visio: Implemented a "ScrollViewTo bug" feature.
Modified Paths:
--------------
trunk/src/data/Z120/CMakeLists.txt
trunk/src/data/Z120/z120_save.cpp
trunk/src/data/formatter.h
trunk/src/view/visio/addon/document.cpp
Modified: trunk/src/data/Z120/CMakeLists.txt
===================================================================
--- trunk/src/data/Z120/CMakeLists.txt 2009-01-03 16:17:14 UTC (rev 147)
+++ trunk/src/data/Z120/CMakeLists.txt 2009-01-03 16:36:24 UTC (rev 148)
@@ -1,4 +1,5 @@
ADD_LIBRARY(scZ120 SHARED
+ export.h
z120.h
z120_save.cpp
)
@@ -13,10 +14,12 @@
# Z120.cpp
# Z120Lexer.c
# Z120Parser.c)
-#
-#TARGET_LINK_LIBRARIES(parser
-# antlr3c)
+TARGET_LINK_LIBRARIES(scZ120
+ scmsc
+# antlr3c
+)
+
INSTALL(TARGETS scZ120
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib
Modified: trunk/src/data/Z120/z120_save.cpp
===================================================================
--- trunk/src/data/Z120/z120_save.cpp 2009-01-03 16:17:14 UTC (rev 147)
+++ trunk/src/data/Z120/z120_save.cpp 2009-01-03 16:36:24 UTC (rev 148)
@@ -65,7 +65,7 @@
list.push_back(item);
}
-int print_event(std::ostream& stream, PtrIDMap<MscMessagePtr>& message_id_map,
+void print_event(std::ostream& stream, PtrIDMap<MscMessagePtr>& message_id_map,
const EventPtr& event)
{
CompleteMessagePtr complete_message = event->get_complete_message();
Modified: trunk/src/data/formatter.h
===================================================================
--- trunk/src/data/formatter.h 2009-01-03 16:17:14 UTC (rev 147)
+++ trunk/src/data/formatter.h 2009-01-03 16:36:24 UTC (rev 148)
@@ -21,7 +21,9 @@
#include "data/msc.h"
-class SCMSC_EXPORT Formatter
+#pragma warning(disable: 4275)
+
+class Formatter
{
public:
virtual ~Formatter() {}
Modified: trunk/src/view/visio/addon/document.cpp
===================================================================
--- trunk/src/view/visio/addon/document.cpp 2009-01-03 16:17:14 UTC (rev 147)
+++ trunk/src/view/visio/addon/document.cpp 2009-01-03 16:36:24 UTC (rev 148)
@@ -216,6 +216,11 @@
Visio::IVShapePtr firstshape = shapes[0];
Visio::IVPagePtr page = firstshape->ContainingPage;
+ Visio::IVCellPtr locPinX = firstshape->CellsSRC[visSectionObject][visRowXFormOut][visXFormLocPinX];
+ Visio::IVCellPtr locPinY = firstshape->CellsSRC[visSectionObject][visRowXFormOut][visXFormLocPinY];
+ double posx, posy;
+ firstshape->XYToPage(locPinX->ResultIU, locPinY->ResultIU, &posx, &posy);
+
Visio::IVSelectionPtr selection =
page->CreateSelection(Visio::visSelTypeSingle, Visio::visSelModeSkipSuper, (IDispatch *)firstshape);
@@ -229,6 +234,7 @@
}
m_vsoApp->ActiveWindow->Page = (IDispatch *)page;
+ m_vsoApp->ActiveWindow->ScrollViewTo(posx, posy);
m_vsoApp->ActiveWindow->Selection = selection;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ba...@us...> - 2009-01-04 12:42:14
|
Revision: 149
http://scstudio.svn.sourceforge.net/scstudio/?rev=149&view=rev
Author: babicaj
Date: 2009-01-04 12:42:09 +0000 (Sun, 04 Jan 2009)
Log Message:
-----------
Few memory leaks removed
Modified Paths:
--------------
trunk/src/check/liveness/deadlock_checker.cpp
trunk/src/check/liveness/deadlock_checker.h
trunk/src/check/pseudocode/visual_closure_initiator.cpp
trunk/src/check/race/race_checker.cpp
trunk/src/check/race/race_checker.h
trunk/src/data/dfsb_hmsc_traverser.cpp
trunk/src/data/dfsb_hmsc_traverser.h
Modified: trunk/src/check/liveness/deadlock_checker.cpp
===================================================================
--- trunk/src/check/liveness/deadlock_checker.cpp 2009-01-03 16:36:24 UTC (rev 148)
+++ trunk/src/check/liveness/deadlock_checker.cpp 2009-01-04 12:42:09 UTC (rev 149)
@@ -162,7 +162,7 @@
//this will be used do show eventual counterexample
HMscPtr p;
DeadlockListener listener;
- DFSHMscTraverser traverser;
+ DFSBMscGraphTraverser traverser;
traverser.add_white_node_found_listener(&listener);
traverser.add_gray_node_found_listener(&listener);
traverser.add_node_finished_listener(&listener);
Modified: trunk/src/check/liveness/deadlock_checker.h
===================================================================
--- trunk/src/check/liveness/deadlock_checker.h 2009-01-03 16:36:24 UTC (rev 148)
+++ trunk/src/check/liveness/deadlock_checker.h 2009-01-04 12:42:09 UTC (rev 149)
@@ -22,7 +22,7 @@
#include "data/checker.h"
#include "data/msc.h"
-#include "data/dfs_hmsc_traverser.h"
+#include "data/dfs_bmsc_graph_traverser.h"
#include "data/dfsb_hmsc_traverser.h"
#include "check/liveness/export.h"
Modified: trunk/src/check/pseudocode/visual_closure_initiator.cpp
===================================================================
--- trunk/src/check/pseudocode/visual_closure_initiator.cpp 2009-01-03 16:36:24 UTC (rev 148)
+++ trunk/src/check/pseudocode/visual_closure_initiator.cpp 2009-01-04 12:42:09 UTC (rev 149)
@@ -68,7 +68,7 @@
EventPList::iterator e;
for(e=m_modified_events.begin();e!=m_modified_events.end();e++)
{
- (*e)->remove_attribute<size_t>(m_visual_closure_attribute);
+ (*e)->remove_attribute<size_t>(m_topology_index_attribute);
(*e)->remove_attribute<BoolVector>(m_visual_closure_attribute);
}
m_modified_events.erase(m_modified_events.begin(),m_modified_events.end());
Modified: trunk/src/check/race/race_checker.cpp
===================================================================
--- trunk/src/check/race/race_checker.cpp 2009-01-03 16:36:24 UTC (rev 148)
+++ trunk/src/check/race/race_checker.cpp 2009-01-04 12:42:09 UTC (rev 149)
@@ -45,8 +45,14 @@
ExtremeEvents& MinimalEventsInitiator::get_events(BMsc* b)
{
ExtremeEvents extreme(m_instance_marker->get_count());
- m_modified_bmscs.push_back(b);
- return b->get_attribute<ExtremeEvents>(m_events_attribute,extreme);
+
+ bool just_set;
+ ExtremeEvents& e = b->get_attribute<ExtremeEvents>(m_events_attribute,extreme,just_set);
+ if(just_set)
+ {
+ m_modified_bmscs.push_back(b);
+ }
+ return e;
}
void MinimalEventsInitiator::on_white_node_found(ReferenceNode* node)
@@ -119,8 +125,14 @@
ExtremeEvents& MaximalEventsInitiator::get_events_less(BMsc* b)
{
- static ExtremeEvents extreme(m_instance_marker->get_count());
- return b->get_attribute<ExtremeEvents>(m_events_less_attribute,extreme);
+ ExtremeEvents extreme(m_instance_marker->get_count());
+ bool just_set;
+ ExtremeEvents& e = b->get_attribute<ExtremeEvents>(m_events_less_attribute,extreme,just_set);
+ if(just_set)
+ {
+ m_modified_bmscs.push_back(b);
+ }
+ return e;
}
void MaximalEventsInitiator::on_white_node_found(ReferenceNode* node)
Modified: trunk/src/check/race/race_checker.h
===================================================================
--- trunk/src/check/race/race_checker.h 2009-01-03 16:36:24 UTC (rev 148)
+++ trunk/src/check/race/race_checker.h 2009-01-04 12:42:09 UTC (rev 149)
@@ -99,6 +99,7 @@
protected:
std::string m_events_less_attribute;
+
public:
Modified: trunk/src/data/dfsb_hmsc_traverser.cpp
===================================================================
--- trunk/src/data/dfsb_hmsc_traverser.cpp 2009-01-03 16:36:24 UTC (rev 148)
+++ trunk/src/data/dfsb_hmsc_traverser.cpp 2009-01-04 12:42:09 UTC (rev 149)
@@ -125,4 +125,21 @@
set_color(n,BLACK);
}
+Color& DFSBHMscTraverser::get_color(HMscNode* n)
+{
+ bool just_set;
+ Color& c = n->get_attribute<Color>(m_color_attribute,WHITE,just_set);
+ if(just_set)
+ {
+ m_colored_nodes.push_back(n);
+ }
+ return c;
+}
+
+void DFSBHMscTraverser::set_color(HMscNode* n, Color c)
+{
+ Color& col = get_color(n);
+ col = c;
+}
+
// $Id$
Modified: trunk/src/data/dfsb_hmsc_traverser.h
===================================================================
--- trunk/src/data/dfsb_hmsc_traverser.h 2009-01-03 16:36:24 UTC (rev 148)
+++ trunk/src/data/dfsb_hmsc_traverser.h 2009-01-04 12:42:09 UTC (rev 149)
@@ -106,20 +106,14 @@
/**
* Sets color attribute of e to c value .
*/
- void set_color(HMscNode* n, Color c)
- {
- n->set_attribute<Color>(m_color_attribute,c);
- }
+ void set_color(HMscNode* n, Color c);
/**
* Returns value of color attribute.
*
* If attribute isn't set it is set to default value WHITE.
*/
- Color get_color(HMscNode* n)
- {
- return n->get_attribute<Color>(m_color_attribute,WHITE);
- }
+ Color& get_color(HMscNode* n);
void white_node_found(HMscNode* n);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <got...@us...> - 2009-01-04 19:25:37
|
Revision: 151
http://scstudio.svn.sourceforge.net/scstudio/?rev=151&view=rev
Author: gotthardp
Date: 2009-01-04 19:25:27 +0000 (Sun, 04 Jan 2009)
Log Message:
-----------
Checking and formatting modules integrated with Visio.
Modified Paths:
--------------
trunk/src/check/liveness/CMakeLists.txt
trunk/src/check/liveness/deadlock_checker.h
trunk/src/check/liveness/livelock_checker.h
trunk/src/check/order/CMakeLists.txt
trunk/src/check/order/acyclic_checker.h
trunk/src/check/order/fifo_checker.h
trunk/src/check/race/CMakeLists.txt
trunk/src/check/race/race_checker.h
trunk/src/data/Z120/CMakeLists.txt
trunk/src/data/Z120/z120.h
trunk/src/data/Z120/z120_save.cpp
trunk/src/data/checker.h
trunk/src/data/dfs_bmsc_graph_traverser.cpp
trunk/src/data/dfs_bmsc_graph_traverser.h
trunk/src/data/dfs_events_traverser.cpp
trunk/src/data/dfs_events_traverser.h
trunk/src/data/dfs_inner_hmsc_traverser.cpp
trunk/src/data/dfsb_hmsc_traverser.cpp
trunk/src/data/dfsb_hmsc_traverser.h
trunk/src/data/formatter.h
trunk/src/data/msc.h
trunk/src/view/visio/addon/addon.cpp
trunk/src/view/visio/addon/document.cpp
trunk/src/view/visio/addon/document.h
trunk/src/view/visio/addon/extract.cpp
trunk/src/view/visio/addon/reportview.cpp
trunk/src/view/visio/scstudio.nsi
Added Paths:
-----------
trunk/src/check/liveness/module.cpp
trunk/src/check/order/module.cpp
trunk/src/check/race/module.cpp
trunk/src/data/Z120/module.cpp
Modified: trunk/src/check/liveness/CMakeLists.txt
===================================================================
--- trunk/src/check/liveness/CMakeLists.txt 2009-01-04 16:16:42 UTC (rev 150)
+++ trunk/src/check/liveness/CMakeLists.txt 2009-01-04 19:25:27 UTC (rev 151)
@@ -1,4 +1,6 @@
ADD_LIBRARY(scliveness SHARED
+ export.h
+ module.cpp
deadlock_checker.cpp
deadlock_checker.h
livelock_checker.cpp
Modified: trunk/src/check/liveness/deadlock_checker.h
===================================================================
--- trunk/src/check/liveness/deadlock_checker.h 2009-01-04 16:16:42 UTC (rev 150)
+++ trunk/src/check/liveness/deadlock_checker.h 2009-01-04 19:25:27 UTC (rev 151)
@@ -119,13 +119,20 @@
*/
static DeadlockCheckerPtr m_instance;
- DeadlockChecker(){};
-
HMscPtr create_counter_example(const MscElementPListList& path);
public:
+ DeadlockChecker(){};
+
/**
+ * Human readable description of this check.
+ */
+ // note: DLL in Windows cannot return pointers to static data
+ virtual std::string get_description() const
+ { return "Deadlock"; }
+
+ /**
* Checks whether hmsc satisfy deadlock free property.
*/
HMscPtr check(HMscPtr hmsc, ChannelMapperPtr chm);
Modified: trunk/src/check/liveness/livelock_checker.h
===================================================================
--- trunk/src/check/liveness/livelock_checker.h 2009-01-04 16:16:42 UTC (rev 150)
+++ trunk/src/check/liveness/livelock_checker.h 2009-01-04 19:25:27 UTC (rev 151)
@@ -93,7 +93,7 @@
* to maek all nodes on the way backwards reachable ( mark_reachable()).
* Then goes again looking for circle (gray listener) that is not reachable.
*/
-class SCLIVENESS_EXPORT LivelockChecker: public HMscChecker
+class SCLIVENESS_EXPORT LivelockChecker: public Checker, public HMscChecker
{
protected:
/**
@@ -101,11 +101,19 @@
*/
static LivelockCheckerPtr m_instance;
- LivelockChecker();
HMscPtr create_counter_example(const MscElementPListList& path);
public:
+ LivelockChecker();
+
+ /**
+ * Human readable description of this check.
+ */
+ // note: DLL in Windows cannot return pointers to static data
+ virtual std::string get_description() const
+ { return "Livelock"; }
+
static LivelockCheckerPtr instance();
bool is_supported(ChannelMapperPtr chm);
Added: trunk/src/check/liveness/module.cpp
===================================================================
--- trunk/src/check/liveness/module.cpp (rev 0)
+++ trunk/src/check/liveness/module.cpp 2009-01-04 19:25:27 UTC (rev 151)
@@ -0,0 +1,35 @@
+/*
+ * 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 Petr Gotthard <pet...@ce...>
+ *
+ * $Id$
+ */
+
+#include "check/liveness/deadlock_checker.h"
+#include "check/liveness/livelock_checker.h"
+
+// module initialization function
+// note: the Visio add-on searches for a function of this name
+extern "C" SCLIVENESS_EXPORT
+Checker** init_checkers()
+{
+ Checker **result = new Checker* [3];
+ result[0] = new DeadlockChecker();
+ result[1] = new LivelockChecker();
+ result[2] = NULL;
+
+ return result;
+}
+
+// $Id$
Property changes on: trunk/src/check/liveness/module.cpp
___________________________________________________________________
Added: svn:keywords
+ Id
Added: svn:eol-style
+ native
Modified: trunk/src/check/order/CMakeLists.txt
===================================================================
--- trunk/src/check/order/CMakeLists.txt 2009-01-04 16:16:42 UTC (rev 150)
+++ trunk/src/check/order/CMakeLists.txt 2009-01-04 19:25:27 UTC (rev 151)
@@ -1,4 +1,6 @@
ADD_LIBRARY(scorder SHARED
+ export.h
+ module.cpp
acyclic_checker.cpp
acyclic_checker.h
fifo_checker.cpp
Modified: trunk/src/check/order/acyclic_checker.h
===================================================================
--- trunk/src/check/order/acyclic_checker.h 2009-01-04 16:16:42 UTC (rev 150)
+++ trunk/src/check/order/acyclic_checker.h 2009-01-04 19:25:27 UTC (rev 151)
@@ -72,15 +72,22 @@
BMsc* create_counter_example(const EventPList& path);
+public:
+
AcyclicChecker()
{
}
-
-public:
~AcyclicChecker()
{
}
+
+ /**
+ * Human readable description of this check.
+ */
+ // note: DLL in Windows cannot return pointers to static data
+ virtual std::string get_description() const
+ { return "Acyclic"; }
/**
* Checks whether bmsc has acyclic events' dependecy
Modified: trunk/src/check/order/fifo_checker.h
===================================================================
--- trunk/src/check/order/fifo_checker.h 2009-01-04 16:16:42 UTC (rev 150)
+++ trunk/src/check/order/fifo_checker.h 2009-01-04 19:25:27 UTC (rev 151)
@@ -32,7 +32,7 @@
typedef std::stack<Event*> EventPStack;
typedef boost::shared_ptr<FifoChecker> FifoCheckerPtr;
-class SCORDER_EXPORT FifoChecker: public BMscChecker
+class SCORDER_EXPORT FifoChecker: public Checker, public BMscChecker
{
protected:
@@ -63,6 +63,13 @@
}
public:
+
+ /**
+ * Human readable description of this check.
+ */
+ // note: DLL in Windows cannot return pointers to static data
+ virtual std::string get_description() const
+ { return "FIFO"; }
/**
* Name of channel id attribute
Added: trunk/src/check/order/module.cpp
===================================================================
--- trunk/src/check/order/module.cpp (rev 0)
+++ trunk/src/check/order/module.cpp 2009-01-04 19:25:27 UTC (rev 151)
@@ -0,0 +1,35 @@
+/*
+ * 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 Petr Gotthard <pet...@ce...>
+ *
+ * $Id$
+ */
+
+#include "check/order/acyclic_checker.h"
+#include "check/order/fifo_checker.h"
+
+// module initialization function
+// note: the Visio add-on searches for a function of this name
+extern "C" SCORDER_EXPORT
+Checker** init_checkers()
+{
+ Checker **result = new Checker* [3];
+ result[0] = new AcyclicChecker();
+ result[1] = new FifoChecker();
+ result[2] = NULL;
+
+ return result;
+}
+
+// $Id$
Property changes on: trunk/src/check/order/module.cpp
___________________________________________________________________
Added: svn:keywords
+ Id
Added: svn:eol-style
+ native
Modified: trunk/src/check/race/CMakeLists.txt
===================================================================
--- trunk/src/check/race/CMakeLists.txt 2009-01-04 16:16:42 UTC (rev 150)
+++ trunk/src/check/race/CMakeLists.txt 2009-01-04 19:25:27 UTC (rev 151)
@@ -1,4 +1,6 @@
ADD_LIBRARY(scrace SHARED
+ export.h
+ module.cpp
race_checker.cpp
race_checker.h
footprint.cpp
Added: trunk/src/check/race/module.cpp
===================================================================
--- trunk/src/check/race/module.cpp (rev 0)
+++ trunk/src/check/race/module.cpp 2009-01-04 19:25:27 UTC (rev 151)
@@ -0,0 +1,33 @@
+/*
+ * 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 Petr Gotthard <pet...@ce...>
+ *
+ * $Id$
+ */
+
+#include "check/race/race_checker.h"
+
+// module initialization function
+// note: the Visio add-on searches for a function of this name
+extern "C" SCRACE_EXPORT
+Checker** init_checkers()
+{
+ Checker **result = new Checker* [2];
+ result[0] = new RaceChecker();
+ result[1] = NULL;
+
+ return result;
+}
+
+// $Id$
Property changes on: trunk/src/check/race/module.cpp
___________________________________________________________________
Added: svn:keywords
+ Id
Added: svn:eol-style
+ native
Modified: trunk/src/check/race/race_checker.h
===================================================================
--- trunk/src/check/race/race_checker.h 2009-01-04 16:16:42 UTC (rev 150)
+++ trunk/src/check/race/race_checker.h 2009-01-04 19:25:27 UTC (rev 151)
@@ -167,7 +167,7 @@
};
-class SCRACE_EXPORT RaceChecker:public HMscChecker
+class SCRACE_EXPORT RaceChecker: public Checker, public HMscChecker
{
protected:
@@ -217,6 +217,13 @@
public:
RaceChecker();
+
+ /**
+ * Human readable description of this check.
+ */
+ // note: DLL in Windows cannot return pointers to static data
+ virtual std::string get_description() const
+ { return "Race Conditions"; }
BMscPtr check_bmsc(BMscPtr bmsc, ChannelMapperPtr mapper);
@@ -225,7 +232,12 @@
HMscPtr check(HMscPtr hmsc, ChannelMapperPtr mapper);
void cleanup_attributes();
-
+
+ bool is_supported(ChannelMapperPtr chm)
+ {
+ // FIXME: this is a dummy function only; Jindra needs to verify
+ return true;
+ }
};
class RaceInBMscException:public std::exception
Modified: trunk/src/data/Z120/CMakeLists.txt
===================================================================
--- trunk/src/data/Z120/CMakeLists.txt 2009-01-04 16:16:42 UTC (rev 150)
+++ trunk/src/data/Z120/CMakeLists.txt 2009-01-04 19:25:27 UTC (rev 151)
@@ -1,5 +1,6 @@
ADD_LIBRARY(scZ120 SHARED
export.h
+ module.cpp
z120.h
z120_save.cpp
)
Added: trunk/src/data/Z120/module.cpp
===================================================================
--- trunk/src/data/Z120/module.cpp (rev 0)
+++ trunk/src/data/Z120/module.cpp 2009-01-04 19:25:27 UTC (rev 151)
@@ -0,0 +1,33 @@
+/*
+ * 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 Petr Gotthard <pet...@ce...>
+ *
+ * $Id$
+ */
+
+#include "data/Z120/z120.h"
+
+// module initialization function
+// note: the Visio add-on searches for a function of this name
+extern "C" SCZ120_EXPORT
+Formatter** init_formatters()
+{
+ Formatter **result = new Formatter* [2];
+ result[0] = new Z120();
+ result[1] = NULL;
+
+ return result;
+}
+
+// $Id$
Property changes on: trunk/src/data/Z120/module.cpp
___________________________________________________________________
Added: svn:keywords
+ Id
Added: svn:eol-style
+ native
Modified: trunk/src/data/Z120/z120.h
===================================================================
--- trunk/src/data/Z120/z120.h 2009-01-04 16:16:42 UTC (rev 150)
+++ trunk/src/data/Z120/z120.h 2009-01-04 19:25:27 UTC (rev 151)
@@ -25,11 +25,23 @@
class SCZ120_EXPORT Z120 : public Formatter
{
public:
+ //! file extension used to distinguish this format
+ // note: DLL in Windows cannot return pointers to static data
+ virtual std::string get_extension() const
+ { return "msc"; }
+ //! human readable description of this format
+ virtual std::string get_description() const
+ { return "Z.120 Textual Format"; }
+
+ //! import MSC document
virtual MscPtr load_msc(std::istream& stream) { return NULL; } // not implemented yet
+ //! export MSC document
virtual int save_msc(std::ostream& stream, const MscPtr& msc);
protected:
+ //! export a basic MSC drawing
int save_bmsc(std::ostream& stream, const BMscPtr& bmsc);
+ //! export a HMSC drawing
int save_hmsc(std::ostream& stream, const HMscPtr& hmsc);
};
Modified: trunk/src/data/Z120/z120_save.cpp
===================================================================
--- trunk/src/data/Z120/z120_save.cpp 2009-01-04 16:16:42 UTC (rev 150)
+++ trunk/src/data/Z120/z120_save.cpp 2009-01-04 19:25:27 UTC (rev 151)
@@ -138,10 +138,10 @@
// events to be processed; this is to avoid recursion
std::list<CoregionEventPtr> event_stack;
- for(CoregionEventPSet::const_iterator mpos = coregion_area->get_maximal_events().begin();
- mpos != coregion_area->get_maximal_events().end(); mpos++)
+ for(CoregionEventPSet::const_iterator mpos = coregion_area->get_minimal_events().begin();
+ mpos != coregion_area->get_minimal_events().end(); mpos++)
{
- // initialize the stack with maximal events
+ // initialize the stack with events with no predecessors
push_back_if_unique<CoregionEventPtr>(event_stack, *mpos);
}
Modified: trunk/src/data/checker.h
===================================================================
--- trunk/src/data/checker.h 2009-01-04 16:16:42 UTC (rev 150)
+++ trunk/src/data/checker.h 2009-01-04 19:25:27 UTC (rev 151)
@@ -43,6 +43,11 @@
{
public:
+
+ /**
+ * Human readable description of this check.
+ */
+ virtual std::string get_description() const = 0;
/**
* Removes no more needed attributes.
@@ -66,6 +71,9 @@
}
};
+//! module initialization function
+typedef Checker** (*FInitCheckers)();
+
/**
* Basic abstract class for checking algorithms of HMsc.
*/
@@ -358,7 +366,7 @@
template <class T>
boost::shared_ptr<GeneralMapper<T> > GeneralMapper<T>::m_instance;
-enum Color
+enum NodeColor
{
WHITE,
GRAY,
Modified: trunk/src/data/dfs_bmsc_graph_traverser.cpp
===================================================================
--- trunk/src/data/dfs_bmsc_graph_traverser.cpp 2009-01-04 16:16:42 UTC (rev 150)
+++ trunk/src/data/dfs_bmsc_graph_traverser.cpp 2009-01-04 19:25:27 UTC (rev 151)
@@ -146,7 +146,7 @@
bool DFSBMscGraphTraverser::is_processed(HMscNode* node)
{
- Color c = get_color(node);
+ NodeColor c = get_color(node);
if(c==BLACK)
{
black_node_found(node);
@@ -198,7 +198,7 @@
HMscNodePList& top = m_colored_nodes.back();
HMscNodePList::iterator event;
for(event=top.begin();event!=top.end();event++)
- (*event)->remove_attribute<Color>(m_color_attribute);
+ (*event)->remove_attribute<NodeColor>(m_color_attribute);
m_colored_nodes.pop_back();
m_reached_elements.pop_back();
}
@@ -209,10 +209,10 @@
m_reached_elements.push_back(MscElementPList());
}
-Color& DFSBMscGraphTraverser::get_color(HMscNode* n)
+NodeColor& DFSBMscGraphTraverser::get_color(HMscNode* n)
{
bool just_set;
- Color& c = n->get_attribute<Color>(m_color_attribute,WHITE,just_set);
+ NodeColor& c = n->get_attribute<NodeColor>(m_color_attribute,WHITE,just_set);
if(just_set)
{
m_colored_nodes.back().push_back(n);
@@ -220,9 +220,9 @@
return c;
}
-void DFSBMscGraphTraverser::set_color(HMscNode* n, Color c)
+void DFSBMscGraphTraverser::set_color(HMscNode* n, NodeColor c)
{
- Color& col = get_color(n);
+ NodeColor& col = get_color(n);
col = c;
}
Modified: trunk/src/data/dfs_bmsc_graph_traverser.h
===================================================================
--- trunk/src/data/dfs_bmsc_graph_traverser.h 2009-01-04 16:16:42 UTC (rev 150)
+++ trunk/src/data/dfs_bmsc_graph_traverser.h 2009-01-04 19:25:27 UTC (rev 151)
@@ -425,14 +425,14 @@
/**
* Sets color attribute of e to c value .
*/
- void set_color(HMscNode* n, Color c);
+ void set_color(HMscNode* n, NodeColor c);
/**
* Returns value of color attribute.
*
* If attribute isn't set it is set to default value WHITE.
*/
- Color& get_color(HMscNode* n);
+ NodeColor& get_color(HMscNode* n);
virtual void push_top_attributes();
Modified: trunk/src/data/dfs_events_traverser.cpp
===================================================================
--- trunk/src/data/dfs_events_traverser.cpp 2009-01-04 16:16:42 UTC (rev 150)
+++ trunk/src/data/dfs_events_traverser.cpp 2009-01-04 19:25:27 UTC (rev 151)
@@ -125,7 +125,7 @@
bool DFSEventsTraverser::is_processed(Event* event)
{
- Color c = get_color(event);
+ NodeColor c = get_color(event);
if(c==BLACK)
{
black_event_found(event);
@@ -144,7 +144,7 @@
{
EventPList::iterator event;
for(event=m_colored_events.begin();event!=m_colored_events.end();event++)
- (*event)->remove_attribute<Color>(m_color);
+ (*event)->remove_attribute<NodeColor>(m_color);
m_colored_events.clear();
}
@@ -192,9 +192,9 @@
return topology;
}
-Color DFSEventsTraverser::get_color(Event* e)
+NodeColor DFSEventsTraverser::get_color(Event* e)
{
- return e->get_attribute<Color>(m_color,WHITE);
+ return e->get_attribute<NodeColor>(m_color,WHITE);
}
void DFSEventsTraverser::remove_white_event_found_listeners()
Modified: trunk/src/data/dfs_events_traverser.h
===================================================================
--- trunk/src/data/dfs_events_traverser.h 2009-01-04 16:16:42 UTC (rev 150)
+++ trunk/src/data/dfs_events_traverser.h 2009-01-04 19:25:27 UTC (rev 151)
@@ -241,9 +241,9 @@
/**
* Sets color attribute of e to c value .
*/
- void set_color(Event* e, Color c)
+ void set_color(Event* e, NodeColor c)
{
- e->set_attribute<Color>(m_color,c);
+ e->set_attribute<NodeColor>(m_color,c);
}
/**
@@ -251,7 +251,7 @@
*
* If attribute isn't set it is set to default value WHITE.
*/
- Color get_color(Event* e);
+ NodeColor get_color(Event* e);
};
Modified: trunk/src/data/dfs_inner_hmsc_traverser.cpp
===================================================================
--- trunk/src/data/dfs_inner_hmsc_traverser.cpp 2009-01-04 16:16:42 UTC (rev 150)
+++ trunk/src/data/dfs_inner_hmsc_traverser.cpp 2009-01-04 19:25:27 UTC (rev 151)
@@ -20,7 +20,7 @@
bool DFSInnerHMscTraverser::traverse_node(InnerNode* node)
{
- Color c = get_color(node);
+ NodeColor c = get_color(node);
if(c==BLACK)
{
black_node_found(node);
Modified: trunk/src/data/dfsb_hmsc_traverser.cpp
===================================================================
--- trunk/src/data/dfsb_hmsc_traverser.cpp 2009-01-04 16:16:42 UTC (rev 150)
+++ trunk/src/data/dfsb_hmsc_traverser.cpp 2009-01-04 19:25:27 UTC (rev 151)
@@ -77,7 +77,7 @@
bool DFSBHMscTraverser::is_processed(HMscNode* node)
{
- Color c = get_color(node);
+ NodeColor c = get_color(node);
if(c==BLACK)
{
black_node_found(node);
@@ -95,7 +95,7 @@
{
HMscNodePList::const_iterator n;
for(n=m_colored_nodes.begin();n!=m_colored_nodes.end();n++)
- (*n)->remove_attribute<Color>(m_color_attribute);
+ (*n)->remove_attribute<NodeColor>(m_color_attribute);
m_colored_nodes.erase(m_colored_nodes.begin(),m_colored_nodes.end());
m_reached_elements.erase(m_reached_elements.begin(),m_reached_elements.end());
}
@@ -125,10 +125,10 @@
set_color(n,BLACK);
}
-Color& DFSBHMscTraverser::get_color(HMscNode* n)
+NodeColor& DFSBHMscTraverser::get_color(HMscNode* n)
{
bool just_set;
- Color& c = n->get_attribute<Color>(m_color_attribute,WHITE,just_set);
+ NodeColor& c = n->get_attribute<NodeColor>(m_color_attribute,WHITE,just_set);
if(just_set)
{
m_colored_nodes.push_back(n);
@@ -136,9 +136,9 @@
return c;
}
-void DFSBHMscTraverser::set_color(HMscNode* n, Color c)
+void DFSBHMscTraverser::set_color(HMscNode* n, NodeColor c)
{
- Color& col = get_color(n);
+ NodeColor& col = get_color(n);
col = c;
}
Modified: trunk/src/data/dfsb_hmsc_traverser.h
===================================================================
--- trunk/src/data/dfsb_hmsc_traverser.h 2009-01-04 16:16:42 UTC (rev 150)
+++ trunk/src/data/dfsb_hmsc_traverser.h 2009-01-04 19:25:27 UTC (rev 151)
@@ -106,14 +106,14 @@
/**
* Sets color attribute of e to c value .
*/
- void set_color(HMscNode* n, Color c);
+ void set_color(HMscNode* n, NodeColor c);
/**
* Returns value of color attribute.
*
* If attribute isn't set it is set to default value WHITE.
*/
- Color& get_color(HMscNode* n);
+ NodeColor& get_color(HMscNode* n);
void white_node_found(HMscNode* n);
Modified: trunk/src/data/formatter.h
===================================================================
--- trunk/src/data/formatter.h 2009-01-04 16:16:42 UTC (rev 150)
+++ trunk/src/data/formatter.h 2009-01-04 19:25:27 UTC (rev 151)
@@ -19,19 +19,38 @@
#ifndef _FORMATTER_H
#define _FORMATTER_H
+#include <boost/shared_ptr.hpp>
+
#include "data/msc.h"
+#if defined(_MSC_VER)
+// FIXME: to be removed once the Formatter has some implementation in a .cpp file
#pragma warning(disable: 4275)
+#endif
+class Formatter;
+
+typedef boost::shared_ptr<Formatter> FormatterPtr;
+
class Formatter
{
public:
virtual ~Formatter() {}
+ //! file extension used to distinguish this format
+ virtual std::string get_extension() const = 0;
+ //! human readable description of the format
+ virtual std::string get_description() const = 0;
+
+ //! import MSC document
virtual MscPtr load_msc(std::istream& stream) = 0;
+ //! export MSC document
virtual int save_msc(std::ostream& stream, const MscPtr& msc) = 0;
};
+//! module initialization function
+typedef Formatter** (*FInitFormatters)();
+
#endif /* _FORMATTER_H */
// $Id$
Modified: trunk/src/data/msc.h
===================================================================
--- trunk/src/data/msc.h 2009-01-04 16:16:42 UTC (rev 150)
+++ trunk/src/data/msc.h 2009-01-04 19:25:27 UTC (rev 151)
@@ -1932,7 +1932,13 @@
e = new CoregionEvent();
m_events.insert(e);
- add_maximal_event(e.get());
+
+ if(e->is_minimal())
+ add_minimal_event(e.get());
+
+ if(e->is_maximal())
+ add_maximal_event(e.get());
+
e->set_area(this);
return e;
}
Modified: trunk/src/view/visio/addon/addon.cpp
===================================================================
--- trunk/src/view/visio/addon/addon.cpp 2009-01-04 16:16:42 UTC (rev 150)
+++ trunk/src/view/visio/addon/addon.cpp 2009-01-04 19:25:27 UTC (rev 151)
@@ -254,11 +254,14 @@
return VAORC_SUCCESS;
case 201:
+ TRACE("CStudioAddon::Run() menu item 'Check--Windows--Verification Report'");
+ return pDocumentMonitor->OnMenuWindowsReporter(vsoApp);
+ case 202:
TRACE("CStudioAddon::Run() menu item 'Check--Run'");
return pDocumentMonitor->OnMenuRun(vsoApp);
- case 202:
- TRACE("CStudioAddon::Run() menu item 'Check--Windows--Verification Report'");
- return pDocumentMonitor->OnMenuWindowsReporter(vsoApp);
+ case 203:
+ TRACE("CStudioAddon::Run() menu item 'Check--Export Drawing'");
+ return pDocumentMonitor->OnMenuExport(vsoApp);
default:
TRACE("CStudioAddon::Run() unexpected event id=" << iEvent);
Modified: trunk/src/view/visio/addon/document.cpp
===================================================================
--- trunk/src/view/visio/addon/document.cpp 2009-01-04 16:16:42 UTC (rev 150)
+++ trunk/src/view/visio/addon/document.cpp 2009-01-04 19:25:27 UTC (rev 151)
@@ -22,9 +22,14 @@
#include "document.h"
#include "errors.h"
#include "extract.h"
+#include <fstream>
#include "data/msc.h"
+// Include libraries from the Windows Template Library (WTL).
+// http://wtl.sourceforge.net
+#include <atldlgs.h>
+
CDocumentMonitor::CDocumentMonitor(CStudioAddon *addon,
Visio::IVApplicationPtr vsoApp, Visio::IVDocumentPtr vsoDocument)
{
@@ -34,10 +39,24 @@
m_reportVisible = false;
m_reportView = NULL;
+
+ static const LPCTSTR keyName = _T("Software\\Sequence Chart Studio\\Modules");
+ LoadModulesFromRegistry(HKEY_LOCAL_MACHINE, keyName);
+ LoadModulesFromRegistry(HKEY_CURRENT_USER, keyName);
}
CDocumentMonitor::~CDocumentMonitor()
{
+ // terminate all module functions
+ m_formatters.clear();
+ m_checkers.clear();
+ // close extension modules
+ for(std::vector<HINSTANCE>::const_iterator mpos = m_open_modules.begin();
+ mpos != m_open_modules.end(); mpos++)
+ {
+ FreeLibrary(*mpos);
+ }
+
if (m_vsoBeforeDocumentClosedEvent != NULL)
m_vsoBeforeDocumentClosedEvent->Delete();
@@ -45,6 +64,113 @@
m_vsoPageAddedEvent->Delete();
}
+int CDocumentMonitor::LoadModulesFromRegistry(HKEY hKey, LPCTSTR lpSubKey)
+{
+ HKEY hSubKey;
+ if(RegOpenKeyEx(hKey, lpSubKey, 0, KEY_READ, &hSubKey) != ERROR_SUCCESS)
+ {
+ return 1;
+ }
+
+ TCHAR achClass[MAX_PATH]; // buffer for class name
+ DWORD cchClassName = MAX_PATH; // size of class string
+ DWORD cSubKeys; // number of subkeys
+ DWORD cbMaxSubKey; // longest subkey size
+ DWORD cchMaxClass; // longest class string
+ DWORD cValues; // number of values for key
+ DWORD cchMaxValue; // longest value name
+ DWORD cbMaxValueData; // longest value data
+ DWORD cbSecurityDescriptor; // size of security descriptor
+ FILETIME ftLastWriteTime; // last write time
+
+ // get the class name and the value count
+ if(RegQueryInfoKey(hSubKey,
+ achClass, // buffer for class name
+ &cchClassName, // size of class string
+ NULL, // reserved
+ &cSubKeys, // number of subkeys
+ &cbMaxSubKey, // longest subkey size
+ &cchMaxClass, // longest class string
+ &cValues, // number of values for this key
+ &cchMaxValue, // longest value name
+ &cbMaxValueData, // longest value data
+ &cbSecurityDescriptor,
+ &ftLastWriteTime) != ERROR_SUCCESS)
+ {
+ return 1;
+ }
+
+ TCHAR *valName = new TCHAR[cchMaxValue];
+ DWORD valNameLength;
+ DWORD dwType;
+ TCHAR *valData = new TCHAR[cbMaxValueData];
+ DWORD valDataLength;
+
+ for(DWORD i = 0; i < cValues; i++)
+ {
+ valNameLength = cchMaxValue;
+ valDataLength = cbMaxValueData;
+
+ if(RegEnumValue(hSubKey, i,
+ valName,
+ &valNameLength,
+ NULL,
+ &dwType,
+ (LPBYTE)valData,
+ &valDataLength) == ERROR_SUCCESS)
+ {
+ // open the extension module
+ HINSTANCE module = LoadLibrary(valData);
+ if(module == NULL)
+ continue;
+
+ FInitFormatters init_formatters = (FInitFormatters)GetProcAddress(module, "init_formatters");
+ FInitCheckers init_checkers = (FInitCheckers)GetProcAddress(module, "init_checkers");
+ if(init_formatters == NULL && init_checkers == NULL)
+ {
+ // this is not our module
+ FreeLibrary(module);
+ }
+
+ if(init_formatters != NULL)
+ {
+ Formatter **formatters = init_formatters();
+ // append new formatters to the list
+ for(Formatter **fpos = formatters; *fpos != NULL; fpos++)
+ {
+ boost::shared_ptr<Formatter> formatter(*fpos);
+ m_formatters.push_back(formatter);
+ }
+ // delete the array
+ // note: the formatters are managed by the boost:shared_ptr
+ delete[] formatters;
+ }
+
+ if(init_checkers != NULL)
+ {
+ Checker **checkers = init_checkers();
+ // append new checkers to the list
+ for(Checker **fpos = checkers; *fpos != NULL; fpos++)
+ {
+ boost::shared_ptr<Checker> checker(*fpos);
+ m_checkers.push_back(checker);
+ }
+ // delete the array
+ // note: the checkers are managed by the boost:shared_ptr
+ delete[] checkers;
+ }
+
+ // keep the pointer to properly unl...
[truncated message content] |
|
From: <ba...@us...> - 2009-01-11 14:50:20
|
Revision: 162
http://scstudio.svn.sourceforge.net/scstudio/?rev=162&view=rev
Author: babicaj
Date: 2009-01-11 14:50:15 +0000 (Sun, 11 Jan 2009)
Log Message:
-----------
fifo checker and acyclic checker return proper counter examples with visual information
Modified Paths:
--------------
trunk/src/check/order/acyclic_checker.cpp
trunk/src/check/order/acyclic_checker.h
trunk/src/check/order/fifo_checker.cpp
trunk/src/check/order/fifo_checker.h
trunk/src/check/pseudocode/msc_duplicators.cpp
trunk/src/check/pseudocode/msc_duplicators.h
trunk/src/data/msc.cpp
trunk/src/data/msc.h
Modified: trunk/src/check/order/acyclic_checker.cpp
===================================================================
--- trunk/src/check/order/acyclic_checker.cpp 2009-01-11 13:18:25 UTC (rev 161)
+++ trunk/src/check/order/acyclic_checker.cpp 2009-01-11 14:50:15 UTC (rev 162)
@@ -17,14 +17,27 @@
*/
#include "check/order/acyclic_checker.h"
+#include "check/pseudocode/msc_duplicators.h"
AcyclicCheckerPtr AcyclicChecker::m_instance;
-BMsc* AcyclicChecker::create_counter_example(const EventPList& path)
+BMscPtr AcyclicChecker::create_counter_example(BMscPtr& bmsc, const EventPList& path)
{
- BMsc* bmsc = new BMsc(path.front()->get_instance()->get_bmsc());
- //TODO: construction of counter example
- return bmsc;
+ Event* last_event = path.back();
+ BMscDuplicator duplicator;
+ BMscPtr new_bmsc = duplicator.duplicate_bmsc(bmsc);
+ EventPList::const_iterator i = path.begin();
+ while(*i != last_event)
+ {
+ i++;
+ }
+ while(i != path.end())
+ {
+ Event* copy = duplicator.get_copy((*i));
+ copy->set_marked(true);
+ i++;
+ }
+ return new_bmsc;
}
BMscPtr AcyclicChecker::check(BMscPtr bmsc, ChannelMapperPtr chm)
@@ -41,7 +54,7 @@
}
catch(CycleDetectedException& cde)
{
- result = create_counter_example(listener.get_path());
+ result = create_counter_example(bmsc,listener.get_path());
traverser.cleanup_traversing_attributes();
}
return result;
Modified: trunk/src/check/order/acyclic_checker.h
===================================================================
--- trunk/src/check/order/acyclic_checker.h 2009-01-11 13:18:25 UTC (rev 161)
+++ trunk/src/check/order/acyclic_checker.h 2009-01-11 14:50:15 UTC (rev 162)
@@ -70,7 +70,7 @@
*/
static AcyclicCheckerPtr m_instance;
- BMsc* create_counter_example(const EventPList& path);
+ BMscPtr create_counter_example(BMscPtr& original, const EventPList& path);
public:
Modified: trunk/src/check/order/fifo_checker.cpp
===================================================================
--- trunk/src/check/order/fifo_checker.cpp 2009-01-11 13:18:25 UTC (rev 161)
+++ trunk/src/check/order/fifo_checker.cpp 2009-01-11 14:50:15 UTC (rev 162)
@@ -18,33 +18,31 @@
#include "check/order/fifo_checker.h"
#include "check/pseudocode/visual_closure_initiator.h"
+#include "check/pseudocode/msc_duplicators.h"
const std::string FifoChecker::channel_id_attribute = "fifo_channel_id";
FifoCheckerPtr FifoChecker::m_instance;
-BMsc* FifoChecker::create_counter_example(Event* receive_1, Event* receive_2)
+BMscPtr FifoChecker::create_counter_example(BMscPtr& bmsc, Event* e_1, Event* e_2)
{
- BMsc* bmsc = new BMsc(receive_1->get_instance()->get_bmsc());
-/* InstancePtr send_instance(new Instance(bmsc,receive_1->get_matching_event()->get_instance()));
- InstancePtr receive_instance(new Instance(bmsc,receive_1->get_instance()));
- bmsc->add_instance(send_instance);
- bmsc->add_instance(receive_instance);
- StrictOrderAreaPtr send_area(new StrictOrderArea(send_instance.get()));
- StrictOrderAreaPtr receive_area(new StrictOrderArea(receive_instance.get()));
- send_instance->set_first(send_area);
- receive_instance->set_first(receive_area);
- MscMessagePtr message1(new MscMessage(send_instance.get(),receive_instance.get(),
- receive_1->get_message().get()));
- MscMessagePtr message2(new MscMessage(send_instance.get(),receive_instance.get(),
- receive_2->get_message().get()));
- StrictEventPtr send1(new StrictEvent(send_area.get(),message1,receive_1->get_matching_event()));
- StrictEventPtr receive1(new StrictEvent(receive_area.get(),send1.get(),receive_1));
- StrictEventPtr send2(new StrictEvent(send_area.get(),message2,receive_2->get_matching_event()));
- StrictEventPtr receive2(new StrictEvent(receive_area.get(),send2.get(),receive_2));
- send_area->set_first(send1);
- send1->set_successor(send2);
- send_area->set_first(receive2);
- receive2->set_successor(receive1);*/
+ BMscDuplicator duplicator;
+ BMscPtr new_bmsc = duplicator.duplicate_bmsc(bmsc);
+ Event* events[] = {e_1,e_2};
+ for(size_t i=0;i<2;i++)
+ {
+ //event is surely complete
+ Event* copy = duplicator.get_copy(events[i]);
+ copy->set_marked(true);
+ copy->get_complete_message()->set_marked(true);
+ if(copy->is_send())
+ {
+ copy->get_complete_message()->get_receive_event()->set_marked(true);
+ }
+ else
+ {
+ copy->get_complete_message()->get_send_event()->set_marked(true);
+ }
+ }
return bmsc;
}
@@ -74,7 +72,7 @@
!closure_initiator.get_visual_closure(topology[e]->get_matching_event())[
closure_initiator.get_topology_index(topology[f]->get_matching_event())])
{
- result = create_counter_example(topology[e],topology[f]);
+ result = create_counter_example(bmsc,topology[e],topology[f]);
cleanup_attributes();
return result;
}
Modified: trunk/src/check/order/fifo_checker.h
===================================================================
--- trunk/src/check/order/fifo_checker.h 2009-01-11 13:18:25 UTC (rev 161)
+++ trunk/src/check/order/fifo_checker.h 2009-01-11 14:50:15 UTC (rev 162)
@@ -47,7 +47,7 @@
*/
EventPStack m_modified_events;
- BMsc* create_counter_example(Event* receive1, Event* receive2);
+ BMscPtr create_counter_example(BMscPtr& bmsc, Event* receive1, Event* receive2);
/**
* Checks whether e1 and e2 (from equivalent channel) are in consistent order.
Modified: trunk/src/check/pseudocode/msc_duplicators.cpp
===================================================================
--- trunk/src/check/pseudocode/msc_duplicators.cpp 2009-01-11 13:18:25 UTC (rev 161)
+++ trunk/src/check/pseudocode/msc_duplicators.cpp 2009-01-11 14:50:15 UTC (rev 162)
@@ -104,20 +104,32 @@
EventAreaPtr area;
if(strict)
{
- area = new StrictOrderArea(strict);
+ StrictOrderArea* new_area = new StrictOrderArea(strict);
+ area = new_area;
}
else
{
- area = new CoregionArea(dynamic_cast<CoregionArea*>(e->get_general_area()));
+ CoregionArea* new_area = new CoregionArea(dynamic_cast<CoregionArea*>(e->get_general_area()));
+ area = new_area;
}
m_last_new_area = area.get();
m_last_new_instance->add_area(area);
m_last_area = e->get_general_area();
}
- EventPtr new_event = m_last_new_area->add_event();
- new_event->set_original(e);
Event*& copy = m_duplicator->get_copy(e);
- copy = new_event.get();
+ CoregionEvent* coreg_event = dynamic_cast<CoregionEvent*>(e);
+ if(coreg_event)
+ {
+ CoregionEvent* new_e = new CoregionEvent(e);
+ copy = new_e;
+ dynamic_cast<CoregionArea*>(m_last_new_area)->add_event(new_e);
+ }
+ else
+ {
+ StrictEvent* new_e = new StrictEvent(e);
+ copy = new_e;
+ dynamic_cast<StrictOrderArea*>(m_last_new_area)->add_event(new_e);
+ }
create_successor(e);
}
Modified: trunk/src/check/pseudocode/msc_duplicators.h
===================================================================
--- trunk/src/check/pseudocode/msc_duplicators.h 2009-01-11 13:18:25 UTC (rev 161)
+++ trunk/src/check/pseudocode/msc_duplicators.h 2009-01-11 14:50:15 UTC (rev 162)
@@ -89,11 +89,11 @@
EventPList m_modified_elements;
- BMscPtr duplicate_bmsc(BMscPtr& bmsc);
+public:
BMscDuplicator();
-public:
+ BMscPtr duplicate_bmsc(BMscPtr& bmsc);
static BMscPtr duplicate(BMscPtr& bmsc);
Modified: trunk/src/data/msc.cpp
===================================================================
--- trunk/src/data/msc.cpp 2009-01-11 13:18:25 UTC (rev 161)
+++ trunk/src/data/msc.cpp 2009-01-11 14:50:15 UTC (rev 162)
@@ -238,7 +238,11 @@
Instance::Instance(Instance* original):MscElementTmpl<Instance>(original)
{
-
+ m_label = original->get_label();
+ m_kind = original->get_label();
+ m_form = original->get_form();
+ m_height = original->get_height();
+ m_width = original->get_width();
}
/////////////////////////////////////////////////////////////////////////////
Modified: trunk/src/data/msc.h
===================================================================
--- trunk/src/data/msc.h 2009-01-11 13:18:25 UTC (rev 161)
+++ trunk/src/data/msc.h 2009-01-11 14:50:15 UTC (rev 162)
@@ -914,6 +914,11 @@
}
+ InstanceAxisForm get_form()
+ {
+ return m_form;
+ }
+
/**
* Set the first EventArea
*/
@@ -974,6 +979,16 @@
m_height = height;
}
+ Size get_width() const
+ {
+ return m_width;
+ }
+
+ void set_width(const Size& width)
+ {
+ m_width = width;
+ }
+
void add_area(EventAreaPtr area);
bool is_empty()
@@ -1196,6 +1211,10 @@
Event(Event* original=NULL)
:MscElementTmpl<Event>(original)
{
+ if(original)
+ {
+ m_y = original->get_y();
+ }
}
CompleteMessage* get_complete() const
@@ -1343,6 +1362,11 @@
}
}
}
+
+ Coordinate get_y()
+ {
+ return m_y;
+ }
};
@@ -1635,11 +1659,15 @@
Instance* m_instance;
/**
- * @param instance - Instance which this EventArea will occure at
+ *
*/
EventArea(EventArea* original):MscElementTmpl<EventArea>(original),
m_previous(NULL),m_instance(NULL),m_next()
{
+ if(original)
+ {
+ m_height = original->get_height();
+ }
}
public:
@@ -1851,7 +1879,10 @@
*/
CoregionArea(CoregionArea* original=NULL):EventArea(original)
{
-
+ if(original)
+ {
+ m_form = original->get_form();
+ }
}
/**
@@ -1942,6 +1973,11 @@
e->set_area(this);
return e;
}
+
+ InstanceAxisForm get_form()
+ {
+ return m_form;
+ }
};
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <got...@us...> - 2009-01-11 15:30:23
|
Revision: 163
http://scstudio.svn.sourceforge.net/scstudio/?rev=163&view=rev
Author: gotthardp
Date: 2009-01-11 15:30:16 +0000 (Sun, 11 Jan 2009)
Log Message:
-----------
Fixed bug in livelock_checker.cpp (reference to local variable) made in previous commit.
Added better About dialog.
Revised Formatter interface; it's now split to ExportFormatter and ImportFormatter.
The Z.120 export is now more standard compliant.
Removed unnecessary data from MSC document template.
Modified Paths:
--------------
trunk/src/check/liveness/livelock_checker.cpp
trunk/src/data/CMakeLists.txt
trunk/src/data/Z120/CMakeLists.txt
trunk/src/data/Z120/z120.h
trunk/src/data/Z120/z120_save.cpp
trunk/src/data/formatter.h
trunk/src/view/visio/addon/addon.cpp
trunk/src/view/visio/addon/dllmodule.rc
trunk/src/view/visio/addon/document.cpp
trunk/src/view/visio/addon/document.h
trunk/src/view/visio/addon/resource.h
trunk/src/view/visio/addon/scstudio.vcproj
trunk/src/view/visio/stencils/Sequence Chart Studio/MSC.vtx
Added Paths:
-----------
trunk/src/view/visio/addon/aboutdlg.h
Property Changed:
----------------
trunk/src/view/visio/addon/dllmodule.rc
Modified: trunk/src/check/liveness/livelock_checker.cpp
===================================================================
--- trunk/src/check/liveness/livelock_checker.cpp 2009-01-11 14:50:15 UTC (rev 162)
+++ trunk/src/check/liveness/livelock_checker.cpp 2009-01-11 15:30:16 UTC (rev 163)
@@ -78,7 +78,7 @@
bool& LivelockListener::get_reachable(HMscNode* node)
{
bool just_set;
- bool reachable = node->get_attribute<bool>(ATTRIBUTE_REACHABLE,false,just_set);
+ bool& reachable = node->get_attribute<bool>(ATTRIBUTE_REACHABLE,false,just_set);
if(just_set)
{
m_marked_elements.push_back(node);
Modified: trunk/src/data/CMakeLists.txt
===================================================================
--- trunk/src/data/CMakeLists.txt 2009-01-11 14:50:15 UTC (rev 162)
+++ trunk/src/data/CMakeLists.txt 2009-01-11 15:30:16 UTC (rev 163)
@@ -23,6 +23,7 @@
dfs_bmsc_graph_traverser.h
)
+# build import-export formatters
ADD_SUBDIRECTORY(Z120)
INSTALL(FILES
Modified: trunk/src/data/Z120/CMakeLists.txt
===================================================================
--- trunk/src/data/Z120/CMakeLists.txt 2009-01-11 14:50:15 UTC (rev 162)
+++ trunk/src/data/Z120/CMakeLists.txt 2009-01-11 15:30:16 UTC (rev 163)
@@ -5,6 +5,7 @@
z120_save.cpp
)
+FIND_PACKAGE(Java)
FIND_PACKAGE(ANTLR)
# do not make antlr a mandatory prerequisite
IF(ANTLR_FOUND)
@@ -12,7 +13,7 @@
ADD_CUSTOM_COMMAND(
OUTPUT Z120Lexer.c Z120Lexer.h Z120Parser.c Z120Parser.h
- COMMAND java org.antlr.Tool Z120.g
+ COMMAND ${JAVA_RUNTIME} org.antlr.Tool Z120.g
DEPENDS Z120.g)
ADD_EXECUTABLE(parser
Modified: trunk/src/data/Z120/z120.h
===================================================================
--- trunk/src/data/Z120/z120.h 2009-01-11 14:50:15 UTC (rev 162)
+++ trunk/src/data/Z120/z120.h 2009-01-11 15:30:16 UTC (rev 163)
@@ -22,21 +22,19 @@
#include "data/formatter.h"
#include "data/Z120/export.h"
-class SCZ120_EXPORT Z120 : public Formatter
+class SCZ120_EXPORT Z120 : public Formatter, public ExportFormatter
{
public:
//! file extension used to distinguish this format
// note: DLL in Windows cannot return pointers to static data
virtual std::string get_extension() const
- { return "msc"; }
+ { return "mpr"; }
//! human readable description of this format
virtual std::string get_description() const
{ return "Z.120 Textual Format"; }
- //! import MSC document
- virtual MscPtr load_msc(std::istream& stream) { return NULL; } // not implemented yet
//! export MSC document
- virtual int save_msc(std::ostream& stream, const MscPtr& msc);
+ virtual int save_msc(std::ostream& stream, const std::string &name, const std::vector<MscPtr>& msc);
protected:
//! export a basic MSC drawing
Modified: trunk/src/data/Z120/z120_save.cpp
===================================================================
--- trunk/src/data/Z120/z120_save.cpp 2009-01-11 14:50:15 UTC (rev 162)
+++ trunk/src/data/Z120/z120_save.cpp 2009-01-11 15:30:16 UTC (rev 163)
@@ -17,23 +17,36 @@
*/
#include <algorithm>
+#include <vector>
#include <list>
#include <map>
#include <ostream>
#include "data/Z120/z120.h"
-int Z120::save_msc(std::ostream& stream, const MscPtr& msc)
+int Z120::save_msc(std::ostream& stream, const std::string &name, const std::vector<MscPtr>& msc)
{
- BMscPtr bmsc = boost::dynamic_pointer_cast<BMsc>(msc);
- if(bmsc != NULL)
- return save_bmsc(stream, bmsc);
+ int result = 0; // error count
+ stream << "mscdocument " << name << ";" << std::endl;
- HMscPtr hmsc = boost::dynamic_pointer_cast<HMsc>(msc);
- if(hmsc != NULL)
- return save_hmsc(stream, hmsc);
+ for(std::vector<MscPtr>::const_iterator pos = msc.begin();
+ pos != msc.end(); pos++)
+ {
+ BMscPtr bmsc = boost::dynamic_pointer_cast<BMsc>(*pos);
+ HMscPtr hmsc = boost::dynamic_pointer_cast<HMsc>(*pos);
- return 1;
+ if(bmsc != NULL)
+ result += save_bmsc(stream, bmsc);
+ else if(hmsc != NULL)
+ result += save_hmsc(stream, hmsc);
+ else
+ {
+ // unexpected pointer
+ result++;
+ }
+ }
+
+ return 0;
}
template <class Ptr>
Modified: trunk/src/data/formatter.h
===================================================================
--- trunk/src/data/formatter.h 2009-01-11 14:50:15 UTC (rev 162)
+++ trunk/src/data/formatter.h 2009-01-11 15:30:16 UTC (rev 163)
@@ -28,10 +28,6 @@
#pragma warning(disable: 4275)
#endif
-class Formatter;
-
-typedef boost::shared_ptr<Formatter> FormatterPtr;
-
class Formatter
{
public:
@@ -41,13 +37,28 @@
virtual std::string get_extension() const = 0;
//! human readable description of the format
virtual std::string get_description() const = 0;
+};
+typedef boost::shared_ptr<Formatter> FormatterPtr;
+
+class ImportFormatter
+{
+public:
//! import MSC document
virtual MscPtr load_msc(std::istream& stream) = 0;
+};
+
+typedef boost::shared_ptr<ImportFormatter> ImportFormatterPtr;
+
+class ExportFormatter
+{
+public:
//! export MSC document
- virtual int save_msc(std::ostream& stream, const MscPtr& msc) = 0;
+ virtual int save_msc(std::ostream& stream, const std::string &name, const std::vector<MscPtr>& msc) = 0;
};
+typedef boost::shared_ptr<ExportFormatter> ExportFormatterPtr;
+
//! module initialization function
typedef Formatter** (*FInitFormatters)();
Added: trunk/src/view/visio/addon/aboutdlg.h
===================================================================
--- trunk/src/view/visio/addon/aboutdlg.h (rev 0)
+++ trunk/src/view/visio/addon/aboutdlg.h 2009-01-11 15:30:16 UTC (rev 163)
@@ -0,0 +1,58 @@
+/*
+ * 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) 2007-2008 Petr Gotthard <pet...@ce...>
+ *
+ * $Id$
+ */
+
+#pragma once
+
+// Include libraries from the Windows Template Library (WTL).
+// http://wtl.sourceforge.net
+#include <atldlgs.h>
+#include <atlctrls.h>
+
+class CAboutDlg : public ATL::CDialogImpl<CAboutDlg>
+{
+public:
+ enum { IDD = IDD_ABOUTBOX };
+
+ std::wstring m_version;
+
+protected:
+BEGIN_MSG_MAP(CAboutDlg)
+ MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog)
+ COMMAND_ID_HANDLER(IDOK, OnCloseCmd)
+END_MSG_MAP()
+
+// Handler prototypes:
+// LRESULT MessageHandler(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
+// LRESULT CommandHandler(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
+// LRESULT NotifyHandler(int idCtrl, LPNMHDR pnmh, BOOL& bHandled)
+
+ LRESULT OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
+ {
+ CenterWindow(GetParent());
+ ::SetWindowText(GetDlgItem(IDC_ABOUT_VERSION), m_version.c_str());
+ return TRUE;
+ }
+
+ LRESULT OnCloseCmd(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
+ {
+ EndDialog(wID);
+ return 0;
+ }
+};
+
+// $Id$
Property changes on: trunk/src/view/visio/addon/aboutdlg.h
___________________________________________________________________
Added: svn:keywords
+ Id
Added: svn:eol-style
+ native
Modified: trunk/src/view/visio/addon/addon.cpp
===================================================================
--- trunk/src/view/visio/addon/addon.cpp 2009-01-11 14:50:15 UTC (rev 162)
+++ trunk/src/view/visio/addon/addon.cpp 2009-01-11 15:30:16 UTC (rev 163)
@@ -19,6 +19,7 @@
#include "stdafx.h"
#include "dllmodule.h"
#include "addon.h"
+#include "aboutdlg.h"
#include "document.h"
#include "errors.h"
#include "resource.h"
@@ -37,7 +38,6 @@
#include <Addsink.cpp>
const int MIN_VISIO_VERSION = 11;
-const _bstr_t VST_FILE_NAME = _T("MSC.vtx");
CStudioAddon scstudio(_T(ADDON_NAME), IDS_ADDON_NAME);
@@ -55,13 +55,16 @@
VAORC CStudioAddon::About(LPVAOV2LSTRUCT pV2L)
{
TRACE("CStudioAddon::About() called");
+ CAboutDlg dlg;
std::wstringstream message;
message
<< GetVersionInfo(_T("\\StringFileInfo\\000004e4\\ProductName"))
- << ", version " << GetVersionInfo(_T("\\StringFileInfo\\000004e4\\ProductVersion"));
+ << ", version " << GetVersionInfo(_T("\\StringFileInfo\\000004e4\\ProductVersion"))
+ << " (" << GetVersionInfo(_T("\\StringFileInfo\\000004e4\\PrivateBuild")) << ")";
+ dlg.m_version = message.str();
- MessageBox(GetActiveWindow(), message.str().c_str(), _T("About"), MB_OK);
+ dlg.DoModal();
return VAORC_SUCCESS;
}
@@ -280,6 +283,9 @@
TRACE("CStudioAddon::Run() menu item 'Check--Run'");
return pDocumentMonitor->OnMenuRun(vsoApp);
case 203:
+ TRACE("CStudioAddon::Run() menu item 'Check--Import Drawing'");
+ return pDocumentMonitor->OnMenuImport(vsoApp);
+ case 204:
TRACE("CStudioAddon::Run() menu item 'Check--Export Drawing'");
return pDocumentMonitor->OnMenuExport(vsoApp);
Modified: trunk/src/view/visio/addon/dllmodule.rc
===================================================================
--- trunk/src/view/visio/addon/dllmodule.rc 2009-01-11 14:50:15 UTC (rev 162)
+++ trunk/src/view/visio/addon/dllmodule.rc 2009-01-11 15:30:16 UTC (rev 163)
@@ -21,6 +21,25 @@
#pragma code_page(1252)
#endif //_WIN32
+/////////////////////////////////////////////////////////////////////////////
+//
+// Dialog
+//
+
+IDD_ABOUTBOX DIALOGEX 0, 0, 240, 79
+STYLE DS_SETFONT | DS_MODALFRAME | WS_CAPTION | WS_SYSMENU
+CAPTION "About Sequence Chart Studio"
+FONT 8, "Microsoft Sans Serif", 400, 0, 0x0
+BEGIN
+ LTEXT "Sequence Chart Studio 0.0.0",IDC_ABOUT_VERSION,5,5,230,
+ 10
+ LTEXT "http://scstudio.sourceforge.net",IDC_STATIC,5,15,230,10
+ LTEXT "This program comes with ABSOLUTELY NO WARRANTY. This program is a free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1.",
+ IDC_STATIC,5,30,230,25
+ DEFPUSHBUTTON "&OK",IDOK,184,60,50,14
+END
+
+
#ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
@@ -53,13 +72,13 @@
//
VS_VERSION_INFO VERSIONINFO
- FILEVERSION 0,1,2,0
- PRODUCTVERSION 0,1,2,0
+ FILEVERSION 0,1,3,0
+ PRODUCTVERSION 0,1,3,0
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
- FILEFLAGS 0x1L
+ FILEFLAGS 0x9L
#else
- FILEFLAGS 0x0L
+ FILEFLAGS 0x8L
#endif
FILEOS 0x4L
FILETYPE 0x2L
@@ -71,12 +90,13 @@
BEGIN
VALUE "CompanyName", "Masaryk University Brno"
VALUE "FileDescription", "Microsoft Visio add-on for design and verification of Message Sequence Charts (MSC)."
- VALUE "FileVersion", "0.1.2"
+ VALUE "FileVersion", "0.1.3"
VALUE "InternalName", "scstudio.vsl"
VALUE "LegalCopyright", "(c) Petr Gotthard. All rights reserved."
VALUE "OriginalFilename", "scstudio.vsl"
+ VALUE "PrivateBuild", "$Revision$"
VALUE "ProductName", "Sequence Chart Studio"
- VALUE "ProductVersion", "0.1.2"
+ VALUE "ProductVersion", "0.1.3"
END
END
BLOCK "VarFileInfo"
Property changes on: trunk/src/view/visio/addon/dllmodule.rc
___________________________________________________________________
Added: svn:keywords
+ Revision
Modified: trunk/src/view/visio/addon/document.cpp
===================================================================
--- trunk/src/view/visio/addon/document.cpp 2009-01-11 14:50:15 UTC (rev 162)
+++ trunk/src/view/visio/addon/document.cpp 2009-01-11 15:30:16 UTC (rev 163)
@@ -238,13 +238,20 @@
menuItem2->BeginGroup = true;
Visio::IVMenuItemPtr menuItem3 = menu->MenuItems->Add();
- menuItem3->Caption = "&Export Drawing...";
+ menuItem3->Caption = "&Import Drawing...";
menuItem3->AddOnName = ADDON_NAME;
menuItem3->AddOnArgs = "/event=203";
menuItem3->BeginGroup = true;
// enable only if some formatters are available
menuItem3->Enabled = m_formatters.size() > 0;
+ Visio::IVMenuItemPtr menuItem4 = menu->MenuItems->Add();
+ menuItem4->Caption = "&Export Drawing...";
+ menuItem4->AddOnName = ADDON_NAME;
+ menuItem4->AddOnArgs = "/event=204";
+ // enable only if some formatters are available
+ menuItem4->Enabled = m_formatters.size() > 0;
+
vsoDocument->SetCustomMenus(vsoMenus);
}
@@ -356,6 +363,33 @@
return res;
}
+// align a given number[inch] to a 5[mm] grid
+inline double align5(double inch)
+{
+ // 1[inch] = 25.4[mm]
+ return floor(inch*25.4/5)*5/25.4;
+}
+
+static const INCH2MM = 25.4;
+
+VAORC CDocumentMonitor::OnMenuImport(Visio::IVApplicationPtr vsoApp)
+{
+ double pageHeight =
+ vsoApp->ActivePage->PageSheet->CellsSRC[visSectionObject][visRowPage][visPageHeight]->ResultIU;
+
+ Visio::IVDocumentPtr stencil = vsoApp->Documents->Item[BMSC_STENCIL_NAME];
+ Visio::IVMasterPtr master1 = stencil->Masters->Item["Message (Right)"];
+ Visio::IVMasterPtr master2 = stencil->Masters->Item["Line Instance"];
+
+ Visio::IVShapePtr sh1 = vsoApp->ActivePage->Drop(master1, 0, pageHeight-0);
+ Visio::IVShapePtr sh2 = vsoApp->ActivePage->Drop(master2, 0, pageHeight-0);
+
+ Visio::IVCellPtr c1 = sh1->CellsSRC[visSectionObject][visRowXForm1D][vis1DBeginX];
+ c1->GlueToPos(sh2, 0.5, 0);
+
+ return VAORC_FAILURE;
+}
+
VAORC CDocumentMonitor::OnMenuExport(Visio::IVApplicationPtr vsoApp)
{
std::string extension;
@@ -401,26 +435,30 @@
return VAORC_FAILURE;
}
- // look for the appropriate formatter
+ // look for the appropriate export formatter
for(FormatterPtrList::const_iterator fpos = m_formatters.begin();
fpos != m_formatters.end(); fpos++)
{
- if(stricmp(fileExtension+1, (*fpos)->get_extension().c_str()) == 0)
+ if(stricmp(fileExtension+1, (*fpos)->get_extension().c_str()) != 0)
+ continue;
+
+ ExportFormatterPtr formatter = boost::dynamic_pointer_cast<ExportFormatter>(*fpos);
+ if(formatter == NULL)
+ continue;
+
+ std::ofstream stream;
+ stream.open(fileName, std::ios::out | std::ios::trunc);
+ if(!stream.good())
{
- std::ofstream stream;
- stream.open(fileName, std::ios::out | std::ios::trunc);
- if(!stream.good())
- {
- MessageBox(GetActiveWindow(),
- _T("Cannot export given file."), _T("Error"), MB_OK | MB_ICONEXCLAMATION);
- return VAORC_FAILURE;
- }
+ MessageBox(GetActiveWindow(),
+ _T("Cannot export given file."), _T("Error"), MB_OK | MB_ICONEXCLAMATION);
+ return VAORC_FAILURE;
+ }
- ExportActiveDocument(*fpos, stream);
+ ExportActiveDocument(formatter, stream);
- stream.close();
- return VAORC_SUCCESS;
- }
+ stream.close();
+ return VAORC_SUCCESS;
}
MessageBox(GetActiveWindow(),
@@ -473,7 +511,7 @@
m_reportVisible = false;
}
-void CDocumentMonitor::ExportActiveDocument(const FormatterPtr& formatter, std::ostream& stream)
+void CDocumentMonitor::ExportActiveDocument(const ExportFormatterPtr& formatter, std::ostream& stream)
{
if(!m_reportVisible)
ShowReportView(m_vsoApp);
@@ -482,15 +520,17 @@
m_reportView->Reset();
CDrawingExtractor extractor(m_reportView);
+ std::vector<MscPtr> msc;
+
// export all pages of the active document
for(int i = 1; i <= m_vsoDocument->Pages->Count; i++)
{
Visio::IVPagePtr vsoPage = m_vsoDocument->Pages->Item[i];
// extract the drawing
- MscPtr msc = extractor.extract_msc(vsoPage);
- if(msc != NULL)
+ MscPtr drawing = extractor.extract_msc(vsoPage);
+ if(drawing != NULL)
{
- formatter->save_msc(stream, msc);
+ msc.push_back(drawing);
}
else
{
@@ -499,8 +539,16 @@
}
}
- m_reportView->Print(RS_NOTICE,
- stringize() << "File saved.");
+ if(msc.size() > 0)
+ {
+ char name[MAX_PATH];
+ wcstombs(name, m_vsoDocument->Name, MAX_PATH);
+
+ formatter->save_msc(stream, name, msc);
+
+ m_reportView->Print(RS_NOTICE,
+ stringize() << "File saved.");
+ }
}
Visio::IVShapePtr CDocumentMonitor::FindShape(const _bstr_t& id)
Modified: trunk/src/view/visio/addon/document.h
===================================================================
--- trunk/src/view/visio/addon/document.h 2009-01-11 14:50:15 UTC (rev 162)
+++ trunk/src/view/visio/addon/document.h 2009-01-11 15:30:16 UTC (rev 163)
@@ -23,6 +23,11 @@
#include <Vaddon.h>
+//! template used to create new documents
+static const _bstr_t VST_FILE_NAME = _T("MSC.vtx");
+static const _bstr_t BMSC_STENCIL_NAME = _T("Basic MSC.vsx");
+static const _bstr_t HMSC_STENCIL_NAME = _T("HMSC.vsx");
+
class CStudioAddon;
class CDocumentMonitor
@@ -38,12 +43,13 @@
VAORC OnMenuRun(Visio::IVApplicationPtr vsoApp);
VAORC OnMenuWindowsReporter(Visio::IVApplicationPtr vsoApp);
+ VAORC OnMenuImport(Visio::IVApplicationPtr vsoApp);
VAORC OnMenuExport(Visio::IVApplicationPtr vsoApp);
void ShowReportView(Visio::IVApplicationPtr vsoApp);
void OnHideReportView();
- void ExportActiveDocument(const FormatterPtr& formatter, std::ostream& stream);
+ void ExportActiveDocument(const ExportFormatterPtr& formatter, std::ostream& stream);
Visio::IVShapePtr FindShape(const _bstr_t& id);
int SelectShapes(const std::vector<_bstr_t>& ids);
Modified: trunk/src/view/visio/addon/resource.h
===================================================================
--- trunk/src/view/visio/addon/resource.h 2009-01-11 14:50:15 UTC (rev 162)
+++ trunk/src/view/visio/addon/resource.h 2009-01-11 15:30:16 UTC (rev 163)
@@ -7,14 +7,16 @@
#define IDS_ERROR_VISIO_VERSION 101
#define IDS_VSL_NAME 102
#define IDS_REPORT_VIEW 103
+#define IDD_ABOUTBOX 203
+#define IDC_ABOUT_VERSION 206
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
-#define _APS_NEXT_RESOURCE_VALUE 203
+#define _APS_NEXT_RESOURCE_VALUE 204
#define _APS_NEXT_COMMAND_VALUE 32768
-#define _APS_NEXT_CONTROL_VALUE 206
+#define _APS_NEXT_CONTROL_VALUE 208
#define _APS_NEXT_SYMED_VALUE 105
#endif
#endif
Modified: trunk/src/view/visio/addon/scstudio.vcproj
===================================================================
--- trunk/src/view/visio/addon/scstudio.vcproj 2009-01-11 14:50:15 UTC (rev 162)
+++ trunk/src/view/visio/addon/scstudio.vcproj 2009-01-11 15:30:16 UTC (rev 163)
@@ -166,6 +166,9 @@
Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}">
<File
+ RelativePath=".\aboutdlg.h">
+ </File>
+ <File
RelativePath=".\addon.cpp">
</File>
<File
Modified: trunk/src/view/visio/stencils/Sequence Chart Studio/MSC.vtx
===================================================================
--- trunk/src/view/visio/stencils/Sequence Chart Studio/MSC.vtx 2009-01-11 14:50:15 UTC (rev 162)
+++ trunk/src/view/visio/stencils/Sequence Chart Studio/MSC.vtx 2009-01-11 15:30:16 UTC (rev 163)
@@ -1,5 +1,5 @@
<?xml version='1.0' encoding='utf-8' ?>
-<VisioDocument key='C67AD2FF5FBE0546D5C43B7DC1788C7E773D0D4F8D26B0B583BD64B4B637BEF38C1EF89F60E35E54FD5F76456757727A9DDBE3714D9B5961B3394ABD4DF6926B' start='190' xmlns='http://schemas.microsoft.com/visio/2003/core' metric='0' DocLangID='1033' buildnum='8161' version='11.0' xml:space='preserve'><DocumentProperties><Title>Message Sequence Chart</Title><Creator>Petr Gotthard</Creator><Template>P:\Projects\scstudio\src\view\visio\Sequence Chart Studio\MSC.vtx</Template><Desc>Create interaction diagram standartized in ITU-T Z.120.</Desc><Company>Brno</Company><BuildNumberCreated>738205665</BuildNumberCreated><BuildNumberEdited>738205665</BuildNumberEdited><PreviewPicture Size='21216'>
+<VisioDocument key='E239D217E4207C139E1257D8835584F97E0E05B4585D344AE83F925EB454A46F3A98795534085029641C662E8016F3BE6DC1C1782EB3F117A2C61A68C9B82E13' start='190' xmlns='http://schemas.microsoft.com/visio/2003/core' metric='0' DocLangID='1033' buildnum='8161' version='11.0' xml:space='preserve'><DocumentProperties><Title>Message Sequence Chart</Title><Creator>Petr Gotthard</Creator><Template>P:\Projects\scstudio\src\view\visio\Sequence Chart Studio\MSC.vtx</Template><Desc>Create interaction diagram standartized in ITU-T Z.120.</Desc><Company>Brno</Company><BuildNumberCreated>738205665</BuildNumberCreated><BuildNumberEdited>738205665</BuildNumberEdited><PreviewPicture Size='21216'>
AQAAAIwAAAAAAAAAAAAAAFIAAABSAAAAAAAAAAAAAACSCQAAmAkAACBFTUYAAAEA4FIAAAMAAAABA
AAADwAAAGwAAAAAAAAAAAQAAAADAAAyAQAA5gAAAAAAAAAAAAAAAAAAAFCrBABwggMAVgBJAFMASQ
BPAAAARAByAGEAdwBpAG4AZwAAAAAAAABMAAAAQFIAAAAAAAAAAAAAUgAAAFIAAAAAAAAAAAAAAFM
@@ -372,445 +372,4 @@
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////wAAAA4AAAAUAAAA
-AAAAABAAAAAUAAAA</PreviewPicture><TimeCreated>2008-12-14T15:08:25</TimeCreated><TimeSaved>2008-12-30T15:13:32</TimeSaved><TimeEdited>2008-12-30T15:12:49</TimeEdited><TimePrinted>2008-12-14T15:08:25</TimePrinted></DocumentProperties><DocumentSettings TopPage='0' DefaultTextStyle='3' DefaultLineStyle='3' DefaultFillStyle='3' DefaultGuideStyle='4'><GlueSettings>41</GlueSettings><SnapSettings>295</SnapSettings><SnapExtensions>34</SnapExtensions><DynamicGridEnabled>0</DynamicGridEnabled><ProtectStyles>0</ProtectStyles><ProtectShapes>0</ProtectShapes><ProtectMasters>0</ProtectMasters><ProtectBkgnds>0</ProtectBkgnds></DocumentSettings><Colors><ColorEntry IX='0' RGB='#000000'/><ColorEntry IX='1' RGB='#FFFFFF'/><ColorEntry IX='2' RGB='#FF0000'/><ColorEntry IX='3' RGB='#00FF00'/><ColorEntry IX='4' RGB='#0000FF'/><ColorEntry IX='5' RGB='#FFFF00'/><ColorEntry IX='6' RGB='#FF00FF'/><ColorEntry IX='7' RGB='#00FFFF'/><ColorEntry IX='8' RGB='#800000'/><ColorEntry IX='9' RGB='#008000'/><ColorEntry IX='10' RGB='#000080'/><ColorEntry IX='11' RGB='#808000'/><ColorEntry IX='12' RGB='#800080'/><ColorEntry IX='13' RGB='#008080'/><ColorEntry IX='14' RGB='#C0C0C0'/><ColorEntry IX='15' RGB='#E6E6E6'/><ColorEntry IX='16' RGB='#CDCDCD'/><ColorEntry IX='17' RGB='#B3B3B3'/><ColorEntry IX='18' RGB='#9A9A9A'/><ColorEntry IX='19' RGB='#808080'/><ColorEntry IX='20' RGB='#666666'/><ColorEntry IX='21' RGB='#4D4D4D'/><ColorEntry IX='22' RGB='#333333'/><ColorEntry IX='23' RGB='#1A1A1A'/></Colors><FaceNames><FaceName ID='1' Name='Arial Unicode MS' UnicodeRanges='-1 -369098753 63 0' CharSets='1614741759 -65536' Panos='2 11 6 4 2 2 2 2 2 4' Flags='357'/><FaceName ID='2' Name='Symbol' UnicodeRanges='0 0 0 0' CharSets='-2147483648 0' Panos='5 5 1 2 1 7 6 2 5 7' Flags='261'/><FaceName ID='3' Name='Wingdings' UnicodeRanges='0 0 0 0' CharSets='-2147483648 0' Panos='5 0 0 0 0 0 0 0 0 0' Flags='261'/><FaceName ID='4' Name='Arial' UnicodeRanges='31367 -2147483648 8 0' CharSets='1073742335 -65536' Panos='2 11 6 4 2 2 2 2 2 4' Flags='325'/><FaceName ID='5' Name='SimSun' UnicodeRanges='1627421663 -2147483648 8 0' CharSets='536936959 539492352' Panos='2 11 6 4 2 2 2 2 2 4' Flags='327'/><FaceName ID='6' Name='PMingLiU' UnicodeRanges='1627421663 -2147483648 8 0' CharSets='536936959 539492352' Panos='2 11 6 4 2 2 2 2 2 4' Flags='327'/><FaceName ID='7' Name='MS PGothic' UnicodeRanges='1627421663 -2147483648 8 0' CharSets='536936959 539492352' Panos='2 11 6 4 2 2 2 2 2 4' Flags='327'/><FaceName ID='8' Name='Dotum' UnicodeRanges='1627421663 -2147483648 8 0' CharSets='536936959 539492352' Panos='2 11 6 4 2 2 2 2 2 4' Flags='327'/><FaceName ID='9' Name='Sylfaen' UnicodeRanges='67110535 0 0 0' CharSets='536871071 0' Panos='1 10 5 2 5 3 6 3 3 3' Flags='325'/><FaceName ID='10' Name='Estrangelo Edessa' UnicodeRanges='-2147459008 0 128 0' CharSets='0 0' Panos='3 8 6 0 0 0 0 0 0 0' Flags='325'/><FaceName ID='11' Name='Vrinda' UnicodeRanges='65539 0 0 0' CharSets='1 0' Panos='1 1 6 0 1 1 1 1 1 1' Flags='325'/><FaceName ID='12' Name='Shruti' UnicodeRanges='262144 0 0 0' CharSets='0 0' Panos='2 0 5 0 0 0 0 0 0 0' Flags='325'/><FaceName ID='13' Name='Mangal' UnicodeRanges='32768 0 0 0' CharSets='0 0' Panos='0 0 4 0 0 0 0 0 0 0' Flags='325'/><FaceName ID='14' Name='Tunga' UnicodeRanges='4194304 0 0 0' CharSets='0 0' Panos='0 0 4 0 0 0 0 0 0 0' Flags='325'/><FaceName ID='15' Name='Sendnya' UnicodeRanges='1627421663 -2147483648 8 0' CharSets='536936959 539492352' Panos='2 11 6 4 2 2 2 2 2 4' Flags='327'/><FaceName ID='16' Name='Raavi' UnicodeRanges='131072 0 0 0' CharSets='0 0' Panos='2 0 5 0 0 0 0 0 0 0' Flags='325'/><FaceName ID='17' Name='Dhenu' UnicodeRanges='1627421663 -2147483648 8 0' CharSets='536936959 539492352' Panos='2 11 6 4 2 2 2 2 2 4' Flags='327'/><FaceName ID='18' Name='Latha' UnicodeRanges='1048576 0 0 0' CharSets='0 0' Panos='2 0 4 0 0 0 0 0 0 0' Flags='325'/><FaceName ID='19' Name='Gautami' UnicodeRanges='2097152 0 0 0' CharSets='0 0' Panos='2 0 5 0 0 0 0 0 0 0' Flags='325'/><FaceName ID='20' Name='Cordia New' UnicodeRanges='1627421663 -2147483648 8 0' CharSets='536936959 539492352' Panos='2 11 6 4 2 2 2 2 2 4' Flags='327'/><FaceName ID='21' Name='MS Farsi' UnicodeRanges='1627421663 -2147483648 8 0' CharSets='536936959 539492352' Panos='2 11 6 4 2 2 2 2 2 4' Flags='327'/><FaceName ID='22' Name='Gulim' UnicodeRanges='1627421663 -2147483648 8 0' CharSets='536936959 539492352' Panos='2 11 6 4 2 2 2 2 2 4' Flags='327'/><FaceName ID='23' Name='Times New Roman' UnicodeRanges='31367 -2147483648 8 0' CharSets='1073742335 -65536' Panos='2 2 6 3 5 4 5 2 3 4' Flags='325'/></FaceNames><StyleSheets><StyleSheet ID='0' NameU='No Style' Name='No Style'><StyleProp><EnableLineProps>1</EnableLineProps><EnableFillProps>1</EnableFillProps><EnableTextProps>1</EnableTextProps><HideForApply>0</HideForApply></StyleProp><Line><LineWeight>0.01</LineWeight><LineColor>0</LineColor><LinePattern>1</LinePattern><Rounding>0</Rounding><EndArrowSize>2</EndArrowSize><BeginArrow>0</BeginArrow><EndArrow>0</EndArrow><LineCap>0</LineCap><BeginArrowSize>2</BeginArrowSize><LineColorTrans>0</LineColorTrans></Line><Fill><FillForegnd>1</FillForegnd><FillBkgnd>0</FillBkgnd><FillPattern>1</FillPattern><ShdwForegnd>0</ShdwForegnd><ShdwBkgnd>1</ShdwBkgnd><ShdwPattern>0</ShdwPattern><FillForegndTrans>0</FillForegndTrans><FillBkgndTrans>0</FillBkgndTrans><ShdwForegndTrans>0</ShdwForegndTrans><ShdwBkgndTrans>0</ShdwBkgndTrans><ShapeShdwType>0</ShapeShdwType><ShapeShdwOffsetX>0</ShapeShdwOffsetX><ShapeShdwOffsetY>0</ShapeShdwOffsetY><ShapeShdwObliqueAngle>0</ShapeShdwObliqueAngle><ShapeShdwScaleFactor>1</ShapeShdwScaleFactor></Fill><TextBlock><LeftMargin>0</LeftMargin><RightMargin>0</RightMargin><TopMargin>0</TopMargin><BottomMargin>0</BottomMargin><VerticalAlign>1</VerticalAlign><TextBkgnd>0</TextBkgnd><DefaultTabStop>0.5</DefaultTabStop><TextDirection>0</TextDirection><TextBkgndTrans>0</TextBkgndTrans></TextBlock><Protection><LockWidth>0</LockWidth><LockHeight>0</LockHeight><LockMoveX>0</LockMoveX><LockMoveY>0</LockMoveY><LockAspect>0</LockAspect><LockDelete>0</LockDelete><LockBegin>0</LockBegin><LockEnd>0</LockEnd><LockRotate>0</LockRotate><LockCrop>0</LockCrop><LockVtxEdit>0</LockVtxEdit><LockTextEdit>0</LockTextEdit><LockFormat>0</LockFormat><LockGroup>0</LockGroup><LockCalcWH>0</LockCalcWH><LockSelect>0</LockSelect><LockCustProp>0</LockCustProp></Protection><Misc><NoObjHandles>0</NoObjHandles><NonPrinting>0</NonPrinting><NoCtlHandles>0</NoCtlHandles><NoAlignBox>0</NoAlignBox><UpdateAlignBox>0</UpdateAlignBox><HideText>0</HideText><DynFeedback>0</DynFeedback><GlueType>0</GlueType><WalkPreference>0</WalkPreference><BegTrigger F='No Formula'>0</BegTrigger><EndTrigger F='No Formula'>0</EndTrigger><ObjType>0</ObjType><Comment V='null'/><IsDropSource>0</IsDropSource><NoLiveDynamics>0</NoLiveDynamics><LocalizeMerge>0</LocalizeMerge><Calendar>0</Calendar><LangID>1033</LangID><ShapeKeywords V='null'/><DropOnPageScale>1</DropOnPageScale></Misc><Event><TheData F='No Formula'>0</TheData><TheText F='No Formula'>0</TheText><EventDblClick F='No Formula'>0</EventDblClick><EventXFMod F='No Formula'>0</EventXFMod><EventDrop F='No Formula'>0</EventDrop></Event><Help><HelpTopic V='null'/><Copyright V='null'/></Help><LayerMem><LayerMember V='null'/></LayerMem><RulerGrid><XRulerDensity>32</XRulerDensity><YRulerDensity>32</YRulerDensity><XRulerOrigin>0</XRulerOrigin><YRulerOrigin>0</YRulerOrigin><XGridDensity>8</XGridDensity><YGridDensity>8</YGridDensity><XGridSpacing>0</XGridSpacing><YGridSpacing>0</YGridSpacing><XGridOrigin>0</XGridOrigin><YGridOrigin>0</YGridOrigin></RulerGrid><Image><Gamma>1</Gamma><Contrast>0.5</Contrast><Brightness>0.5</Brightness><Sharpen>0</Sharpen><Blur>0</Blur><Denoise>0</Denoise><Transparency>0...
[truncated message content] |
|
From: <ba...@us...> - 2009-01-11 19:50:42
|
Revision: 165
http://scstudio.svn.sourceforge.net/scstudio/?rev=165&view=rev
Author: babicaj
Date: 2009-01-11 19:50:35 +0000 (Sun, 11 Jan 2009)
Log Message:
-----------
deadlock checker returns proper counter example
Modified Paths:
--------------
trunk/src/check/liveness/CMakeLists.txt
trunk/src/check/liveness/deadlock_checker.cpp
trunk/src/check/pseudocode/msc_duplicators.cpp
trunk/src/check/pseudocode/msc_duplicators.h
trunk/src/data/msc.cpp
trunk/src/data/msc.h
Modified: trunk/src/check/liveness/CMakeLists.txt
===================================================================
--- trunk/src/check/liveness/CMakeLists.txt 2009-01-11 17:57:54 UTC (rev 164)
+++ trunk/src/check/liveness/CMakeLists.txt 2009-01-11 19:50:35 UTC (rev 165)
@@ -9,6 +9,7 @@
TARGET_LINK_LIBRARIES(scliveness
scmsc
+ scpseudocode
)
INSTALL(TARGETS scliveness
Modified: trunk/src/check/liveness/deadlock_checker.cpp
===================================================================
--- trunk/src/check/liveness/deadlock_checker.cpp 2009-01-11 17:57:54 UTC (rev 164)
+++ trunk/src/check/liveness/deadlock_checker.cpp 2009-01-11 19:50:35 UTC (rev 165)
@@ -18,6 +18,7 @@
#include "data/dfsb_hmsc_traverser.h"
#include "check/liveness/deadlock_checker.h"
+#include "check/pseudocode/msc_duplicators.h"
DeadlockCheckerPtr DeadlockChecker::m_instance;
@@ -124,36 +125,14 @@
HMscPtr DeadlockChecker::create_counter_example(const MscElementPListList& path)
{
-// InnerNodePListList::const_iterator hmscs_it;
-// HMscPtr result;
-// for (hmscs_it = path.begin(); hmscs_it != path.end(); hmscs_it++)
-// {
-// HMscPtr current_hmsc;
-// InnerNode* last_node = NULL;
-// InnerNodePList::const_iterator nodes_it;
-// for (nodes_it = hmscs_it->begin(); nodes_it != hmscs_it->end(); nodes_it++)
-// {
-// if (last_node == NULL)
-// {
-// if (dynamic_cast<ReferenceNode*> (*nodes_it) != NULL)
-// last_node = new ReferenceNode((ReferenceNode*) * nodes_it);
-// else
-// last_node = new ConnectionNode((ConnectionNode*) * nodes_it);
-// current_hmsc = new HMsc((*nodes_it)->get_owner());
-// current_hmsc = set_start(new StartNode((*nodes_it)->get_owner()->get_start().get()));
-// current_hmsc->get_start()->add_successor(last_node);
-// if (!result.get())
-// result = current_hmsc;
-// }
-// else
-// {
-// last_node->add_successor(*nodes_it);
-// last_node = *nodes_it;
-// }
-// }
-// }
-// return result;
- HMscPtr example = new HMsc("counter example");
+ HMscPathDuplicator duplicator;
+ HMscPtr example = duplicator.duplicate_path(path);
+ MscElementPListList::const_iterator h;
+ for(h=path.begin();h!=path.end();h++)
+ {
+ MscElement* last = (*h).back();
+ duplicator.get_copy(last)->set_marked(true);
+ }
return example;
}
Modified: trunk/src/check/pseudocode/msc_duplicators.cpp
===================================================================
--- trunk/src/check/pseudocode/msc_duplicators.cpp 2009-01-11 17:57:54 UTC (rev 164)
+++ trunk/src/check/pseudocode/msc_duplicators.cpp 2009-01-11 19:50:35 UTC (rev 165)
@@ -24,7 +24,38 @@
const std::string BMSC_GRAPH_DUPLICATOR_COPY_ATTR = "BGDcopy";
const std::string BMSC_GRAPH_DUPLICATOR_REF_ATTR = "BGDreferencing";
const std::string BMSC_GRAPH_DUPLICATOR_ENDLIST_ATTR = "BGDendlist";
+const std::string DUPLICATOR_COPY_ATTR = "Dcopy";
+Duplicator::Duplicator()
+{
+}
+
+Duplicator::~Duplicator()
+{
+ MscElementPList::const_iterator i;
+ for(i=m_modified_elements.begin();i!=m_modified_elements.end();i++)
+ {
+ (*i)->remove_attribute<MscElement*>(DUPLICATOR_COPY_ATTR);
+ }
+}
+
+MscElement*& Duplicator::get_copy(MscElement* e)
+{
+ bool just_set;
+ MscElement*& copy = e->get_attribute<MscElement*>(DUPLICATOR_COPY_ATTR,NULL,just_set);
+ if(just_set)
+ {
+ m_modified_elements.push_back(e);
+ }
+ return copy;
+}
+
+void Duplicator::set_copy(MscElement* original, MscElement* copy)
+{
+ MscElement*& c = get_copy(original);
+ c = copy;
+}
+
BMscDuplicator::BMscDuplicator()
{
}
@@ -488,4 +519,92 @@
return new_hmsc;
}
+HMscPtr HMscPathDuplicator::duplicate_path(const MscElementPListList& path)
+{
+ HMscPtr root;
+ if(path.size()>0)
+ {
+ MscElementPListList::const_iterator h;
+ PredecessorNode* new_pred(NULL);
+ for(h=path.begin();h!=path.end();h++)
+ {
+ HMscPtr new_hmsc;
+ NodeRelation* old_rel(NULL);
+ MscElementPList::const_iterator e;
+ for(e=(*h).begin();e!=(*h).end();e++)
+ {
+ if(e==(*h).begin())
+ {
+ StartNode* start = dynamic_cast<StartNode*>(*e);
+ new_hmsc = new HMsc(start->get_owner());
+ if(!root.get())
+ {
+ root = new_hmsc;
+ }
+ else
+ {
+ //hmsc is surely referenced from ReferenceNode
+ ReferenceNode* ref = dynamic_cast<ReferenceNode*>(new_pred);
+ ref->set_msc(new_hmsc);
+ }
+ StartNode* new_start = new StartNode(start);
+ new_hmsc->set_start(new_start);
+ new_pred = new_start;
+ set_copy(start,new_start);
+ set_copy(start->get_owner(),new_hmsc.get());
+ }
+ else
+ {
+ NodeRelation* rel = dynamic_cast<NodeRelation*>(*e);
+ if(rel)
+ {
+ old_rel = rel;
+ }
+ else
+ {
+ ReferenceNode* ref_node = dynamic_cast<ReferenceNode*>(*e);
+ NodeRelationPtr new_rel;
+ if(ref_node)
+ {
+ ReferenceNode* new_ref = new ReferenceNode(ref_node);
+ new_hmsc->add_node(new_ref);
+ new_rel = new_ref->add_predecessor(new_pred);
+ new_pred = new_ref;
+ set_copy(ref_node,new_ref);
+ }
+ else
+ {
+ ConnectionNode* con_node = dynamic_cast<ConnectionNode*>(*e);
+ if(con_node)
+ {
+ ConnectionNode* new_con = new ConnectionNode(con_node);
+ new_hmsc->add_node(new_con);
+ new_rel = new_con->add_predecessor(new_pred);
+ new_pred = new_con;
+ set_copy(con_node,new_con);
+ }
+ else
+ {
+ EndNode* end_node = dynamic_cast<EndNode*>(*e);
+ EndNode* new_end = new EndNode(end_node);
+ new_rel = new_end->add_predecessor(new_pred);
+ new_hmsc->add_node(new_end);
+ set_copy(end_node,new_end);
+ }
+ }
+ new_rel->set_original(old_rel);
+ new_rel->set_line(old_rel->get_line());
+ set_copy(old_rel,new_rel.get());
+ }
+ }
+ }
+ }
+ }
+ return root;
+}
+
+HMscPathDuplicator::~HMscPathDuplicator()
+{
+}
+
// $Id$
Modified: trunk/src/check/pseudocode/msc_duplicators.h
===================================================================
--- trunk/src/check/pseudocode/msc_duplicators.h 2009-01-11 17:57:54 UTC (rev 164)
+++ trunk/src/check/pseudocode/msc_duplicators.h 2009-01-11 19:50:35 UTC (rev 165)
@@ -26,6 +26,23 @@
typedef std::list<HMsc*> HMscPList;
typedef std::list<ConnectionNode*> ConnectionNodePList;
+class SCPSEUDOCODE_EXPORT Duplicator
+{
+protected:
+
+ MscElementPList m_modified_elements;
+
+ Duplicator();
+
+public:
+
+ virtual ~Duplicator();
+
+ MscElement*& get_copy(MscElement* e);
+
+ void set_copy(MscElement* original, MscElement* copy);
+};
+
class BMscDuplicator;
class EventsCreatorListener:
@@ -186,4 +203,18 @@
};
+/**
+ * \brief Duplicates path in HMsc.
+ *
+ * The path is supposed to be generated by traversers -- similar srtucture.
+ */
+class SCPSEUDOCODE_EXPORT HMscPathDuplicator:public Duplicator
+{
+public:
+
+ ~HMscPathDuplicator();
+
+ HMscPtr duplicate_path(const MscElementPListList& path);
+};
+
// $Id$
Modified: trunk/src/data/msc.cpp
===================================================================
--- trunk/src/data/msc.cpp 2009-01-11 17:57:54 UTC (rev 164)
+++ trunk/src/data/msc.cpp 2009-01-11 19:50:35 UTC (rev 165)
@@ -32,6 +32,16 @@
pred->m_successors.insert(this);
}
+void NodeRelation::set_line(const PolyLine& line)
+{
+ m_line = line;
+}
+
+const PolyLine& NodeRelation::get_line()
+{
+ return m_line;
+}
+
void SuccessorNode::remove_predecessor(const NodeRelationPtr& n)
{
m_predecessors.erase(n);
@@ -71,6 +81,10 @@
HMscNode::HMscNode(HMscNode* original):MscElementTmpl<HMscNode>(original),
m_owner(NULL)
{
+ if(original)
+ {
+ m_position = original->get_position();
+ }
}
HMscNodePtr HMscNode::my_ptr()
Modified: trunk/src/data/msc.h
===================================================================
--- trunk/src/data/msc.h 2009-01-11 17:57:54 UTC (rev 164)
+++ trunk/src/data/msc.h 2009-01-11 19:50:35 UTC (rev 165)
@@ -368,6 +368,10 @@
Msc(Msc* original):MscElementTmpl<Msc>(original)
{
+ if(original)
+ {
+ m_label = original->get_label();
+ }
}
public:
@@ -532,6 +536,10 @@
* Connects to a given PredecessorNode and re-configures its back pointer.
*/
void set_predecessor(PredecessorNode* pred);
+
+ void set_line(const PolyLine& line);
+
+ const PolyLine& get_line();
};
typedef boost::intrusive_ptr<NodeRelation> NodeRelationPtr;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <got...@us...> - 2009-01-13 23:11:34
|
Revision: 168
http://scstudio.svn.sourceforge.net/scstudio/?rev=168&view=rev
Author: gotthardp
Date: 2009-01-13 23:11:26 +0000 (Tue, 13 Jan 2009)
Log Message:
-----------
Fixed a compiler warning (struct vs. class Font).
Implemented visualization of counter examples. Currently only instances and complete messages are supported. No coregions. No HMSC.
Modified Paths:
--------------
trunk/src/data/msc_visual.h
trunk/src/view/visio/addon/addon.h
trunk/src/view/visio/addon/document.cpp
trunk/src/view/visio/addon/document.h
trunk/src/view/visio/addon/extract.cpp
trunk/src/view/visio/addon/extract.h
trunk/src/view/visio/addon/reportview.cpp
trunk/src/view/visio/addon/reportview.h
trunk/src/view/visio/addon/stdafx.h
trunk/src/view/visio/addon/visualize.cpp
trunk/src/view/visio/addon/visualize.h
Modified: trunk/src/data/msc_visual.h
===================================================================
--- trunk/src/data/msc_visual.h 2009-01-12 08:43:40 UTC (rev 167)
+++ trunk/src/data/msc_visual.h 2009-01-13 23:11:26 UTC (rev 168)
@@ -21,8 +21,8 @@
#include <list>
-typedef float Coordinate;
-typedef float Size;
+typedef double Coordinate;
+typedef double Size;
/**
* Denotes form of instance's axis as described by ITU-T
Modified: trunk/src/view/visio/addon/addon.h
===================================================================
--- trunk/src/view/visio/addon/addon.h 2009-01-12 08:43:40 UTC (rev 167)
+++ trunk/src/view/visio/addon/addon.h 2009-01-13 23:11:26 UTC (rev 168)
@@ -18,9 +18,6 @@
#pragma once
-#include <Vaddon.h>
-#include <Visiwrap.h>
-
#include <map>
class CReportView;
Modified: trunk/src/view/visio/addon/document.cpp
===================================================================
--- trunk/src/view/visio/addon/document.cpp 2009-01-12 08:43:40 UTC (rev 167)
+++ trunk/src/view/visio/addon/document.cpp 2009-01-13 23:11:26 UTC (rev 168)
@@ -290,7 +290,7 @@
if(result != NULL)
{
m_reportView->Print(RS_ERROR, stringize()
- << (*cpos)->get_description() << " violated.");
+ << (*cpos)->get_description() << " violated. [details]", result);
violated_count++;
}
else
@@ -317,6 +317,8 @@
satisfied_count++;
}
}
+
+ (*cpos)->cleanup_attributes();
}
if(satisfied_count == 0 && violated_count == 0)
@@ -617,6 +619,16 @@
}
}
+int CDocumentMonitor::DisplayDocument(const MscPtr& msc)
+{
+ Visio::IVDocumentPtr vsoDocument = m_vsoApp->GetDocuments()->Add(VST_FILE_NAME);
+
+ CDrawingVisualizer visualizer(vsoDocument->Pages->Item[1]);
+ visualizer.visualize_msc(msc);
+
+ return 0;
+}
+
Visio::IVShapePtr CDocumentMonitor::FindShape(const _bstr_t& id)
{
for(int i = 1; i <= m_vsoDocument->Pages->Count; i++)
Modified: trunk/src/view/visio/addon/document.h
===================================================================
--- trunk/src/view/visio/addon/document.h 2009-01-12 08:43:40 UTC (rev 167)
+++ trunk/src/view/visio/addon/document.h 2009-01-13 23:11:26 UTC (rev 168)
@@ -21,8 +21,6 @@
#include "data/formatter.h"
#include "data/checker.h"
-#include <Vaddon.h>
-
//! template used to create new documents
static const _bstr_t VST_FILE_NAME = _T("MSC.vtx");
static const _bstr_t BMSC_STENCIL_NAME = _T("Basic MSC.vsx");
@@ -52,6 +50,7 @@
void ImportDocument(const ImportFormatterPtr& formatter, std::istream& stream);
void ExportActiveDocument(const ExportFormatterPtr& formatter, std::ostream& stream);
+ int DisplayDocument(const MscPtr& msc);
Visio::IVShapePtr FindShape(const _bstr_t& id);
int SelectShapes(const std::vector<_bstr_t>& ids);
Modified: trunk/src/view/visio/addon/extract.cpp
===================================================================
--- trunk/src/view/visio/addon/extract.cpp 2009-01-12 08:43:40 UTC (rev 167)
+++ trunk/src/view/visio/addon/extract.cpp 2009-01-13 23:11:26 UTC (rev 168)
@@ -153,7 +153,7 @@
Visio::IVCellPtr posx = shape->CellsSRC[visSectionConnectionPts][cellrow][visX];
Visio::IVCellPtr posy = shape->CellsSRC[visSectionConnectionPts][cellrow][visY];
- return SPoint(posx->Result[visDrawingUnits], posy->Result[visDrawingUnits]);
+ return SPoint(posx->Result[visMillimeters], posy->Result[visMillimeters]);
}
void CDrawingExtractor::assert_no_nested_FromConnects(Visio::IVShapePtr shape)
@@ -364,6 +364,27 @@
return area;
}
+inline double align5(double mm)
+{
+ return floor(mm/5)*5;
+}
+
+InstancePtr new_instance_ptr(Visio::IVShapePtr shape)
+{
+ double page_height = align5(shape->ContainingPage->PageSheet->CellsSRC[visSectionObject][visRowPage][visPageHeight]->Result[visMillimeters]);
+
+ InstancePtr result = new Instance((const char*)shape->Text);
+
+ result->set_line_begin(Point(
+ shape->CellsSRC[visSectionObject][visRowXForm1D][vis1DBeginX]->Result[visMillimeters],
+ page_height - shape->CellsSRC[visSectionObject][visRowXForm1D][vis1DBeginY]->Result[visMillimeters]));
+ result->set_line_end(Point(
+ shape->CellsSRC[visSectionObject][visRowXForm1D][vis1DEndX]->Result[visMillimeters],
+ page_height - shape->CellsSRC[visSectionObject][visRowXForm1D][vis1DEndY]->Result[visMillimeters]));
+
+ return result;
+}
+
BMscPtr CDrawingExtractor::extract_bmsc(Visio::IVPagePtr vsoPage)
{
// keep previous error indicator; this function may be called recursively
@@ -387,7 +408,7 @@
switch(type)
{
case ST_BMSC_INSTANCE:
- instances[shape->ID] = new Instance((const char*)shape->Text);
+ instances[shape->ID] = new_instance_ptr(shape);
break;
case ST_BMSC_MESSAGE:
@@ -569,6 +590,7 @@
continue;
StrictEventPtr event = strict_area->add_event(new StrictEvent());
+ event->set_y(epos->event_time/instance->CellsSRC[visSectionObject][visRowXFormOut][visXFormWidth]->Result[visMillimeters]);
if(epos->event_type == SStrictOrder::ET_OUTGOING)
message->glue_send_event(event);
else if(epos->event_type == SStrictOrder::ET_INCOMING)
Modified: trunk/src/view/visio/addon/extract.h
===================================================================
--- trunk/src/view/visio/addon/extract.h 2009-01-12 08:43:40 UTC (rev 167)
+++ trunk/src/view/visio/addon/extract.h 2009-01-13 23:11:26 UTC (rev 168)
@@ -20,7 +20,6 @@
#include "reportview.h"
#include "fcmp.h"
-#include <Vaddon.h>
#include "data/msc.h"
struct nocase_comparator: public std::binary_function<std::string, std::string, bool>
Modified: trunk/src/view/visio/addon/reportview.cpp
===================================================================
--- trunk/src/view/visio/addon/reportview.cpp 2009-01-12 08:43:40 UTC (rev 167)
+++ trunk/src/view/visio/addon/reportview.cpp 2009-01-13 23:11:26 UTC (rev 168)
@@ -55,7 +55,7 @@
return 0;
}
-int CReportView::Print(TSeverity severity, const std::string& message, const std::vector<_bstr_t>& references)
+int CReportView::__Print(TSeverity severity, const std::string& message)
{
static const char *rtfPrefix =
"{\\rtf1\\ansi"
@@ -98,13 +98,33 @@
StreamIn(SF_RTF | SFF_SELECTION, es);
LineScroll(1);
+ return 0;
+}
+int CReportView::Print(TSeverity severity, const std::string& message, const std::vector<_bstr_t>& shapelist)
+{
+ __Print(severity, message);
+
+ Reference reference;
+ reference.shapes = shapelist;
// append new line to the list of references
- m_references.push_back(references);
+ m_references.push_back(reference);
return 0;
}
+int CReportView::Print(TSeverity severity, const std::string& message, const MscPtr& msc)
+{
+ __Print(severity, message);
+
+ Reference reference;
+ reference.drawing = msc;
+ // append new line to the list of references
+ m_references.push_back(reference);
+
+ return 0;
+}
+
LRESULT CReportView::OnLButtonDblClk(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
POINT pos = { LOWORD(lParam), HIWORD(lParam) };
@@ -114,8 +134,12 @@
TRACE("CReportView::OnLButtonDblClk() called at line " << line);
- if (m_references[line].size() > 0)
- m_documentMonitor->SelectShapes(m_references[line]);
+ if (m_references[line].shapes.size() > 0)
+ m_documentMonitor->SelectShapes(m_references[line].shapes);
+
+ if (m_references[line].drawing != 0)
+ m_documentMonitor->DisplayDocument(m_references[line].drawing);
+
return 1;
}
Modified: trunk/src/view/visio/addon/reportview.h
===================================================================
--- trunk/src/view/visio/addon/reportview.h 2009-01-12 08:43:40 UTC (rev 167)
+++ trunk/src/view/visio/addon/reportview.h 2009-01-13 23:11:26 UTC (rev 168)
@@ -18,7 +18,6 @@
#pragma once
#include "resource.h"
-#include <Visiwrap.h>
// Include libraries from the Windows Template Library (WTL).
// http://wtl.sourceforge.net
@@ -27,6 +26,8 @@
#include <sstream>
#include <vector>
+#include "data/msc.h"
+
class CDocumentMonitor;
//! Helper class to construct a message for CReportView::Print()
@@ -88,7 +89,8 @@
void Reset();
int Print(TSeverity severity, const std::string& message,
- const std::vector<_bstr_t>& references = std::vector<_bstr_t>());
+ const std::vector<_bstr_t>& shapelist = std::vector<_bstr_t>());
+ int Print(TSeverity severity, const std::string& message, const MscPtr& msc);
protected:
BEGIN_MSG_MAP(CReportView)
@@ -108,7 +110,15 @@
int m_statistics[__RS_LAST];
- typedef std::vector<std::vector<_bstr_t> > ReferenceList;
+ int __Print(TSeverity severity, const std::string& message);
+
+ struct Reference
+ {
+ std::vector<_bstr_t> shapes; // shapes to select
+ MscPtr drawing; // drawing to display
+ };
+
+ typedef std::vector<Reference> ReferenceList;
// UniqueID's of shapes referenced by lines in this report
ReferenceList m_references;
};
Modified: trunk/src/view/visio/addon/stdafx.h
===================================================================
--- trunk/src/view/visio/addon/stdafx.h 2009-01-12 08:43:40 UTC (rev 167)
+++ trunk/src/view/visio/addon/stdafx.h 2009-01-13 23:11:26 UTC (rev 168)
@@ -34,6 +34,9 @@
#include "resource.h"
+#include <Vaddon.h>
+#include <Visiwrap.h>
+
#include <atlbase.h>
#include <atlapp.h>
Modified: trunk/src/view/visio/addon/visualize.cpp
===================================================================
--- trunk/src/view/visio/addon/visualize.cpp 2009-01-12 08:43:40 UTC (rev 167)
+++ trunk/src/view/visio/addon/visualize.cpp 2009-01-13 23:11:26 UTC (rev 168)
@@ -43,10 +43,11 @@
BMscPtr bmsc = boost::dynamic_pointer_cast<BMsc>(drawing);
if(bmsc != NULL)
visualize_bmsc(bmsc);
+
+ // the last dropped shape would be selected
+ m_page->Application->ActiveWindow->DeselectAll();
}
-static const INCH2MM = 25.4;
-
void CDrawingVisualizer::visualize_instance(const InstancePtr& instance)
{
}
@@ -59,6 +60,8 @@
ipos != bmsc->get_instances().end(); ipos++)
{
Visio::IVShapePtr inst = m_page->Drop(m_instance_master, 0, m_page_height-0);
+ if((*ipos)->get_marked())
+ inst->CellsSRC[visSectionObject][visRowLine][visLineColor]->Result[visNoCast] = 2;
inst->Text = (*ipos)->get_label().c_str();
inst->CellsSRC[visSectionObject][visRowXForm1D][vis1DBeginX]->Result[visMillimeters] = (*ipos)->get_line_begin().get_x();
@@ -93,6 +96,8 @@
if(msg == NULL)
{
msg = m_page->Drop(m_message_master, 0, m_page_height-0);
+ if(message->get_marked() || event->get_marked())
+ msg->CellsSRC[visSectionObject][visRowLine][visLineColor]->Result[visNoCast] = 2;
msg->Text = message->get_label().c_str();
messages[message] = msg;
}
Modified: trunk/src/view/visio/addon/visualize.h
===================================================================
--- trunk/src/view/visio/addon/visualize.h 2009-01-12 08:43:40 UTC (rev 167)
+++ trunk/src/view/visio/addon/visualize.h 2009-01-13 23:11:26 UTC (rev 168)
@@ -18,7 +18,6 @@
#pragma once
-#include <Vaddon.h>
#include "data/msc.h"
class CDrawingVisualizer
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <got...@us...> - 2009-01-14 21:28:51
|
Revision: 169
http://scstudio.svn.sourceforge.net/scstudio/?rev=169&view=rev
Author: gotthardp
Date: 2009-01-14 21:28:47 +0000 (Wed, 14 Jan 2009)
Log Message:
-----------
Minor error/warning fixes. This version may crash! (It does on my Windows machine.)
Modified Paths:
--------------
trunk/src/check/order/fifo_checker.cpp
trunk/src/view/visio/addon/document.cpp
trunk/src/view/visio/addon/extract.cpp
Modified: trunk/src/check/order/fifo_checker.cpp
===================================================================
--- trunk/src/check/order/fifo_checker.cpp 2009-01-13 23:11:26 UTC (rev 168)
+++ trunk/src/check/order/fifo_checker.cpp 2009-01-14 21:28:47 UTC (rev 169)
@@ -43,7 +43,7 @@
copy->get_complete_message()->get_send_event()->set_marked(true);
}
}
- return bmsc;
+ return new_bmsc;
}
BMscPtr FifoChecker::check(BMscPtr bmsc, ChannelMapperPtr mapper)
Modified: trunk/src/view/visio/addon/document.cpp
===================================================================
--- trunk/src/view/visio/addon/document.cpp 2009-01-13 23:11:26 UTC (rev 168)
+++ trunk/src/view/visio/addon/document.cpp 2009-01-14 21:28:47 UTC (rev 169)
@@ -553,7 +553,7 @@
RECT rc = {0, 0, defWidth, defHeight};
HWND hwndTV = m_reportView->Create(
- (HWND)m_reportWindow->WindowHandle32,
+ (HWND)m_reportWindow->WindowHandle,
rc, NULL,
WS_CHILD | WS_VISIBLE | WS_VSCROLL | WS_HSCROLL |
ES_MULTILINE | ES_AUTOVSCROLL | ES_AUTOHSCROLL | ES_READONLY,
Modified: trunk/src/view/visio/addon/extract.cpp
===================================================================
--- trunk/src/view/visio/addon/extract.cpp 2009-01-13 23:11:26 UTC (rev 168)
+++ trunk/src/view/visio/addon/extract.cpp 2009-01-14 21:28:47 UTC (rev 169)
@@ -590,7 +590,7 @@
continue;
StrictEventPtr event = strict_area->add_event(new StrictEvent());
- event->set_y(epos->event_time/instance->CellsSRC[visSectionObject][visRowXFormOut][visXFormWidth]->Result[visMillimeters]);
+ event->set_y(epos->event_time);
if(epos->event_type == SStrictOrder::ET_OUTGOING)
message->glue_send_event(event);
else if(epos->event_type == SStrictOrder::ET_INCOMING)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <got...@us...> - 2009-01-16 22:48:04
|
Revision: 170
http://scstudio.svn.sourceforge.net/scstudio/?rev=170&view=rev
Author: gotthardp
Date: 2009-01-16 21:39:08 +0000 (Fri, 16 Jan 2009)
Log Message:
-----------
Fixed CRASH when opening a counter example.
TODO: It may be still necessary to use smart pointer for MscElement::m_original.
Removed remaining compiler warnings.
Modified Paths:
--------------
trunk/src/check/order/acyclic_checker.cpp
trunk/src/data/msc.cpp
trunk/src/data/msc.h
trunk/src/view/visio/addon/addon.cpp
trunk/src/view/visio/addon/extract.cpp
trunk/src/view/visio/addon/reportview.cpp
Modified: trunk/src/check/order/acyclic_checker.cpp
===================================================================
--- trunk/src/check/order/acyclic_checker.cpp 2009-01-14 21:28:47 UTC (rev 169)
+++ trunk/src/check/order/acyclic_checker.cpp 2009-01-16 21:39:08 UTC (rev 170)
@@ -52,7 +52,7 @@
{
traverser.traverse(bmsc);
}
- catch(CycleDetectedException& cde)
+ catch(CycleDetectedException&)
{
result = create_counter_example(bmsc,listener.get_path());
traverser.cleanup_traversing_attributes();
Modified: trunk/src/data/msc.cpp
===================================================================
--- trunk/src/data/msc.cpp 2009-01-14 21:28:47 UTC (rev 169)
+++ trunk/src/data/msc.cpp 2009-01-16 21:39:08 UTC (rev 170)
@@ -270,24 +270,14 @@
MscMessage::MscMessage(MscMessage* original):
MscElementTmpl<MscMessage>(original)
{
-}
-
-MscMessage::~MscMessage()
-{
-}
-
-const std::string& MscMessage::get_label() const
-{
- if(get_original())
+ if(original)
{
- return get_original()->get_label();
+ m_label = original->get_label();
}
- return m_label;
}
-void MscMessage::set_label(const std::string& label)
+MscMessage::~MscMessage()
{
- m_label = label;
}
/////////////////////////////////////////////////////////////////////////////
Modified: trunk/src/data/msc.h
===================================================================
--- trunk/src/data/msc.h 2009-01-14 21:28:47 UTC (rev 169)
+++ trunk/src/data/msc.h 2009-01-16 21:39:08 UTC (rev 170)
@@ -385,14 +385,16 @@
/**
* Getter for m_label
*/
- void set_label(const std::string label) {
+ void set_label(const std::string label)
+ {
m_label = label;
}
/**
* Setter for m_label
*/
- const std::string& get_label() {
+ const std::string& get_label()
+ {
return m_label;
}
@@ -949,10 +951,6 @@
*/
const std::string& get_label()
{
- if(get_original())
- {
- return get_original()->get_label();
- }
return m_label;
}
@@ -1049,10 +1047,16 @@
virtual ~MscMessage();
- const std::string& get_label() const;
-
- void set_label(const std::string& label);
+ const std::string& get_label() const
+ {
+ return m_label;
+ }
+ void set_label(const std::string& label)
+ {
+ m_label = label;
+ }
+
/**
* Determines if the message is correctly glued to events.
*/
Modified: trunk/src/view/visio/addon/addon.cpp
===================================================================
--- trunk/src/view/visio/addon/addon.cpp 2009-01-14 21:28:47 UTC (rev 169)
+++ trunk/src/view/visio/addon/addon.cpp 2009-01-16 21:39:08 UTC (rev 170)
@@ -41,10 +41,10 @@
CStudioAddon scstudio(_T(ADDON_NAME), IDS_ADDON_NAME);
-const short visEvtPageAdded = Visio::visEvtAdd | Visio::visEvtPage;
-const short visEvtBeforeDocumentClose = Visio::visEvtDel | Visio::visEvtDoc;
-const short visEvtConnectionsAdded = Visio::visEvtAdd | Visio::visEvtConnect;
-const short visEvtConnectionsDeleted = Visio::visEvtDel | Visio::visEvtConnect;
+const unsigned short visEvtPageAdded = Visio::visEvtAdd | Visio::visEvtPage;
+const unsigned short visEvtBeforeDocumentClose = Visio::visEvtDel | Visio::visEvtDoc;
+const unsigned short visEvtConnectionsAdded = Visio::visEvtAdd | Visio::visEvtConnect;
+const unsigned short visEvtConnectionsDeleted = Visio::visEvtDel | Visio::visEvtConnect;
CStudioAddon::CStudioAddon(LPCTSTR pName, UINT uIDLocalName)
: VAddon(VAO_AOATTS_ISACTION | VAO_AOATTS_HASABOUT, VAO_ENABLEALWAYS, 0, 0, pName, uIDLocalName)
@@ -407,7 +407,7 @@
Visio::IVEventPtr vsoDocumentOpenEvent = NULL;
Visio::IVEventListPtr vsoDocumentEventList = vsoDocument->EventList;
- for(int i = 1; i <= vsoDocumentEventList->Count; i++)
+ for(short i = 1; i <= vsoDocumentEventList->Count; i++)
{
Visio::IVEventPtr vsoEvent = vsoDocumentEventList->Item[i];
Modified: trunk/src/view/visio/addon/extract.cpp
===================================================================
--- trunk/src/view/visio/addon/extract.cpp 2009-01-14 21:28:47 UTC (rev 169)
+++ trunk/src/view/visio/addon/extract.cpp 2009-01-16 21:39:08 UTC (rev 170)
@@ -66,7 +66,7 @@
{
// walk though all user-defined cells
// note: rows are numbered starting with 0
- for(int i = 0; i < shape->RowCount[visSectionUser]; i++)
+ for(short i = 0; i < shape->RowCount[visSectionUser]; i++)
{
Visio::IVCellPtr cell = shape->CellsSRC[visSectionUser][visRowUser+i][visUserValue];
if(cell == NULL)
@@ -974,11 +974,9 @@
Visio::IVConnectPtr connect1 = line->Connects->Item[1];
Visio::IVShapePtr shape1 = connect1->ToSheet;
- TShapeType shape1_type = get_shape_type(shape1);
Visio::IVConnectPtr connect2 = line->Connects->Item[2];
Visio::IVShapePtr shape2 = connect2->ToSheet;
- TShapeType shape2_type = get_shape_type(shape2);
// determine to what edges is this connector attached
TConnectedPart dir1 = get_connected_part(connect1);
Modified: trunk/src/view/visio/addon/reportview.cpp
===================================================================
--- trunk/src/view/visio/addon/reportview.cpp 2009-01-14 21:28:47 UTC (rev 169)
+++ trunk/src/view/visio/addon/reportview.cpp 2009-01-16 21:39:08 UTC (rev 170)
@@ -37,7 +37,7 @@
}
static DWORD CALLBACK
-EditStreamCallBack(DWORD dwCookie, LPBYTE pbBuff, LONG cb, LONG *pcb)
+EditStreamCallBack(DWORD_PTR dwCookie, LPBYTE pbBuff, LONG cb, LONG *pcb)
{
const char **ppstr = (const char**)dwCookie;
@@ -93,7 +93,7 @@
const char *pstr = sstr.c_str();
- EDITSTREAM es = {(DWORD)&pstr, 0, EditStreamCallBack};
+ EDITSTREAM es = {(DWORD_PTR)&pstr, 0, EditStreamCallBack};
// append RTF to the list
StreamIn(SF_RTF | SFF_SELECTION, es);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ba...@us...> - 2009-01-17 15:36:40
|
Revision: 172
http://scstudio.svn.sourceforge.net/scstudio/?rev=172&view=rev
Author: babicaj
Date: 2009-01-17 15:36:32 +0000 (Sat, 17 Jan 2009)
Log Message:
-----------
livelock_checker returns proper counter example
Modified Paths:
--------------
trunk/src/check/liveness/livelock_checker.cpp
trunk/src/data/msc.h
trunk/src/data/refnode_finder.cpp
trunk/src/data/refnode_finder.h
Modified: trunk/src/check/liveness/livelock_checker.cpp
===================================================================
--- trunk/src/check/liveness/livelock_checker.cpp 2009-01-16 22:29:45 UTC (rev 171)
+++ trunk/src/check/liveness/livelock_checker.cpp 2009-01-17 15:36:32 UTC (rev 172)
@@ -18,6 +18,7 @@
#include "check/liveness/livelock_checker.h"
#include "data/dfs_refnode_hmsc_traverser.h"
+#include "check/pseudocode/msc_duplicators.h"
const std::string ATTRIBUTE_REACHABLE = "LL_reachable";
@@ -110,8 +111,59 @@
HMscPtr LivelockChecker::create_counter_example(const MscElementPListList& path)
{
- HMscPtr e = HMscPtr(new HMsc("Erroneous path"));
- return e;
+ HMscPtr example;
+ MscElementPListList::const_iterator h;
+ MscElementPListList complete_path;
+ ReferenceNodeFinder finder;
+ //path doesn't contain connection nodes and relations -- find them
+ for(h=path.begin();h!=path.end();h++)
+ {
+ complete_path.push_back(MscElementPList());
+ MscElementPList::const_iterator e;
+ for(e=(*h).begin();e!=(*h).end();e++)
+ {
+ if(e==(*h).begin())
+ {
+ complete_path.back().push_back(*e);
+ }
+ else
+ {
+ finder.find_node(
+ dynamic_cast<HMscNode*>(complete_path.back().back()),
+ dynamic_cast<HMscNode*>(*e));
+ const MscElementPList& node_path = *(finder.get_reached_elements().begin());
+ if(node_path.size()>1)
+ {
+ complete_path.back().insert(
+ complete_path.back().end(),
+ ++node_path.begin(),
+ node_path.end()
+ );
+ }
+ finder.cleanup_traversing_attributes();
+ }
+ }
+ }
+ HMscPathDuplicator duplicator;
+ example = duplicator.duplicate_path(complete_path);
+ //mark last node in each hmsc if it is reference node
+ for(h=complete_path.begin();h!=complete_path.end();h++)
+ {
+ MscElement* last = (*h).back();
+ duplicator.get_copy(last)->set_marked(true);
+ }
+ //mark cycle in last hmsc
+ MscElementPList::const_iterator e=complete_path.back().begin();
+ while(*e!=complete_path.back().back())
+ {
+ e++;
+ }
+ while(e!=complete_path.back().end())
+ {
+ duplicator.get_copy(*e)->set_marked(true);
+ e++;
+ }
+ return example;
}
LivelockCheckerPtr LivelockChecker::instance()
Modified: trunk/src/data/msc.h
===================================================================
--- trunk/src/data/msc.h 2009-01-16 22:29:45 UTC (rev 171)
+++ trunk/src/data/msc.h 2009-01-17 15:36:32 UTC (rev 172)
@@ -314,7 +314,7 @@
* and the newly created one. Therefore algorithms keep this relation in this
* attribute.
*/
- T* m_original;
+ boost::intrusive_ptr<T> m_original;
/**
* \brief Creates MscElement referencing the original one.
@@ -333,7 +333,7 @@
*/
T* get_original() const
{
- return m_original;
+ return m_original.get();
}
/**
@@ -344,6 +344,14 @@
m_original = e;
}
+ /**
+ * Setter for m_original.
+ */
+ void set_original(boost::intrusive_ptr<T>& e)
+ {
+ m_original = e;
+ }
+
virtual ~MscElementTmpl()
{
Modified: trunk/src/data/refnode_finder.cpp
===================================================================
--- trunk/src/data/refnode_finder.cpp 2009-01-16 22:29:45 UTC (rev 171)
+++ trunk/src/data/refnode_finder.cpp 2009-01-17 15:36:32 UTC (rev 172)
@@ -72,4 +72,40 @@
return finder.find_successors(node);
}
+void ReferenceNodeFinder::find_node(HMscNode* start, HMscNode* desired)
+{
+ FindNodeListener l(desired);
+ add_white_node_found_listener(&l);
+ push_top_attributes();
+ set_color(start,GRAY); //set node to GRAY to avoid him to be traversed
+ m_reached_elements.back().push_back(start); //push him on top to simulate it was already traversed
+ PredecessorNode* pred = dynamic_cast<PredecessorNode*>(start);
+ if(pred)
+ {
+ try
+ {
+ traverse_successors(pred);
+ }
+ catch(...)
+ {
+
+ }
+ }
+ remove_white_node_found_listeners();
+}
+
+FindNodeListener::FindNodeListener(HMscNode* desired):
+m_desired(desired)
+{
+
+}
+
+void FindNodeListener::on_white_node_found(HMscNode* n)
+{
+ if(m_desired==n)
+ {
+ throw 1;
+ }
+}
+
// $Id$
Modified: trunk/src/data/refnode_finder.h
===================================================================
--- trunk/src/data/refnode_finder.h 2009-01-16 22:29:45 UTC (rev 171)
+++ trunk/src/data/refnode_finder.h 2009-01-17 15:36:32 UTC (rev 172)
@@ -62,6 +62,20 @@
};
+class FindNodeListener:public WhiteNodeFoundListener
+{
+private:
+
+ HMscNode* m_desired;
+
+public:
+
+ FindNodeListener(HMscNode* desired);
+
+ void on_white_node_found(HMscNode* n);
+
+};
+
/**
* \brief See method traverse(HMscNode* node) for purpose.
*/
@@ -84,6 +98,13 @@
* \brief Creates ReferenceNodeFinder and returns result of find_successors
*/
static HMscNodePListPtr successors(HMscNode* node, const std::string& color_attribute = "rnf_color");
+
+ /**
+ * \brief Finds path from start to desired node
+ *
+ * Found path can be retrieved by get_reached_elements()
+ */
+ void find_node(HMscNode* start, HMscNode* desired);
protected:
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <got...@us...> - 2009-01-29 22:44:13
|
Revision: 178
http://scstudio.svn.sourceforge.net/scstudio/?rev=178&view=rev
Author: gotthardp
Date: 2009-01-29 22:26:55 +0000 (Thu, 29 Jan 2009)
Log Message:
-----------
Enhanced error visualization.
- Displays bMSC with messages and coregions. Do not show general ordering (yet).
- Displays event marking.
- Displays hyperlinks in verification report, so the error can be more easily shown.
Modified Paths:
--------------
trunk/src/data/engmann/engmann.cpp
trunk/src/data/msc.cpp
trunk/src/data/msc.h
trunk/src/view/visio/addon/addon.cpp
trunk/src/view/visio/addon/addon.h
trunk/src/view/visio/addon/dllmodule.rc
trunk/src/view/visio/addon/document.cpp
trunk/src/view/visio/addon/extract.cpp
trunk/src/view/visio/addon/extract.h
trunk/src/view/visio/addon/reportview.cpp
trunk/src/view/visio/addon/reportview.h
trunk/src/view/visio/addon/visualize.cpp
trunk/src/view/visio/addon/visualize.h
trunk/src/view/visio/stencils/Sequence Chart Studio/Basic MSC.vsx
trunk/src/view/visio/stencils/Sequence Chart Studio/MSC.vtx
Modified: trunk/src/data/engmann/engmann.cpp
===================================================================
--- trunk/src/data/engmann/engmann.cpp 2009-01-28 21:09:46 UTC (rev 177)
+++ trunk/src/data/engmann/engmann.cpp 2009-01-29 22:26:55 UTC (rev 178)
@@ -129,8 +129,8 @@
static const Coordinate x_step = 30; // distance between instances [mm]
Coordinate current_x = 10;
- static const Coordinate y_step = 5; // distance between messages [mm]
- Coordinate current_y = 5;
+ static const Coordinate y_step = 7.5; // distance between messages [mm]
+ Coordinate current_y = 7.5;
while(stream.good())
{
@@ -152,6 +152,7 @@
// create new instance
InstancePtr inst = new Instance(node_name.text);
+ inst->set_width(10);
inst->set_line_begin(Point(current_x,5));
result->add_instance(inst);
@@ -179,10 +180,10 @@
CompleteMessagePtr message = new CompleteMessage(message_label);
EventPtr from_event = from_area->add_event();
- from_event->set_y(current_y);
+ from_event->set_position(Point(0,current_y));
EventPtr to_event = to_area->add_event();
- to_event->set_y(current_y);
+ to_event->set_position(Point(0,current_y));
message->glue_events(from_event, to_event);
}
Modified: trunk/src/data/msc.cpp
===================================================================
--- trunk/src/data/msc.cpp 2009-01-28 21:09:46 UTC (rev 177)
+++ trunk/src/data/msc.cpp 2009-01-29 22:26:55 UTC (rev 178)
@@ -37,7 +37,7 @@
m_line = line;
}
-const PolyLine& NodeRelation::get_line()
+const PolyLine& NodeRelation::get_line() const
{
return m_line;
}
@@ -168,7 +168,7 @@
get_coregion_area()->add_minimal_event(e->get_successor());
}
-CoregionArea* CoregionEvent::get_coregion_area()
+CoregionArea* CoregionEvent::get_coregion_area() const
{
return dynamic_cast<CoregionArea*>(m_area);
}
@@ -248,6 +248,7 @@
Instance::Instance(const std::string& label, const std::string& kind):
MscElementTmpl<Instance>(NULL),m_label(label),m_kind(kind)
{
+ m_width = 0;
}
Instance::Instance(Instance* original):MscElementTmpl<Instance>(original)
@@ -284,7 +285,8 @@
IncompleteMessage::IncompleteMessage(IncompleteMessage* original):MscMessage(original)
{
- m_type = original->get_type();
+ m_dot_position = original->m_dot_position;
+ m_type = original->m_type;
}
void IncompleteMessage::glue_event(const EventPtr& event)
Modified: trunk/src/data/msc.h
===================================================================
--- trunk/src/data/msc.h 2009-01-28 21:09:46 UTC (rev 177)
+++ trunk/src/data/msc.h 2009-01-29 22:26:55 UTC (rev 178)
@@ -257,7 +257,7 @@
}
}
- bool get_marked()
+ bool get_marked() const
{
return m_marked;
}
@@ -401,7 +401,7 @@
/**
* Setter for m_label
*/
- const std::string& get_label()
+ const std::string& get_label() const
{
return m_label;
}
@@ -446,7 +446,7 @@
/**
* Getter for m_instances.
*/
- const InstancePtrList& get_instances()
+ const InstancePtrList& get_instances() const
{
return m_instances;
}
@@ -481,12 +481,12 @@
/**
* Getter of m_label
*/
- const std::string& get_label()
+ const std::string& get_label() const
{
return m_label;
}
- HMsc* get_owner()
+ HMsc* get_owner() const
{
return m_owner;
}
@@ -496,11 +496,16 @@
m_owner = owner;
}
- Point& get_position()
+ const Point& get_position() const
{
return m_position;
}
+ void set_position(const Point& position)
+ {
+ m_position = position;
+ }
+
HMscNodePtr my_ptr();
virtual ~HMscNode()
@@ -526,12 +531,12 @@
m_predecessor = NULL;
}
- SuccessorNode* get_successor()
+ SuccessorNode* get_successor() const
{
return m_successor;
}
- PredecessorNode* get_predecessor()
+ PredecessorNode* get_predecessor() const
{
return m_predecessor;
}
@@ -550,7 +555,7 @@
void set_line(const PolyLine& line);
- const PolyLine& get_line();
+ const PolyLine& get_line() const;
};
typedef boost::intrusive_ptr<NodeRelation> NodeRelationPtr;
@@ -578,7 +583,7 @@
/**
* Getter for m_predecessors.
*/
- const NodeRelationPtrSet& get_predecessors()
+ const NodeRelationPtrSet& get_predecessors() const
{
return m_predecessors;
}
@@ -634,7 +639,7 @@
/**
* Getter for m_successors.
*/
- const NodeRelationPtrSet& get_successors()
+ const NodeRelationPtrSet& get_successors() const
{
return m_successors;
}
@@ -746,7 +751,7 @@
/**
* Getter for m_start.
*/
- StartNodePtr get_start()
+ StartNodePtr get_start() const
{
return m_start;
}
@@ -757,7 +762,7 @@
m_start->set_owner(this);
}
- const HMscNodePtrSet& get_nodes()
+ const HMscNodePtrSet& get_nodes() const
{
return m_nodes;
}
@@ -812,7 +817,7 @@
/**
* Getter for m_msc.
*/
- MscPtr get_msc()
+ MscPtr get_msc() const
{
return m_msc;
}
@@ -830,7 +835,7 @@
*
* If not successfull undefined HMscPtr is returned.
*/
- HMscPtr get_hmsc()
+ HMscPtr get_hmsc() const
{
return boost::dynamic_pointer_cast<HMsc>(m_msc);
}
@@ -840,7 +845,7 @@
*
* If not successfull undefined BMscPtr is returned.
*/
- BMscPtr get_bmsc()
+ BMscPtr get_bmsc() const
{
return boost::dynamic_pointer_cast<BMsc>(m_msc);
}
@@ -934,7 +939,7 @@
}
- InstanceAxisForm get_form()
+ InstanceAxisForm get_form() const
{
return m_form;
}
@@ -949,7 +954,7 @@
/**
* Getter for m_first.
*/
- EventAreaPtr get_first()
+ EventAreaPtr get_first() const
{
return m_first;
}
@@ -957,7 +962,7 @@
/**
* Getter for m_label.
*/
- const std::string& get_label()
+ const std::string& get_label() const
{
return m_label;
}
@@ -967,7 +972,7 @@
m_last = a;
}
- EventAreaPtr get_last()
+ EventAreaPtr get_last() const
{
return m_last;
}
@@ -985,7 +990,7 @@
m_bmsc = bmsc;
}
- Point get_line_begin() const
+ const Point& get_line_begin() const
{
return m_line_begin;
}
@@ -995,7 +1000,7 @@
m_line_begin = line_begin;
}
- Point get_line_end() const
+ const Point& get_line_end() const
{
return m_line_end;
}
@@ -1194,11 +1199,16 @@
IncompleteMessage(IncompleteMessage* original);
- Point& get_dot_position()
+ const Point& get_dot_position() const
{
return m_dot_position;
}
+ void set_dot_position(const Point& dot_position)
+ {
+ m_dot_position = dot_position;
+ }
+
const std::string& get_instance_label() const
{
return m_instance_label;
@@ -1236,10 +1246,13 @@
{
protected:
-
- Coordinate m_y;
/**
+ * Relative position of the event to the respective instance/area.
+ */
+ Point m_position;
+
+ /**
* Label of message whose this is send or receive event.
*/
MscMessagePtr m_message;
@@ -1252,7 +1265,7 @@
{
if(original)
{
- m_y = original->get_y();
+ m_position = original->m_position;
}
}
@@ -1289,7 +1302,7 @@
* Return instance of CompleteMessage in case m_message contains the instance,
* undefined NULL otherwise
*/
- CompleteMessagePtr get_complete_message()
+ CompleteMessagePtr get_complete_message() const
{
return boost::dynamic_pointer_cast<CompleteMessage>(m_message);
}
@@ -1298,7 +1311,7 @@
* Return instance of CompleteMessage in case m_message contains the instance,
* undefined NULL otherwise
*/
- IncompleteMessagePtr get_incomplete_message()
+ IncompleteMessagePtr get_incomplete_message() const
{
return boost::dynamic_pointer_cast<IncompleteMessage>(m_message);
}
@@ -1307,7 +1320,7 @@
* Retrives matching event of this Event in case this Event has complete
* message, otherwise it returns NULL
*/
- Event* get_matching_event()
+ Event* get_matching_event() const
{
if(is_matched())
{
@@ -1402,14 +1415,14 @@
}
}
- Coordinate set_y(Coordinate y)
+ void set_position(const Point& position)
{
- return m_y = y;
+ m_position = position;
}
- Coordinate get_y()
+ const Point& get_position() const
{
- return m_y;
+ return m_position;
}
};
@@ -1440,7 +1453,7 @@
/**
* Returns EventArea which this Event occures in
*/
- TArea* get_area()
+ TArea* get_area() const
{
return m_area;
}
@@ -1501,7 +1514,7 @@
/**
* Getter for m_successor.
*/
- StrictEventPtr get_successor()
+ StrictEventPtr get_successor() const
{
return m_successor;
}
@@ -1509,7 +1522,7 @@
/**
* Getter for predecessor.
*/
- StrictEvent* get_predecessor()
+ StrictEvent* get_predecessor() const
{
return m_predecessor;
}
@@ -1561,12 +1574,12 @@
m_line = line;
}
- CoregionEvent* get_predecessor()
+ CoregionEvent* get_predecessor() const
{
return m_predecessor;
}
- CoregionEvent* get_successor()
+ CoregionEvent* get_successor() const
{
return m_successor;
}
@@ -1616,7 +1629,7 @@
/**
* Getter for m_successors
*/
- const CoregEventRelPtrSet& get_successors()
+ const CoregEventRelPtrSet& get_successors() const
{
return m_successors;
}
@@ -1624,7 +1637,7 @@
/**
* Getter for m_predecessors
*/
- const CoregEventRelPtrSet& get_predecessors()
+ const CoregEventRelPtrSet& get_predecessors() const
{
return m_predecessors;
}
@@ -1656,7 +1669,7 @@
/**
* Getter for m_area
*/
- CoregionArea* get_coregion_area();
+ CoregionArea* get_coregion_area() const;
bool is_minimal()
{
@@ -1693,8 +1706,11 @@
*/
EventArea* m_previous;
- Size m_height;
-
+ Coordinate m_begin_height;
+ Coordinate m_end_height;
+
+ Size m_width;
+
/**
* Instance which EventArea occures on
*
@@ -1710,7 +1726,8 @@
{
if(original)
{
- m_height = original->get_height();
+ m_begin_height = original->m_begin_height;
+ m_end_height = original->m_end_height;
}
}
@@ -1729,7 +1746,7 @@
/**
* Getter for m_next
*/
- EventAreaPtr get_next()
+ EventAreaPtr get_next() const
{
return m_next;
}
@@ -1750,7 +1767,7 @@
/**
* Getter for m_previous
*/
- EventArea* get_previous()
+ EventArea* get_previous() const
{
return m_previous;
}
@@ -1768,16 +1785,41 @@
return m_previous==NULL;
}
- Size get_height()
+ const Coordinate& get_begin_height() const
{
- return m_height;
+ return m_begin_height;
}
- void set_height(Size height)
+ void set_begin_height(const Coordinate& begin_height)
{
- m_height=height;
+ m_begin_height = begin_height;
}
+ const Coordinate& get_end_height() const
+ {
+ return m_end_height;
+ }
+
+ void set_end_height(const Coordinate& end_height)
+ {
+ m_end_height = end_height;
+ }
+
+ Size get_height() const
+ {
+ return fabs(m_end_height - m_begin_height);
+ }
+
+ Size get_width() const
+ {
+ return m_width;
+ }
+
+ void set_width(const Size& width)
+ {
+ m_width = width;
+ }
+
/**
* Adds event into this area. The added event is returned.
*/
@@ -1819,7 +1861,7 @@
/**
* Getter for m_first.
*/
- StrictEventPtr get_first()
+ StrictEventPtr get_first() const
{
return m_first;
}
@@ -1841,7 +1883,7 @@
/**
* Getter for m_first.
*/
- StrictEventPtr get_last()
+ StrictEventPtr get_last() const
{
return m_last;
}
@@ -1937,7 +1979,7 @@
/**
* Getter for m_minimal_events.
*/
- const CoregionEventPSet& get_minimal_events()
+ const CoregionEventPSet& get_minimal_events() const
{
return m_minimal_events;
}
@@ -1945,7 +1987,7 @@
/**
* Getter for m_maximal_events.
*/
- const CoregionEventPSet& get_maximal_events()
+ const CoregionEventPSet& get_maximal_events() const
{
return m_maximal_events;
}
@@ -1991,7 +2033,7 @@
return m_minimal_events.size()==0;
}
- const CoregionEventPtrSet& get_events()
+ const CoregionEventPtrSet& get_events() const
{
return m_events;
}
@@ -2018,7 +2060,7 @@
return e;
}
- InstanceAxisForm get_form()
+ InstanceAxisForm get_form() const
{
return m_form;
}
Modified: trunk/src/view/visio/addon/addon.cpp
===================================================================
--- trunk/src/view/visio/addon/addon.cpp 2009-01-28 21:09:46 UTC (rev 177)
+++ trunk/src/view/visio/addon/addon.cpp 2009-01-29 22:26:55 UTC (rev 178)
@@ -21,6 +21,7 @@
#include "addon.h"
#include "aboutdlg.h"
#include "document.h"
+#include "extract.h"
#include "errors.h"
#include "resource.h"
@@ -41,8 +42,9 @@
CStudioAddon scstudio(_T(ADDON_NAME), IDS_ADDON_NAME);
+const unsigned short visEvtBeforeDocumentClose = Visio::visEvtDel | Visio::visEvtDoc;
const unsigned short visEvtPageAdded = Visio::visEvtAdd | Visio::visEvtPage;
-const unsigned short visEvtBeforeDocumentClose = Visio::visEvtDel | Visio::visEvtDoc;
+const unsigned short visEvtCellChanged = Visio::visEvtMod | Visio::visEvtCell;
const unsigned short visEvtConnectionsAdded = Visio::visEvtAdd | Visio::visEvtConnect;
const unsigned short visEvtConnectionsDeleted = Visio::visEvtDel | Visio::visEvtConnect;
@@ -335,7 +337,6 @@
IUnknown *ipSink, short nEventCode, IDispatch *pSourceObj, long nEventID,
long nEventSeqNum, IDispatch *pSubjectObj, VARIANT vMoreInfo, VARIANT *pvResult)
{
- TRACE("CStudioAddon::HandleVisioEvent() called");
try
{
if (ipSink == NULL || pSourceObj == NULL || pSubjectObj == NULL || pvResult == NULL)
@@ -344,27 +345,31 @@
return E_FAIL;
}
- switch (nEventCode)
+ unsigned short event = nEventCode;
+ switch (event)
{
+ case visEvtBeforeDocumentClose:
+ TRACE("CStudioAddon::HandleVisioEvent() visEvtBeforeDocumentClose");
+ break;
case visEvtPageAdded:
TRACE("CStudioAddon::HandleVisioEvent() visEvtPageAdded");
break;
- case visEvtBeforeDocumentClose:
- TRACE("CStudioAddon::HandleVisioEvent() visEvtBeforeDocumentClose");
+ case visEvtCellChanged:
+ HandleCellChanged(pSubjectObj);
break;
case visEvtConnectionsAdded:
TRACE("CStudioAddon::HandleVisioEvent() visEvtConnectionsAdded");
HandleConnectionsAdded(pSubjectObj);
break;
-
case visEvtConnectionsDeleted:
TRACE("CStudioAddon::HandleVisioEvent() visEvtConnectionsDeleted");
break;
default:
- TRACE("CStudioAddon::HandleVisioEvent() unexpected event id=" << nEventCode);
+ TRACE("CStudioAddon::HandleVisioEvent() unexpected event id="
+ << std::ios::hex << event);
break;
}
@@ -377,6 +382,30 @@
}
}
+void CStudioAddon::HandleCellChanged(Visio::IVCellPtr vsoCell)
+{
+ if(vsoCell->Section == visSectionControls)
+ {
+ // note: to keep stencil compatibility, the names must not be changed
+ if(_tcsicmp(vsoCell->RowName, _T("mscHeadWidth")) == 0 && vsoCell->Column == visCtlY)
+ {
+ double value = vsoCell->ResultIU;
+ TRACE("CStudioAddon::HandleCellChanged() mscHeadWidth changed to " << value);
+
+ Visio::IVShapePtr vsoShape = vsoCell->Shape;
+ // walk through connected shapes
+ for(int i = 1; i <= vsoShape->FromConnects->Count; i++)
+ {
+ Visio::IVConnectPtr fromConnect = vsoShape->FromConnects->Item[i];
+ // change width of all coregion boxes
+ // note: the coregion is rotated by 90', width is the 'y' coordinate
+ if(get_shape_type(fromConnect->FromSheet) == ST_BMSC_COREGION)
+ fromConnect->FromSheet->CellsSRC[visSectionObject][visRowXFormOut][visXFormHeight]->ResultIU = value*2;
+ }
+ }
+ }
+}
+
void CStudioAddon::HandleConnectionsAdded(Visio::IVConnectsPtr vsoConnects)
{
// dynamic connectors are positioned on Width*X
@@ -472,14 +501,14 @@
pDocumentMonitor = new CDocumentMonitor(this, vsoApp, vsoDocument);
pDocumentMonitor->InitMenu(vsoApp);
+ // register BeforeDocumentClose
+ vsoEvent = vsoDocumentEventList->AddAdvise(visEvtBeforeDocumentClose, varSink, _T(""), _T(""));
+ pDocumentMonitor->m_vsoBeforeDocumentClosedEvent = vsoEvent;
// register PageAdded
vsoEvent = vsoDocumentEventList->AddAdvise(visEvtPageAdded, varSink, _T(""), _T(""));
pDocumentMonitor->m_vsoPageAddedEvent = vsoEvent;
-
- // register BeforeDocumentClose
- vsoEvent = vsoDocumentEventList->AddAdvise(visEvtBeforeDocumentClose, varSink, _T(""), _T(""));
- pDocumentMonitor->m_vsoBeforeDocumentClosedEvent = vsoEvent;
+ vsoDocumentEventList->AddAdvise(visEvtCellChanged, varSink, _T(""), _T("CellChanged"));
vsoDocumentEventList->AddAdvise(visEvtConnectionsAdded, varSink, _T(""), _T("ConnectionsAdded"));
vsoDocumentEventList->AddAdvise(visEvtConnectionsDeleted, varSink, _T(""), _T("ConnectionsDeleted"));
Modified: trunk/src/view/visio/addon/addon.h
===================================================================
--- trunk/src/view/visio/addon/addon.h 2009-01-28 21:09:46 UTC (rev 177)
+++ trunk/src/view/visio/addon/addon.h 2009-01-29 22:26:55 UTC (rev 178)
@@ -44,6 +44,7 @@
VARIANT vMoreInfo, // [in] other info
VARIANT *pvResult); // [retval][out] return a value to Visio for query events
+ void HandleCellChanged(Visio::IVCellPtr vsoCell);
void HandleConnectionsAdded(Visio::IVConnectsPtr vsoConnects);
void RegisterPersistentEvents(Visio::IVDocumentPtr vsoDocument);
Modified: trunk/src/view/visio/addon/dllmodule.rc
===================================================================
--- trunk/src/view/visio/addon/dllmodule.rc 2009-01-28 21:09:46 UTC (rev 177)
+++ trunk/src/view/visio/addon/dllmodule.rc 2009-01-29 22:26:55 UTC (rev 178)
@@ -72,8 +72,8 @@
//
VS_VERSION_INFO VERSIONINFO
- FILEVERSION 0,1,3,0
- PRODUCTVERSION 0,1,3,0
+ FILEVERSION 0,1,6,0
+ PRODUCTVERSION 0,1,6,0
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x9L
@@ -90,13 +90,13 @@
BEGIN
VALUE "CompanyName", "Masaryk University Brno"
VALUE "FileDescription", "Microsoft Visio add-on for design and verification of Message Sequence Charts (MSC)."
- VALUE "FileVersion", "0.1.3"
+ VALUE "FileVersion", "0.1.6"
VALUE "InternalName", "scstudio.vsl"
VALUE "LegalCopyright", "(c) Petr Gotthard. All rights reserved."
VALUE "OriginalFilename", "scstudio.vsl"
VALUE "PrivateBuild", "$Revision$"
VALUE "ProductName", "Sequence Chart Studio"
- VALUE "ProductVersion", "0.1.3"
+ VALUE "ProductVersion", "0.1.6"
END
END
BLOCK "VarFileInfo"
Modified: trunk/src/view/visio/addon/document.cpp
===================================================================
--- trunk/src/view/visio/addon/document.cpp 2009-01-28 21:09:46 UTC (rev 177)
+++ trunk/src/view/visio/addon/document.cpp 2009-01-29 22:26:55 UTC (rev 178)
@@ -290,7 +290,7 @@
if(result != NULL)
{
m_reportView->Print(RS_ERROR, stringize()
- << (*cpos)->get_description() << " violated. [details]", result);
+ << (*cpos)->get_description() << " violated.", result);
violated_count++;
}
else
@@ -545,19 +545,16 @@
Visio::IVWindowPtr vsoWindow = vsoApp->GetActiveWindow();
const int defWidth = 500;
- const int defHeight = 200;
+ const int defHeight = 150;
m_reportWindow = vsoWindow->Windows->Add(LoadStringResource(IDS_REPORT_VIEW),
Visio::visWSVisible | Visio::visWSAnchorLeft, Visio::visAnchorBarAddon, 1, 1, defWidth, defHeight);
- LoadLibrary(CReportView::GetLibraryName());
+ LoadLibrary(CRichEditCtrl::GetLibraryName());
RECT rc = {0, 0, defWidth, defHeight};
- HWND hwndTV = m_reportView->Create(
- (HWND)m_reportWindow->WindowHandle,
+ HWND hwndTV = m_reportView->Create((HWND)m_reportWindow->WindowHandle,
rc, NULL,
- WS_CHILD | WS_VISIBLE | WS_VSCROLL | WS_HSCROLL |
- ES_MULTILINE | ES_AUTOVSCROLL | ES_AUTOHSCROLL | ES_READONLY,
- WS_EX_STATICEDGE);
+ WS_CHILD | WS_VISIBLE | WS_CLIPCHILDREN | WS_CLIPSIBLINGS);
m_reportMenuItem->State = Visio::visButtonDown;
m_vsoDocument->CustomMenus->UpdateUI();
Modified: trunk/src/view/visio/addon/extract.cpp
===================================================================
--- trunk/src/view/visio/addon/extract.cpp 2009-01-28 21:09:46 UTC (rev 177)
+++ trunk/src/view/visio/addon/extract.cpp 2009-01-29 22:26:55 UTC (rev 178)
@@ -62,7 +62,7 @@
return NULL;
}
-CDrawingExtractor::TShapeType CDrawingExtractor::get_shape_type(Visio::IVShapePtr shape)
+TShapeType get_shape_type(Visio::IVShapePtr shape)
{
// walk though all user-defined cells
// note: rows are numbered starting with 0
@@ -156,6 +156,29 @@
return SPoint(posx->Result[visMillimeters], posy->Result[visMillimeters]);
}
+inline double align5(double mm)
+{
+ return floor(mm/5)*5;
+}
+
+Point CDrawingExtractor::GetLineBegin(Visio::IVShapePtr shape)
+{
+ double page_height = align5(shape->ContainingPage->PageSheet->CellsSRC[visSectionObject][visRowPage][visPageHeight]->Result[visMillimeters]);
+
+ return Point(
+ shape->CellsSRC[visSectionObject][visRowXForm1D][vis1DBeginX]->Result[visMillimeters],
+ page_height - shape->CellsSRC[visSectionObject][visRowXForm1D][vis1DBeginY]->Result[visMillimeters]);
+}
+
+Point CDrawingExtractor::GetLineEnd(Visio::IVShapePtr shape)
+{
+ double page_height = align5(shape->ContainingPage->PageSheet->CellsSRC[visSectionObject][visRowPage][visPageHeight]->Result[visMillimeters]);
+
+ return Point(
+ shape->CellsSRC[visSectionObject][visRowXForm1D][vis1DEndX]->Result[visMillimeters],
+ page_height - shape->CellsSRC[visSectionObject][visRowXForm1D][vis1DEndY]->Result[visMillimeters]);
+}
+
void CDrawingExtractor::assert_no_nested_FromConnects(Visio::IVShapePtr shape)
{
for(int i = 1; i <= shape->Shapes->Count; i++)
@@ -214,6 +237,8 @@
continue;
// create coregion event
event = area->add_event(new CoregionEvent());
+ // note: instances in Visio are rotated by 90', height is the 'x' coordinate
+ event->set_position(Point(pos.m_y,pos.m_x));
// connect the message
switch(connect->FromPart)
{
@@ -238,8 +263,11 @@
IncompleteMessagePtr message = find_message<IncompleteMessage>(messages, shape->ID);
if(message == NULL)
continue;
+ // lost message: glued on begin, dot on end
+ message->set_dot_position(GetLineEnd(shape));
// create coregion event
event = area->add_event(new CoregionEvent());
+ event->set_position(Point(pos.m_y,pos.m_x));
// connect the message
if(connect->FromPart == visBegin)
message->glue_event(event);
@@ -257,8 +285,11 @@
IncompleteMessagePtr message = find_message<IncompleteMessage>(messages, shape->ID);
if(message == NULL)
continue;
+ // found message: glued on end, dot on begin
+ message->set_dot_position(GetLineBegin(shape));
// create coregion event
event = area->add_event(new CoregionEvent());
+ event->set_position(Point(pos.m_y,pos.m_x));
// connect the message
if(connect->FromPart == visEnd)
message->glue_event(event);
@@ -364,23 +395,24 @@
return area;
}
-inline double align5(double mm)
+InstancePtr CDrawingExtractor::new_instance_ptr(Visio::IVShapePtr shape)
{
- return floor(mm/5)*5;
-}
+ InstancePtr result = new Instance((const char*)shape->Text);
-InstancePtr new_instance_ptr(Visio::IVShapePtr shape)
-{
- double page_height = align5(shape->ContainingPage->PageSheet->CellsSRC[visSectionObject][visRowPage][visPageHeight]->Result[visMillimeters]);
+ result->set_line_begin(GetLineBegin(shape));
+ result->set_line_end(GetLineEnd(shape));
- InstancePtr result = new Instance((const char*)shape->Text);
+ // walk though all controls
+ // note: rows are numbered starting with 0
+ for(short i = 0; i < shape->RowCount[visSectionControls]; i++)
+ {
+ Visio::IVCellPtr cell = shape->CellsSRC[visSectionControls][visRowControl+i][visCtlY];
+ if(cell == NULL)
+ continue;
- result->set_line_begin(Point(
- shape->CellsSRC[visSectionObject][visRowXForm1D][vis1DBeginX]->Result[visMillimeters],
- page_height - shape->CellsSRC[visSectionObject][visRowXForm1D][vis1DBeginY]->Result[visMillimeters]));
- result->set_line_end(Point(
- shape->CellsSRC[visSectionObject][visRowXForm1D][vis1DEndX]->Result[visMillimeters],
- page_height - shape->CellsSRC[visSectionObject][visRowXForm1D][vis1DEndY]->Result[visMillimeters]));
+ if(_tcsicmp(cell->RowName, _T("mscHeadWidth")) == 0)
+ result->set_width(2.0*cell->Result[visMillimeters]);
+ }
return result;
}
@@ -473,7 +505,9 @@
SStrictOrder event;
event.shape_id = shape->ID;
event.shape_type = get_shape_type(shape);
- event.event_time = pos.m_x;
+ event.event_offset = pos.m_y;
+ // note: instances in Visio are rotated by 90', height is the 'x' coordinate
+ event.event_height = pos.m_x;
// which shape is connected?
switch(event.shape_type)
@@ -495,7 +529,15 @@
case ST_BMSC_MESSAGE_LOST:
if(connect->FromPart == visBegin)
+ {
+ IncompleteMessagePtr message = find_message<IncompleteMessage>(messages, shape->ID);
+ if(message == NULL)
+ continue;
+ // lost message: glued on begin, dot on end
+ message->set_dot_position(GetLineEnd(shape));
+
event.event_type = SStrictOrder::ET_OUTGOING;
+ }
else
{
PrintError(stringize() << page_name << ": "
@@ -507,7 +549,15 @@
case ST_BMSC_MESSAGE_FOUND:
if(connect->FromPart == visEnd)
+ {
+ IncompleteMessagePtr message = find_message<IncompleteMessage>(messages, shape->ID);
+ if(message == NULL)
+ continue;
+ // found message: glued on end, dot on begin
+ message->set_dot_position(GetLineBegin(shape));
+
event.event_type = SStrictOrder::ET_INCOMING;
+ }
else
{
PrintError(stringize() << page_name << ": "
@@ -566,6 +616,7 @@
} state = ST_EXPECTING_AREA;
StrictOrderAreaPtr strict_area;
+ CoregionAreaPtr coregion_area;
long coregion_id;
// walk though the events in a time-order
@@ -590,7 +641,7 @@
continue;
StrictEventPtr event = strict_area->add_event(new StrictEvent());
- event->set_y(epos->event_time);
+ event->set_position(Point(epos->event_offset, epos->event_height));
if(epos->event_type == SStrictOrder::ET_OUTGOING)
message->glue_send_event(event);
else if(epos->event_type == SStrictOrder::ET_INCOMING)
@@ -621,7 +672,15 @@
if(message == NULL)
continue;
+ if(epos->shape_type == ST_BMSC_MESSAGE_LOST)
+ // lost message: glued on begin, dot on end
+ message->set_dot_position(GetLineEnd(shape));
+ else if(epos->shape_type == ST_BMSC_MESSAGE_FOUND)
+ // found message: glued on end, dot on begin
+ message->set_dot_position(GetLineBegin(shape));
+
StrictEventPtr event = strict_area->add_event(new StrictEvent());
+ event->set_position(Point(epos->event_offset, epos->event_height));
message->glue_event(event);
break;
@@ -643,7 +702,9 @@
case ST_STRICT:
if(epos->event_type == SStrictOrder::ET_OUTGOING)
{
- ipos->second->add_area(create_coregion_area(messages, shape));
+ ipos->second->add_area(coregion_area = create_coregion_area(messages, shape));
+ coregion_area->set_begin_height(epos->event_height);
+ coregion_area->set_width(shape->CellsSRC[visSectionObject][visRowXFormOut][visXFormHeight]->Result[visMillimeters]);
}
else
{
@@ -665,6 +726,7 @@
}
else if(epos->event_type == SStrictOrder::ET_INCOMING)
{
+ coregion_area->set_end_height(epos->event_height);
state = ST_EXPECTING_AREA;
}
else
Modified: trunk/src/view/visio/addon/extract.h
===================================================================
--- trunk/src/view/visio/addon/extract.h 2009-01-28 21:09:46 UTC (rev 177)
+++ trunk/src/view/visio/addon/extract.h 2009-01-29 22:26:55 UTC (rev 178)
@@ -37,6 +37,29 @@
}
};
+enum TShapeType
+{
+ ST_BMSC_INSTANCE,
+ ST_BMSC_MESSAGE,
+ ST_BMSC_MESSAGE_LOST,
+ ST_BMSC_MESSAGE_FOUND,
+ ST_BMSC_COREGION,
+ ST_BMSC_ORDER_LINE,
+ ST_BMSC_ORDER_ARROW,
+ ST_C...
[truncated message content] |
|
From: <got...@us...> - 2009-01-31 16:35:13
|
Revision: 179
http://scstudio.svn.sourceforge.net/scstudio/?rev=179&view=rev
Author: gotthardp
Date: 2009-01-31 16:35:08 +0000 (Sat, 31 Jan 2009)
Log Message:
-----------
Visualization of both basic MSC and HMSC completed.
Modified Paths:
--------------
trunk/src/data/msc.h
trunk/src/view/visio/addon/document.cpp
trunk/src/view/visio/addon/extract.cpp
trunk/src/view/visio/addon/extract.h
trunk/src/view/visio/addon/visualize.cpp
trunk/src/view/visio/addon/visualize.h
Modified: trunk/src/data/msc.h
===================================================================
--- trunk/src/data/msc.h 2009-01-29 22:26:55 UTC (rev 178)
+++ trunk/src/data/msc.h 2009-01-31 16:35:08 UTC (rev 179)
@@ -109,6 +109,21 @@
typedef std::set<HMscNodePtr> HMscNodePtrSet;
+struct nocase_comparator: public std::binary_function<std::string, std::string, bool>
+{
+ struct nocase_compare: public std::binary_function<unsigned char, unsigned char, bool>
+ {
+ bool operator() (const unsigned char& c1, const unsigned char& c2) const
+ { return tolower(c1) < tolower(c2); };
+ };
+
+ bool operator() (const std::string& s1, const std::string& s2) const
+ {
+ return std::lexicographical_compare(
+ s1.begin(), s1.end(), s2.begin(), s2.end(), nocase_compare());
+ }
+};
+
/**
* \brief Common basic abstract class for all elements of MSC
*/
Modified: trunk/src/view/visio/addon/document.cpp
===================================================================
--- trunk/src/view/visio/addon/document.cpp 2009-01-29 22:26:55 UTC (rev 178)
+++ trunk/src/view/visio/addon/document.cpp 2009-01-31 16:35:08 UTC (rev 179)
@@ -307,7 +307,7 @@
if(result != NULL)
{
m_reportView->Print(RS_ERROR, stringize()
- << (*cpos)->get_description() << " violated.");
+ << (*cpos)->get_description() << " violated.", result);
violated_count++;
}
else
@@ -572,8 +572,8 @@
{
MscPtr drawing = formatter->load_msc(stream);
- CDrawingVisualizer visualizer(m_vsoApp->ActivePage);
- visualizer.visualize_msc(drawing);
+ CDrawingVisualizer visualizer(m_vsoApp);
+ visualizer.visualize_msc(m_vsoApp->ActivePage, drawing);
}
void CDocumentMonitor::ExportActiveDocument(const ExportFormatterPtr& formatter, std::ostream& stream)
@@ -620,8 +620,8 @@
{
Visio::IVDocumentPtr vsoDocument = m_vsoApp->GetDocuments()->Add(VST_FILE_NAME);
- CDrawingVisualizer visualizer(vsoDocument->Pages->Item[1]);
- visualizer.visualize_msc(msc);
+ CDrawingVisualizer visualizer(m_vsoApp);
+ visualizer.visualize_msc(vsoDocument->Pages->Item[1], msc);
return 0;
}
Modified: trunk/src/view/visio/addon/extract.cpp
===================================================================
--- trunk/src/view/visio/addon/extract.cpp 2009-01-29 22:26:55 UTC (rev 178)
+++ trunk/src/view/visio/addon/extract.cpp 2009-01-31 16:35:08 UTC (rev 179)
@@ -179,6 +179,15 @@
page_height - shape->CellsSRC[visSectionObject][visRowXForm1D][vis1DEndY]->Result[visMillimeters]);
}
+Point CDrawingExtractor::GetPinPos(Visio::IVShapePtr shape)
+{
+ double page_height = align5(shape->ContainingPage->PageSheet->CellsSRC[visSectionObject][visRowPage][visPageHeight]->Result[visMillimeters]);
+
+ return Point(
+ shape->CellsSRC[visSectionObject][visRowXFormOut][visXFormPinX]->Result[visMillimeters],
+ page_height - shape->CellsSRC[visSectionObject][visRowXFormOut][visXFormPinY]->Result[visMillimeters]);
+}
+
void CDrawingExtractor::assert_no_nested_FromConnects(Visio::IVShapePtr shape)
{
for(int i = 1; i <= shape->Shapes->Count; i++)
@@ -263,8 +272,6 @@
IncompleteMessagePtr message = find_message<IncompleteMessage>(messages, shape->ID);
if(message == NULL)
continue;
- // lost message: glued on begin, dot on end
- message->set_dot_position(GetLineEnd(shape));
// create coregion event
event = area->add_event(new CoregionEvent());
event->set_position(Point(pos.m_y,pos.m_x));
@@ -285,8 +292,6 @@
IncompleteMessagePtr message = find_message<IncompleteMessage>(messages, shape->ID);
if(message == NULL)
continue;
- // found message: glued on end, dot on begin
- message->set_dot_position(GetLineBegin(shape));
// create coregion event
event = area->add_event(new CoregionEvent());
event->set_position(Point(pos.m_y,pos.m_x));
@@ -447,11 +452,21 @@
messages[shape->ID] = new CompleteMessage((const char*)shape->Text);
break;
case ST_BMSC_MESSAGE_LOST:
- messages[shape->ID] = new IncompleteMessage(LOST, (const char*)shape->Text);
+ {
+ IncompleteMessage *new_message = new IncompleteMessage(LOST, (const char*)shape->Text);
+ // lost message: glued on begin, dot on end
+ new_message->set_dot_position(GetLineEnd(shape));
+ messages[shape->ID] = new_message;
break;
+ }
case ST_BMSC_MESSAGE_FOUND:
- messages[shape->ID] = new IncompleteMessage(FOUND, (const char*)shape->Text);
+ {
+ IncompleteMessage *new_message = new IncompleteMessage(FOUND, (const char*)shape->Text);
+ // found message: glued on end, dot on begin
+ new_message->set_dot_position(GetLineBegin(shape));
+ messages[shape->ID] = new_message;
break;
+ }
case ST_BMSC_COREGION:
case ST_BMSC_ORDER_LINE:
@@ -529,15 +544,7 @@
case ST_BMSC_MESSAGE_LOST:
if(connect->FromPart == visBegin)
- {
- IncompleteMessagePtr message = find_message<IncompleteMessage>(messages, shape->ID);
- if(message == NULL)
- continue;
- // lost message: glued on begin, dot on end
- message->set_dot_position(GetLineEnd(shape));
-
event.event_type = SStrictOrder::ET_OUTGOING;
- }
else
{
PrintError(stringize() << page_name << ": "
@@ -549,15 +556,7 @@
case ST_BMSC_MESSAGE_FOUND:
if(connect->FromPart == visEnd)
- {
- IncompleteMessagePtr message = find_message<IncompleteMessage>(messages, shape->ID);
- if(message == NULL)
- continue;
- // found message: glued on end, dot on begin
- message->set_dot_position(GetLineBegin(shape));
-
event.event_type = SStrictOrder::ET_INCOMING;
- }
else
{
PrintError(stringize() << page_name << ": "
@@ -672,13 +671,6 @@
if(message == NULL)
continue;
- if(epos->shape_type == ST_BMSC_MESSAGE_LOST)
- // lost message: glued on begin, dot on end
- message->set_dot_position(GetLineEnd(shape));
- else if(epos->shape_type == ST_BMSC_MESSAGE_FOUND)
- // found message: glued on end, dot on begin
- message->set_dot_position(GetLineBegin(shape));
-
StrictEventPtr event = strict_area->add_event(new StrictEvent());
event->set_position(Point(epos->event_offset, epos->event_height));
message->glue_event(event);
@@ -959,8 +951,14 @@
break;
case ST_HMSC_CONNECTION:
- hmsc->add_node(nodes[shape->ID] = new ConnectionNode());
+ {
+ ConnectionNode *new_connection = new ConnectionNode();
+ new_connection->set_position(GetPinPos(shape));
+
+ hmsc->add_node(new_connection);
+ nodes[shape->ID] = new_connection;
break;
+ }
case ST_HMSC_START:
{
if(hmsc->get_start() != NULL)
@@ -972,16 +970,26 @@
continue;
}
StartNode *new_start = new StartNode();
+ new_start->set_position(GetPinPos(shape));
+
hmsc->set_start(new_start);
nodes[shape->ID] = new_start;
break;
}
case ST_HMSC_END:
- hmsc->add_node(nodes[shape->ID] = new EndNode());
+ {
+ EndNode *new_end = new EndNode();
+ new_end->set_position(GetPinPos(shape));
+
+ hmsc->add_node(new_end);
+ nodes[shape->ID] = new_end;
break;
+ }
case ST_HMSC_REFERENCE:
{
ReferenceNode *new_node = new ReferenceNode();
+ new_node->set_position(GetPinPos(shape));
+
hmsc->add_node(new_node);
nodes[shape->ID] = new_node;
Modified: trunk/src/view/visio/addon/extract.h
===================================================================
--- trunk/src/view/visio/addon/extract.h 2009-01-29 22:26:55 UTC (rev 178)
+++ trunk/src/view/visio/addon/extract.h 2009-01-31 16:35:08 UTC (rev 179)
@@ -22,21 +22,6 @@
#include "data/msc.h"
-struct nocase_comparator: public std::binary_function<std::string, std::string, bool>
-{
- struct nocase_compare: public std::binary_function<unsigned char, unsigned char, bool>
- {
- bool operator() (const unsigned char& c1, const unsigned char& c2) const
- { return tolower(c1) < tolower(c2); };
- };
-
- bool operator() (const std::string& s1, const std::string& s2) const
- {
- return std::lexicographical_compare(
- s1.begin(), s1.end(), s2.begin(), s2.end(), nocase_compare());
- }
-};
-
enum TShapeType
{
ST_BMSC_INSTANCE,
@@ -126,6 +111,7 @@
Point GetLineBegin(Visio::IVShapePtr shape);
Point GetLineEnd(Visio::IVShapePtr shape);
+ Point GetPinPos(Visio::IVShapePtr shape);
//! assert the given shape has no connections to its sub-shapes
void assert_no_nested_FromConnects(Visio::IVShapePtr shape);
Modified: trunk/src/view/visio/addon/visualize.cpp
===================================================================
--- trunk/src/view/visio/addon/visualize.cpp 2009-01-29 22:26:55 UTC (rev 178)
+++ trunk/src/view/visio/addon/visualize.cpp 2009-01-31 16:35:08 UTC (rev 179)
@@ -23,50 +23,82 @@
#include <math.h>
#include <Visconst.h>
-inline double align5(double mm)
+CDrawingVisualizer::CDrawingVisualizer(Visio::IVApplicationPtr vsoApp)
{
- return floor(mm/5)*5;
-}
+ m_vsoApp = vsoApp;
-CDrawingVisualizer::CDrawingVisualizer(Visio::IVPagePtr vsoPage)
-{
- m_page = vsoPage;
- m_page_height = align5(vsoPage->PageSheet->CellsSRC[visSectionObject][visRowPage][visPageHeight]->Result[visMillimeters]);
+ Visio::IVDocumentPtr bmsc_stencil = vsoApp->Documents->Item[BMSC_STENCIL_NAME];
+ m_instance_master = bmsc_stencil->Masters->Item["Line Instance"];
+ m_coregion_master = bmsc_stencil->Masters->Item["Coregion Box"];
+ m_message_master = bmsc_stencil->Masters->Item["Message (Right)"];
+ m_lost_message_master = bmsc_stencil->Masters->Item["Lost Message"];
+ m_found_message_master = bmsc_stencil->Masters->Item["Found Message"];
+ m_ordering_side_side_master = bmsc_stencil->Masters->Item["Ordering Side-Side"];
+ m_ordering_sides_master = bmsc_stencil->Masters->Item["Ordering Sides"];
+ m_ordering_arrow_master = bmsc_stencil->Masters->Item["Ordering Arrow"];
- Visio::IVDocumentPtr stencil = vsoPage->Application->Documents->Item[BMSC_STENCIL_NAME];
- m_instance_master = stencil->Masters->Item["Line Instance"];
- m_coregion_master = stencil->Masters->Item["Coregion Box"];
-
- m_message_master = stencil->Masters->Item["Message (Right)"];
- m_lost_message_master = stencil->Masters->Item["Lost Message"];
- m_found_message_master = stencil->Masters->Item["Found Message"];
+ Visio::IVDocumentPtr hmsc_stencil = vsoApp->Documents->Item[HMSC_STENCIL_NAME];
+ m_start_symbol_master = hmsc_stencil->Masters->Item["Start Symbol"];
+ m_end_symbol_master = hmsc_stencil->Masters->Item["End Symbol"];
+ m_msc_reference_master = hmsc_stencil->Masters->Item["MSC Reference"];
+ m_connection_point_master = hmsc_stencil->Masters->Item["Connection Point"];
+ m_connection_arrow_master = hmsc_stencil->Masters->Item["Connection Arrow"];
}
-void CDrawingVisualizer::visualize_msc(const MscPtr& drawing)
+void CDrawingVisualizer::visualize_msc(Visio::IVPagePtr vsoPage, const MscPtr& drawing)
{
BMscPtr bmsc = boost::dynamic_pointer_cast<BMsc>(drawing);
if(bmsc != NULL)
- visualize_bmsc(bmsc);
+ visualize_bmsc(vsoPage, bmsc);
+ HMscPtr hmsc = boost::dynamic_pointer_cast<HMsc>(drawing);
+ if(hmsc != NULL)
+ visualize_hmsc(vsoPage, hmsc);
+
// the last dropped shape would be selected
- m_page->Application->ActiveWindow->DeselectAll();
+ m_vsoApp->ActiveWindow->DeselectAll();
}
+double get_page_height(Visio::IVPagePtr vsoPage)
+{
+ double mm = vsoPage->PageSheet->CellsSRC[visSectionObject][visRowPage][visPageHeight]->Result[visMillimeters];
+ // keep vertical alignment
+ return floor(mm/5)*5;
+}
+
+Visio::IVShapePtr CDrawingVisualizer::DropMaster(Visio::IVPagePtr vsoPage, Visio::IVMasterPtr master, const Point& pos)
+{
+ double page_height = get_page_height(vsoPage);
+ // drop the master to bottom-left corner
+ // note: drop coordinates are in Visio internal units
+ Visio::IVShapePtr shape = vsoPage->Drop(master, 0, 0);
+ // move shape to the right position
+ shape->CellsSRC[visSectionObject][visRowXFormOut][visXFormPinX]->Result[visMillimeters] = pos.get_x(),
+ shape->CellsSRC[visSectionObject][visRowXFormOut][visXFormPinY]->Result[visMillimeters] = page_height - pos.get_y();
+ return shape;
+}
+
void CDrawingVisualizer::SetLineBegin(Visio::IVShapePtr what, const Point& pos)
{
+ double page_height = get_page_height(what->ContainingPage);
+
what->CellsSRC[visSectionObject][visRowXForm1D][vis1DBeginX]->Result[visMillimeters] = pos.get_x();
- what->CellsSRC[visSectionObject][visRowXForm1D][vis1DBeginY]->Result[visMillimeters] = m_page_height-pos.get_y();
+ what->CellsSRC[visSectionObject][visRowXForm1D][vis1DBeginY]->Result[visMillimeters] = page_height-pos.get_y();
}
void CDrawingVisualizer::SetLineEnd(Visio::IVShapePtr what, const Point& pos)
{
+ double page_height = get_page_height(what->ContainingPage);
+
what->CellsSRC[visSectionObject][visRowXForm1D][vis1DEndX]->Result[visMillimeters] = pos.get_x();
- what->CellsSRC[visSectionObject][visRowXForm1D][vis1DEndY]->Result[visMillimeters] = m_page_height-pos.get_y();
+ what->CellsSRC[visSectionObject][visRowXForm1D][vis1DEndY]->Result[visMillimeters] = page_height-pos.get_y();
}
void MarkShape(Visio::IVShapePtr what)
{
+ // line color = red
what->CellsSRC[visSectionObject][visRowLine][visLineColor]->ResultIU = 2;
+ // text color = red
what->CellsSRC[visSectionCharacter][visRowCharacter][visCharacterColor]->ResultIU = 2;
}
@@ -76,6 +108,7 @@
double width = where->CellsSRC[visSectionObject][visRowXFormOut][visXFormWidth]->Result[visMillimeters];
Visio::IVCellPtr cell = what->CellsSRC[visSectionObject][visRowXForm1D][vis1DBeginX];
+ // glue coordinates represent decimal fractions of the shape's width and height
// note: instances in Visio are rotated by 90', height is the 'x' coordinate
cell->GlueToPos(where, pos.get_y()/max(1.0,width), pos.get_x()/max(1.0,height));
}
@@ -97,30 +130,30 @@
list.push_back(item);
}
-Visio::IVShapePtr CDrawingVisualizer::drop_message(MessagePtrMap& messages,
+Visio::IVShapePtr CDrawingVisualizer::drop_message(Visio::IVPagePtr vsoPage, MessagePtrMap& messages,
MscMessagePtr message, Visio::IVMasterPtr master)
{
Visio::IVShapePtr msg = messages[message];
- if(msg == NULL)
- {
- msg = m_page->Drop(master, 0, m_page_height-0);
- if(message->get_marked())
- MarkShape(msg);
+ if(msg != NULL)
+ return msg;
- msg->Text = message->get_label().c_str();
- messages[message] = msg;
- }
+ msg = vsoPage->Drop(master, 0, 0);
+ if(message->get_marked())
+ MarkShape(msg);
+ msg->Text = message->get_label().c_str();
+ messages[message] = msg;
+
return msg;
}
-void CDrawingVisualizer::show_event(MessagePtrMap& messages,
+void CDrawingVisualizer::show_event(Visio::IVPagePtr vsoPage, MessagePtrMap& messages,
Visio::IVShapePtr parent, EventPtr event)
{
CompleteMessagePtr complete_message = event->get_complete_message();
if(complete_message != NULL)
{
- Visio::IVShapePtr msg = drop_message(messages, complete_message, m_message_master);
+ Visio::IVShapePtr msg = drop_message(vsoPage, messages, complete_message, m_message_master);
if(complete_message->get_send_event() == event)
GlueBeginToPos(msg, parent, event->get_position());
@@ -133,13 +166,13 @@
{
if(incomplete_message->is_lost())
{
- Visio::IVShapePtr msg = drop_message(messages, incomplete_message, m_lost_message_master);
+ Visio::IVShapePtr msg = drop_message(vsoPage, messages, incomplete_message, m_lost_message_master);
GlueBeginToPos(msg, parent, event->get_position());
SetLineEnd(msg, incomplete_message->get_dot_position());
}
else if(incomplete_message->is_found())
{
- Visio::IVShapePtr msg = drop_message(messages, incomplete_message, m_found_message_master);
+ Visio::IVShapePtr msg = drop_message(vsoPage, messages, incomplete_message, m_found_message_master);
SetLineBegin(msg, incomplete_message->get_dot_position());
GlueEndToPos(msg, parent, event->get_position());
}
@@ -147,29 +180,55 @@
if(event->get_marked())
{
- Visio::IVMasterPtr marker_master = m_page->Document->Masters->Item["Event Marker"];
+ Visio::IVMasterPtr marker_master = vsoPage->Document->Masters->Item["Event Marker"];
- double posX;
- double posY;
-
+ double posX, posY;
+ // convert drop coordinates to Visio internal units
// note: instances in Visio are rotated by 90', height is the 'x' coordinate
parent->XYToPage(
- m_page->Application->ConvertResult(event->get_position().get_y(), visMillimeters, visInches),
- m_page->Application->ConvertResult(event->get_position().get_x(), visMillimeters, visInches),
+ vsoPage->Application->ConvertResult(event->get_position().get_y(), visMillimeters, visInches),
+ vsoPage->Application->ConvertResult(event->get_position().get_x(), visMillimeters, visInches),
&posX, &posY);
- Visio::IVShapePtr marker = m_page->Drop(marker_master, posX, posY);
+ Visio::IVShapePtr marker = vsoPage->Drop(marker_master, posX, posY);
}
}
-void CDrawingVisualizer::visualize_bmsc(const BMscPtr& bmsc)
+Visio::IVShapePtr CDrawingVisualizer::connect_events(Visio::IVPagePtr vsoPage,
+ Visio::IVShapePtr parent, EventPtr pred_event, EventPtr succ_event)
{
+ Visio::IVShapePtr connector;
+
+ // events are on the same height
+ if(pred_event->get_position().get_y() == succ_event->get_position().get_y())
+ connector = vsoPage->Drop(m_ordering_arrow_master, 0, 0);
+ // events are on the same side
+ else if(pred_event->get_position().get_x() == succ_event->get_position().get_x())
+ {
+ connector = vsoPage->Drop(m_ordering_sides_master, 0, 0);
+ // set the vertical line offset
+ connector->CellsSRC[visSectionControls][visRowControl][visCtlX]->Result[visMillimeters] = -5.0;
+ }
+ else
+ connector = vsoPage->Drop(m_ordering_side_side_master, 0, 0);
+
+ GlueBeginToPos(connector, parent, pred_event->get_position());
+ GlueEndToPos(connector, parent, succ_event->get_position());
+
+ return connector;
+}
+
+void CDrawingVisualizer::visualize_bmsc(Visio::IVPagePtr vsoPage, const BMscPtr& bmsc)
+{
+ vsoPage->Name = bmsc->get_label().c_str();
+
std::map<InstancePtr,Visio::IVShapePtr> instances;
+ // visualize all instances
for(InstancePtrList::const_iterator ipos = bmsc->get_instances().begin();
ipos != bmsc->get_instances().end(); ipos++)
{
- Visio::IVShapePtr inst = m_page->Drop(m_instance_master, 0, m_page_height-0);
+ Visio::IVShapePtr inst = vsoPage->Drop(m_instance_master, 0, 0);
if((*ipos)->get_marked())
MarkShape(inst);
@@ -182,6 +241,7 @@
MessagePtrMap messages;
+ // walk through all instance events and visualize the messages
for(InstancePtrList::const_iterator ipos = bmsc->get_instances().begin();
ipos != bmsc->get_instances().end(); ipos++)
{
@@ -198,14 +258,14 @@
for(StrictEventPtr event = strict_area->get_first();
event != NULL; event = event->get_successor())
{
- show_event(messages, inst, event);
+ show_event(vsoPage, messages, inst, event);
}
}
CoregionAreaPtr coregion_area = boost::dynamic_pointer_cast<CoregionArea>(area);
if(coregion_area != NULL)
{
- Visio::IVShapePtr coregion = m_page->Drop(m_coregion_master, 0, m_page_height-0);
+ Visio::IVShapePtr coregion = vsoPage->Drop(m_coregion_master, 0, 0);
if(coregion_area->get_marked())
MarkShape(coregion);
@@ -226,12 +286,27 @@
for(std::list<CoregionEventPtr>::const_iterator epos = event_stack.begin();
epos != event_stack.end(); epos++)
{
- show_event(messages, coregion, *epos);
+ show_event(vsoPage, messages, coregion, *epos);
+
+ for(CoregEventRelPtrSet::const_iterator spos = (*epos)->get_successors().begin();
+ spos != (*epos)->get_successors().end(); spos++)
+ {
+ CoregionEventPtr successor = (*spos)->get_successor();
+
+ Visio::IVShapePtr connector = connect_events(vsoPage, coregion, *epos, successor);
+ if((*spos)->get_marked())
+ MarkShape(connector);
+
+ // add successors of this event to the stack
+ // note: std::list<>::push_back doesn't invalidate iterators
+ push_back_if_unique<CoregionEventPtr>(event_stack, successor);
+ }
}
}
}
}
+ // walk through generated messages
for(MessagePtrMap::const_iterator mpos = messages.begin();
mpos != messages.end(); mpos++)
{
@@ -243,4 +318,113 @@
}
}
+Visio::IVShapePtr CDrawingVisualizer::drop_hmsc_node(Visio::IVPagePtr vsoPage, NodePtrMap& nodes, HMscNodePtr node)
+{
+ Visio::IVShapePtr shape = nodes[node];
+ if(shape != NULL)
+ return shape;
+
+ StartNodePtr start_node = boost::dynamic_pointer_cast<StartNode>(node);
+ if(start_node != NULL)
+ {
+ shape = DropMaster(vsoPage, m_start_symbol_master, start_node->get_position());
+ }
+
+ ConnectionNodePtr connection_node = boost::dynamic_pointer_cast<ConnectionNode>(node);
+ if(connection_node != NULL)
+ {
+ shape = DropMaster(vsoPage, m_connection_point_master, connection_node->get_position());
+ }
+
+ ReferenceNodePtr reference_node = boost::dynamic_pointer_cast<ReferenceNode>(node);
+ if(reference_node != NULL)
+ {
+ shape = DropMaster(vsoPage, m_msc_reference_master, reference_node->get_position());
+
+ MscPtr msc = reference_node->get_msc();
+ if(msc != NULL)
+ {
+ shape->Text = msc->get_label().c_str();
+
+ Visio::IVPagePtr newPage;
+ for(int i = 1; i <= vsoPage->Document->Pages->Count; i++)
+ {
+ Visio::IVPagePtr thisPage = vsoPage->Document->Pages->Item[i];
+ if(_tcsicmp(thisPage->Name, shape->Text) == 0)
+ {
+ newPage = thisPage;
+ break;
+ }
+ }
+
+ if(newPage == NULL)
+ {
+ newPage = vsoPage->Document->Pages->Add();
+ visualize_msc(newPage, msc);
+ }
+ }
+ else
+ shape->Text = "(void)";
+ }
+
+ EndNodePtr end_node = boost::dynamic_pointer_cast<EndNode>(node);
+ if(end_node != NULL)
+ {
+ shape = DropMaster(vsoPage, m_end_symbol_master, end_node->get_position());
+ }
+
+ if(node->get_marked())
+ MarkShape(shape);
+
+ nodes[node] = shape;
+
+ return shape;
+}
+
+void CDrawingVisualizer::visualize_hmsc(Visio::IVPagePtr vsoPage, const HMscPtr& hmsc)
+{
+ vsoPage->Name = hmsc->get_label().c_str();
+
+ NodePtrMap nodes;
+
+ // nodes to be processed; this is to avoid recursion
+ std::list<HMscNodePtr> node_stack;
+
+ // initialize the stack with the start node
+ push_back_if_unique<HMscNodePtr>(node_stack, hmsc->get_start());
+
+ // process all nodes in the stack
+ for(std::list<HMscNodePtr>::const_iterator npos = node_stack.begin();
+ npos != node_stack.end(); npos++)
+ {
+ Visio::IVShapePtr shape = drop_hmsc_node(vsoPage, nodes, *npos);
+
+ PredecessorNode *predecessor_node = dynamic_cast<PredecessorNode*>(npos->get());
+ if(predecessor_node != NULL)
+ {
+ for(NodeRelationPtrSet::const_iterator spos = predecessor_node->get_successors().begin();
+ spos != predecessor_node->get_successors().end(); spos++)
+ {
+ SuccessorNode *successor = (*spos)->get_successor();
+ HMscNode *successor_node = dynamic_cast<HMscNode*>(successor);
+
+ Visio::IVShapePtr successor_shape = drop_hmsc_node(vsoPage, nodes, successor_node);
+
+ Visio::IVShapePtr connector = vsoPage->Drop(m_connection_arrow_master, 0, 0);
+ if((*spos)->get_marked())
+ MarkShape(connector);
+
+ Visio::IVCellPtr from_cell = connector->CellsSRC[visSectionObject][visRowXForm1D][vis1DBeginX];
+ from_cell->GlueToPos(shape, 0.5, 0.0);
+ Visio::IVCellPtr to_cell = connector->CellsSRC[visSectionObject][visRowXForm1D][vis1DEndX];
+ to_cell->GlueToPos(successor_shape, 0.5, 1.0);
+
+ // add successors of this node to the stack
+ // note: std::list<>::push_back doesn't invalidate iterators
+ push_back_if_unique<HMscNodePtr>(node_stack, successor_node);
+ }
+ }
+ }
+}
+
// $Id$
Modified: trunk/src/view/visio/addon/visualize.h
===================================================================
--- trunk/src/view/visio/addon/visualize.h 2009-01-29 22:26:55 UTC (rev 178)
+++ trunk/src/view/visio/addon/visualize.h 2009-01-31 16:35:08 UTC (rev 179)
@@ -23,31 +23,47 @@
class CDrawingVisualizer
{
public:
- CDrawingVisualizer(Visio::IVPagePtr vsoPage);
- void visualize_msc(const MscPtr& drawing);
+ CDrawingVisualizer(Visio::IVApplicationPtr vsoApp);
+ void visualize_msc(Visio::IVPagePtr vsoPage, const MscPtr& drawing);
protected:
- Visio::IVPagePtr m_page;
- double m_page_height;
+ Visio::IVApplicationPtr m_vsoApp;
Visio::IVMasterPtr m_instance_master;
Visio::IVMasterPtr m_coregion_master;
Visio::IVMasterPtr m_message_master;
Visio::IVMasterPtr m_lost_message_master;
Visio::IVMasterPtr m_found_message_master;
+ Visio::IVMasterPtr m_ordering_side_side_master;
+ Visio::IVMasterPtr m_ordering_sides_master;
+ Visio::IVMasterPtr m_ordering_arrow_master;
+ Visio::IVMasterPtr m_start_symbol_master;
+ Visio::IVMasterPtr m_end_symbol_master;
+ Visio::IVMasterPtr m_msc_reference_master;
+ Visio::IVMasterPtr m_connection_point_master;
+ Visio::IVMasterPtr m_connection_arrow_master;
+
typedef std::map<MscMessagePtr,Visio::IVShapePtr> MessagePtrMap;
typedef std::map<InstancePtr,Visio::IVShapePtr> InstancePtrMap;
+ Visio::IVShapePtr DropMaster(Visio::IVPagePtr vsoPage, Visio::IVMasterPtr master, const Point& pos);
void SetLineBegin(Visio::IVShapePtr what, const Point& pos);
void SetLineEnd(Visio::IVShapePtr what, const Point& pos);
- Visio::IVShapePtr drop_message(MessagePtrMap& messages,
+ Visio::IVShapePtr drop_message(Visio::IVPagePtr vsoPage, MessagePtrMap& messages,
MscMessagePtr message, Visio::IVMasterPtr master);
- void show_event(MessagePtrMap& messages,
+ void show_event(Visio::IVPagePtr vsoPage, MessagePtrMap& messages,
Visio::IVShapePtr parent, EventPtr event);
+ Visio::IVShapePtr connect_events(Visio::IVPagePtr vsoPage,
+ Visio::IVShapePtr parent, EventPtr pred_event, EventPtr succ_event);
- void visualize_bmsc(const BMscPtr& bmsc);
+ void visualize_bmsc(Visio::IVPagePtr vsoPage, const BMscPtr& bmsc);
+
+ typedef std::map<HMscNodePtr,Visio::IVShapePtr> NodePtrMap;
+ Visio::IVShapePtr drop_hmsc_node(Visio::IVPagePtr vsoPage, NodePtrMap& nodes, HMscNodePtr node);
+
+ void visualize_hmsc(Visio::IVPagePtr vsoPage, const HMscPtr& hmsc);
};
// $Id$
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <got...@us...> - 2009-02-01 10:41:29
|
Revision: 182
http://scstudio.svn.sourceforge.net/scstudio/?rev=182&view=rev
Author: gotthardp
Date: 2009-02-01 10:41:24 +0000 (Sun, 01 Feb 2009)
Log Message:
-----------
- Implemented "repaint" function to upgrade stencils in an existing drawing
- Fixed leading/trailing whitespace in engmann import
- Fixed gcc portability by replacing std::bad_cast --> std::invalid_argument in msc.h; standard std::bad_cast doesn't allow any reason string
Modified Paths:
--------------
trunk/src/data/engmann/engmann.cpp
trunk/src/data/msc.h
trunk/src/view/visio/addon/addon.cpp
trunk/src/view/visio/addon/document.cpp
trunk/src/view/visio/addon/document.h
Modified: trunk/src/data/engmann/engmann.cpp
===================================================================
--- trunk/src/data/engmann/engmann.cpp 2009-01-31 23:08:34 UTC (rev 181)
+++ trunk/src/data/engmann/engmann.cpp 2009-02-01 10:41:24 UTC (rev 182)
@@ -54,6 +54,20 @@
}
}
+static void trim(std::string& str)
+{
+ std::string::size_type pos = str.find_last_not_of(' ');
+ if(pos != std::string::npos)
+ {
+ str.erase(pos + 1);
+ pos = str.find_first_not_of(' ');
+ if(pos != std::string::npos)
+ str.erase(0, pos);
+ }
+ else
+ str.erase(str.begin(), str.end());
+}
+
static std::string read_line(std::istream& stream)
{
std::string result;
@@ -64,6 +78,9 @@
while(stream.good() && (ch = stream.get()) != '\n')
result.push_back(ch);
+ // remove leading and trailing whitespace
+ trim(result);
+
return result;
}
Modified: trunk/src/data/msc.h
===================================================================
--- trunk/src/data/msc.h 2009-01-31 23:08:34 UTC (rev 181)
+++ trunk/src/data/msc.h 2009-02-01 10:41:24 UTC (rev 182)
@@ -23,8 +23,8 @@
#include <string>
#include <set>
#include <map>
-#include <typeinfo>
#include <queue>
+#include <stdexcept>
#include <cmath>
// we use boost::intrusive_ptr as we need to construct the xx_ptr<T> from T*
@@ -371,7 +371,7 @@
}
else
{
- throw std::bad_cast("Attribute m_original is not of desired type");
+ throw std::invalid_argument("Attribute m_original is not of desired type");
}
}
Modified: trunk/src/view/visio/addon/addon.cpp
===================================================================
--- trunk/src/view/visio/addon/addon.cpp 2009-01-31 23:08:34 UTC (rev 181)
+++ trunk/src/view/visio/addon/addon.cpp 2009-02-01 10:41:24 UTC (rev 182)
@@ -288,11 +288,14 @@
TRACE("CStudioAddon::Run() menu item 'Check--Run'");
return pDocumentMonitor->OnMenuRun(vsoApp);
case 203:
- TRACE("CStudioAddon::Run() menu item 'Check--Import Drawing'");
+ TRACE("CStudioAddon::Run() menu item 'Check--Drawing--Import'");
return pDocumentMonitor->OnMenuImport(vsoApp);
case 204:
- TRACE("CStudioAddon::Run() menu item 'Check--Export Drawing'");
+ TRACE("CStudioAddon::Run() menu item 'Check--Drawing--Export'");
return pDocumentMonitor->OnMenuExport(vsoApp);
+ case 205:
+ TRACE("CStudioAddon::Run() menu item 'Check--Drawing--Repaint'");
+ return pDocumentMonitor->OnMenuRepaint(vsoApp);
default:
TRACE("CStudioAddon::Run() unexpected event id=" << iEvent);
Modified: trunk/src/view/visio/addon/document.cpp
===================================================================
--- trunk/src/view/visio/addon/document.cpp 2009-01-31 23:08:34 UTC (rev 181)
+++ trunk/src/view/visio/addon/document.cpp 2009-02-01 10:41:24 UTC (rev 182)
@@ -239,20 +239,31 @@
menuItem2->BeginGroup = true;
Visio::IVMenuItemPtr menuItem3 = menu->MenuItems->Add();
- menuItem3->Caption = "&Import Drawing...";
- menuItem3->AddOnName = ADDON_NAME;
- menuItem3->AddOnArgs = "/event=203";
+ menuItem3->Caption = "&Drawing";
menuItem3->BeginGroup = true;
+ menuItem3->CmdNum = Visio::visCmdHierarchical;
+
+ Visio::IVMenuItemPtr menuItem31 = menuItem3->MenuItems->Add();
+ menuItem31->Caption = "&Import...";
+ menuItem31->AddOnName = ADDON_NAME;
+ menuItem31->AddOnArgs = "/event=203";
+ menuItem31->BeginGroup = true;
// enable only if some formatters are available
- menuItem3->Enabled = m_formatters.size() > 0;
+ menuItem31->Enabled = m_formatters.size() > 0;
- Visio::IVMenuItemPtr menuItem4 = menu->MenuItems->Add();
- menuItem4->Caption = "&Export Drawing...";
- menuItem4->AddOnName = ADDON_NAME;
- menuItem4->AddOnArgs = "/event=204";
+ Visio::IVMenuItemPtr menuItem32 = menuItem3->MenuItems->Add();
+ menuItem32->Caption = "&Export...";
+ menuItem32->AddOnName = ADDON_NAME;
+ menuItem32->AddOnArgs = "/event=204";
// enable only if some formatters are available
- menuItem4->Enabled = m_formatters.size() > 0;
+ menuItem32->Enabled = m_formatters.size() > 0;
+ Visio::IVMenuItemPtr menuItem33 = menuItem3->MenuItems->Add();
+ menuItem33->Caption = "&Repaint";
+ menuItem33->AddOnName = ADDON_NAME;
+ menuItem33->AddOnArgs = "/event=205";
+ menuItem33->BeginGroup = true;
+
vsoDocument->SetCustomMenus(vsoMenus);
}
@@ -526,6 +537,39 @@
return VAORC_FAILURE;
}
+VAORC CDocumentMonitor::OnMenuRepaint(Visio::IVApplicationPtr vsoApp)
+{
+ if(!m_reportVisible)
+ ShowReportView(vsoApp);
+
+ // clear the verification report
+ m_reportView->Reset();
+
+ // this should repaint all pages, but we don't know the HMSC root
+ // walk through all pages are repaint each drawing separately
+ for(int i = 1; i <= vsoApp->ActiveDocument->Pages->Count; i++)
+ {
+ Visio::IVPagePtr page = vsoApp->ActiveDocument->Pages->Item[i];
+
+ CDrawingExtractor extractor(m_reportView);
+ MscPtr msc = extractor.extract_msc(page);
+
+ if(msc == NULL)
+ return VAORC_FAILURE;
+
+ Visio::IVSelectionPtr selection = page->CreateSelection(Visio::visSelTypeAll, Visio::visSelModeSkipSuper);
+ selection->Delete();
+
+ CDrawingVisualizer visualizer(vsoApp);
+ visualizer.visualize_msc(page, msc);
+ }
+
+ m_reportView->Print(RS_NOTICE,
+ stringize() << "Repaint completed.");
+
+ return VAORC_SUCCESS;
+}
+
VAORC CDocumentMonitor::OnMenuWindowsReporter(Visio::IVApplicationPtr vsoApp)
{
if(m_reportVisible)
Modified: trunk/src/view/visio/addon/document.h
===================================================================
--- trunk/src/view/visio/addon/document.h 2009-01-31 23:08:34 UTC (rev 181)
+++ trunk/src/view/visio/addon/document.h 2009-02-01 10:41:24 UTC (rev 182)
@@ -43,6 +43,7 @@
VAORC OnMenuWindowsReporter(Visio::IVApplicationPtr vsoApp);
VAORC OnMenuImport(Visio::IVApplicationPtr vsoApp);
VAORC OnMenuExport(Visio::IVApplicationPtr vsoApp);
+ VAORC OnMenuRepaint(Visio::IVApplicationPtr vsoApp);
void ShowReportView(Visio::IVApplicationPtr vsoApp);
void OnHideReportView();
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <va...@us...> - 2009-04-22 07:54:30
|
Revision: 226
http://scstudio.svn.sourceforge.net/scstudio/?rev=226&view=rev
Author: vacek
Date: 2009-04-22 07:54:18 +0000 (Wed, 22 Apr 2009)
Log Message:
-----------
Standalone Name Checker added, Boundedness counterexamples improved
Modified Paths:
--------------
trunk/src/check/CMakeLists.txt
trunk/src/check/boundedness/universal_boundedness_checker.cpp
trunk/src/check/boundedness/universal_boundedness_checker.h
trunk/src/check/pseudocode/communication_graph.cpp
trunk/src/check/pseudocode/communication_graph.h
trunk/src/check/pseudocode/msc_duplicators.cpp
trunk/src/data/msc.cpp
trunk/src/data/msc.h
Added Paths:
-----------
trunk/src/check/structure/
trunk/src/check/structure/CMakeLists.txt
trunk/src/check/structure/export.h
trunk/src/check/structure/module.cpp
trunk/src/check/structure/name_checker.cpp
trunk/src/check/structure/name_checker.h
Modified: trunk/src/check/CMakeLists.txt
===================================================================
--- trunk/src/check/CMakeLists.txt 2009-04-19 21:37:05 UTC (rev 225)
+++ trunk/src/check/CMakeLists.txt 2009-04-22 07:54:18 UTC (rev 226)
@@ -5,5 +5,6 @@
ADD_SUBDIRECTORY(order)
ADD_SUBDIRECTORY(race)
ADD_SUBDIRECTORY(boundedness)
+ADD_SUBDIRECTORY(structure)
# $Id$
Modified: trunk/src/check/boundedness/universal_boundedness_checker.cpp
===================================================================
--- trunk/src/check/boundedness/universal_boundedness_checker.cpp 2009-04-19 21:37:05 UTC (rev 225)
+++ trunk/src/check/boundedness/universal_boundedness_checker.cpp 2009-04-22 07:54:18 UTC (rev 226)
@@ -17,31 +17,15 @@
*/
#include "check/boundedness/universal_boundedness_checker.h"
-#include "check/pseudocode/msc_duplicators.h"
+
UniversalBoundednessCheckerPtr UniversalBoundednessChecker::m_instance;
const std::string UniversalBoundednessChecker::com_graph_attribute = "cograt";
const std::string UniversalBoundednessChecker::vertex_number_attribute = "venuat";
-void FindFirstNodeListener::on_white_node_found(HMscNode *n)
+void NameCollector::on_white_node_found(HMscNode *n)
{
- ReferenceNode* refnode = dynamic_cast<ReferenceNode*>(n);
- if(refnode != NULL)
- {
- BMscPtr bmsc = refnode->get_bmsc();
- if(bmsc != NULL)
- {
- throw FirstNodeFoundException();
- }
-
- }
-}
-void NameChecker::on_white_node_found(HMscNode *n)
-{
- size_t num_of_instances;
- std::vector<std::string> current_labels;
-
InstancePtrList::const_iterator instance_iterator;
ReferenceNode* refnode = dynamic_cast<ReferenceNode*>(n);
if(refnode != NULL)
@@ -51,34 +35,13 @@
{
const InstancePtrList& instances = bmsc->get_instances();
for(instance_iterator = instances.begin(); instance_iterator != instances.end(); instance_iterator++)
- current_labels.push_back(instance_iterator->get()->get_label());
- num_of_instances = current_labels.size();
-
- std::sort(current_labels.begin(), current_labels.end());
- for(unsigned i = 1; i < current_labels.size(); i++)
- if(current_labels[i] == current_labels[i - 1])
- throw DuplicateNamesException();
-
- if(m_first_node)
- {
- m_instance_names = current_labels;
- m_first_node = false;
- }
- else
- {
- if(current_labels != m_instance_names)
- throw InconsistentNamesException();
- }
+ if(m_instance_map.find(instance_iterator->get()->get_label()) == m_instance_map.end())
+ m_instance_map[instance_iterator->get()->get_label()] = m_instance_map.size();
}
}
}
-void NodeAdder::on_white_node_found(HMscNode *n)
-{
- m_where_to_add->add_node(n);
-}
-
void AssignListener::on_white_node_found(HMscNode *n)
{
CommunicationGraph comgraph;
@@ -86,7 +49,7 @@
refnode = dynamic_cast<ReferenceNode*>(n);
if(refnode)
{
- comgraph.create_from_bmsc(refnode->get_bmsc());
+ comgraph.create_from_bmsc_with_map(refnode->get_bmsc(), m_label_map);
refnode->set_attribute<CommunicationGraph>(UniversalBoundednessChecker::com_graph_attribute, comgraph);
}
n->set_attribute(UniversalBoundednessChecker::vertex_number_attribute, m_node_number++);
@@ -137,33 +100,7 @@
}
}
-HMscPtr UniversalBoundednessChecker::create_duplicate_counter_example(const MscElementPListList& path)
-{
- HMscPathDuplicator duplicator;
- HMscPtr example = duplicator.duplicate_path(path);
- MscElementPListList::const_iterator h;
- for(h=path.begin();h!=path.end();h++)
- {
- MscElement* last = (*h).back();
- duplicator.get_copy(last)->set_marked(true);
- }
- return example;
-}
-HMscPtr UniversalBoundednessChecker::create_inconsistent_counter_example(const MscElementPListList& path1, const MscElementPListList& path2)
-{
- HMscPtr p, q;
- p = create_duplicate_counter_example(path1);
- q = create_duplicate_counter_example(path2);
- NodeAdder no_a(p);
- DFSBMscGraphTraverser node_adder;
- node_adder.add_white_node_found_listener(&no_a);
- node_adder.traverse(q);
- const NodeRelationPtr& rel = *(q->get_start()->get_successors().begin());
- p->get_start()->add_successor(rel->get_successor());
- return p;
-}
-
HMscPtr UniversalBoundednessChecker::create_counter_example(const MscElementPList& to_cycle, const MscElementPList& cycle)
{
HMscPtr p;
@@ -188,52 +125,19 @@
HMscPtr UniversalBoundednessChecker::check(HMscPtr hmsc, ChannelMapperPtr chm)
{
- DFSHMscTraverser name_traverser, first_node_traverser;
- NameChecker n_ch;
- FindFirstNodeListener ffnl;
+ DFSHMscTraverser name_traverser;
+ NameCollector name_collector;
HMscPtr p(NULL);
- MscElementPListList path_to_first;
- name_traverser.add_white_node_found_listener(&n_ch);
- first_node_traverser.add_white_node_found_listener(&ffnl);
+ name_traverser.add_white_node_found_listener(&name_collector);
+ name_traverser.traverse(hmsc);
-
-
- try
- {
- first_node_traverser.traverse(hmsc);
- }
- catch(FirstNodeFoundException)
- {
- path_to_first = first_node_traverser.get_reached_elements();
- first_node_traverser.cleanup_traversing_attributes();
- }
-
- try
- {
- name_traverser.traverse(hmsc);
- }
- catch(DuplicateNamesException)
- {
- p = create_duplicate_counter_example(name_traverser.get_reached_elements());
- name_traverser.cleanup_traversing_attributes();
- m_graph_duplicator.cleanup_attributes();
- return p;
- }
-
- catch(InconsistentNamesException)
- {
- p = create_inconsistent_counter_example(name_traverser.get_reached_elements(), path_to_first);
- name_traverser.cleanup_traversing_attributes();
- m_graph_duplicator.cleanup_attributes();
- return p;
- }
-
+
/* Here the main part of the checker begins */
// BMscGraphDuplicator graph_duplicator;
HMscPtr transformed = m_graph_duplicator.duplicate_hmsc(hmsc);
DFSHMscTraverser msc_traverser;
- AssignListener assigner;
+ AssignListener assigner(name_collector.get_instance_map());
CleanupListener cleaner;
//First, communication graphs and numbers are assigned to all the vertices.
Modified: trunk/src/check/boundedness/universal_boundedness_checker.h
===================================================================
--- trunk/src/check/boundedness/universal_boundedness_checker.h 2009-04-19 21:37:05 UTC (rev 225)
+++ trunk/src/check/boundedness/universal_boundedness_checker.h 2009-04-22 07:54:18 UTC (rev 226)
@@ -18,7 +18,6 @@
#include <vector>
#include <map>
-#include <iostream>
#include "data/checker.h"
#include "data/msc.h"
#include "check/boundedness/export.h"
@@ -50,35 +49,6 @@
unsigned m_vertex_count;
};
-class InconsistentNamesException: public std::exception
-{
-public:
-
- const char* what()
- {
- return "Inconsistent names.";
- }
-};
-
-class DuplicateNamesException: public std::exception
-{
-public:
-
- const char* what()
- {
- return "Duplicate names.";
- }
-};
-
-class FirstNodeFoundException: public std::exception
-{
-public:
- const char* what()
- {
- return "First node found.";
- }
-};
-
class UnboundedCycleException: public std::exception
{
public:
@@ -92,8 +62,8 @@
{
public:
void on_white_node_found(HMscNode *n);
- AssignListener()
- :m_node_number(0)
+ AssignListener(const std::map<std::string, unsigned> &map)
+ :m_node_number(0), m_label_map(map)
{}
unsigned get_vertex_count(void)
{
@@ -101,6 +71,7 @@
}
private:
unsigned m_node_number;
+ const std::map<std::string, unsigned>& m_label_map;
};
class CycleListener: public WhiteNodeFoundListener
@@ -125,35 +96,24 @@
void on_white_node_found(HMscNode *n);
};
-class FindFirstNodeListener: public WhiteNodeFoundListener
-{
-public:
- void on_white_node_found(HMscNode *n);
-};
-class NameChecker: public WhiteNodeFoundListener
+class NameCollector: public WhiteNodeFoundListener
{
private:
- bool m_first_node;
- std::vector<std::string> m_instance_names;
-
-public:
- void on_white_node_found(HMscNode *n);
- NameChecker()
- :m_first_node(true)
- {}
+ std::map<std::string, unsigned> m_instance_map;
-};
-class NodeAdder: public WhiteNodeFoundListener
-{
- HMscPtr m_where_to_add;
public:
void on_white_node_found(HMscNode *n);
- NodeAdder(HMscPtr &where_add)
+ unsigned get_instance_count(void)
{
- m_where_to_add = where_add;
+ return m_instance_map.size();
}
+ const std::map<std::string, unsigned> & get_instance_map(void)
+ {
+ return m_instance_map;
+ }
+
};
class SCBOUNDEDNESS_EXPORT UniversalBoundednessChecker: public Checker, public HMscChecker
@@ -165,10 +125,8 @@
*/
static UniversalBoundednessCheckerPtr m_instance;
- HMscPtr create_duplicate_counter_example(const MscElementPListList& path);
-
- HMscPtr create_inconsistent_counter_example(const MscElementPListList& path1, const MscElementPListList& path2);
HMscPtr create_counter_example(const MscElementPList& to_cycle, const MscElementPList& cycle);
+
BMscGraphDuplicator m_graph_duplicator;
Modified: trunk/src/check/pseudocode/communication_graph.cpp
===================================================================
--- trunk/src/check/pseudocode/communication_graph.cpp 2009-04-19 21:37:05 UTC (rev 225)
+++ trunk/src/check/pseudocode/communication_graph.cpp 2009-04-22 07:54:18 UTC (rev 226)
@@ -33,7 +33,34 @@
m_graph.at(from).at(to) = 1;
}
}
+void CommunicationGraph::create_from_bmsc_with_map(BMscPtr bmsc, const std::map<std::string, unsigned> & instance_map)
+{
+ m_graph.clear();
+ m_graph.resize(instance_map.size());
+ for(unsigned i = 0; i < instance_map.size(); i++)
+ {
+ m_graph.at(i).resize(instance_map.size());
+ for(unsigned j = 0; j < instance_map.size(); j++)
+ m_graph.at(i).at(j) = 0;
+ }
+ InstancePtrList::const_iterator it;
+ unsigned current_num;
+ for(it = bmsc->get_instances().begin(); it != bmsc->get_instances().end(); it++)
+ {
+ current_num = instance_map.find((*it)->get_label())->second;
+ (*it)->set_attribute(lexical_order_attribute, current_num);
+ }
+
+ DFSEventsTraverser graph_creator;
+ CommunicationGraphListener graph_creator_listener(m_graph);
+ graph_creator.add_white_event_found_listener(&graph_creator_listener);
+ graph_creator.traverse(bmsc);
+
+ for(it = bmsc->get_instances().begin(); it != bmsc->get_instances().end(); it++)
+ (*it)->remove_attribute<unsigned>(lexical_order_attribute);
+
+}
void CommunicationGraph::create_from_bmsc(BMscPtr bmsc)
{
m_graph.clear();
Modified: trunk/src/check/pseudocode/communication_graph.h
===================================================================
--- trunk/src/check/pseudocode/communication_graph.h 2009-04-19 21:37:05 UTC (rev 225)
+++ trunk/src/check/pseudocode/communication_graph.h 2009-04-22 07:54:18 UTC (rev 226)
@@ -19,7 +19,6 @@
#ifndef _COMMUNICATION_GRAPH_H
#define _COMMUNICATION_GRAPH_H
#include <vector>
-#include <iostream>
#include <map>
#include "data/msc.h"
#include "data/dfs_events_traverser.h"
@@ -50,6 +49,7 @@
this->create_from_bmsc(bmsc);
}
void create_from_bmsc(BMscPtr bmsc);
+ void create_from_bmsc_with_map(BMscPtr bmsc, const std::map<std::string, unsigned> & instance_map);
void clear(void)
{
m_graph.clear();
Modified: trunk/src/check/pseudocode/msc_duplicators.cpp
===================================================================
--- trunk/src/check/pseudocode/msc_duplicators.cpp 2009-04-19 21:37:05 UTC (rev 225)
+++ trunk/src/check/pseudocode/msc_duplicators.cpp 2009-04-22 07:54:18 UTC (rev 226)
@@ -89,7 +89,7 @@
instances != bmsc->get_instances().end();
instances++)
{
- if(instances->get()->is_empty())
+ if(!instances->get()->has_events())
{
new_empty = new Instance(instances->get());
new_bmsc.get()->add_instance(new_empty);
Added: trunk/src/check/structure/CMakeLists.txt
===================================================================
--- trunk/src/check/structure/CMakeLists.txt (rev 0)
+++ trunk/src/check/structure/CMakeLists.txt 2009-04-22 07:54:18 UTC (rev 226)
@@ -0,0 +1,18 @@
+ADD_LIBRARY(scstructure SHARED
+ export.h
+ module.cpp
+ name_checker.cpp
+ name_checker.h
+)
+
+TARGET_LINK_LIBRARIES(scstructure
+ scpseudocode
+ scmsc
+)
+
+INSTALL(TARGETS scstructure
+ RUNTIME DESTINATION bin
+ LIBRARY DESTINATION lib
+ ARCHIVE DESTINATION lib)
+
+# $Id: CMakeLists.txt 206 2009-03-25 17:03:43Z vacek $
Added: trunk/src/check/structure/export.h
===================================================================
--- trunk/src/check/structure/export.h (rev 0)
+++ trunk/src/check/structure/export.h 2009-04-22 07:54:18 UTC (rev 226)
@@ -0,0 +1,37 @@
+/*
+ * 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 Petr Gotthard <pet...@ce...>
+ *
+ * $Id$
+ */
+
+#ifndef _SCSTRUCTURE_EXPORT_H
+#define _SCSTRUCTURE_EXPORT_H
+
+#if defined(_MSC_VER)
+#pragma warning(disable: 4251)
+
+#if defined(scstructure_EXPORTS)
+#define SCSTRUCTURE_EXPORT __declspec(dllexport)
+#else
+#define SCSTRUCTURE_EXPORT __declspec(dllimport)
+#endif
+
+#else
+#define SCSTRUCTURE_EXPORT
+#endif
+
+#endif /* _SCSTRUCTURE_EXPORT_H */
+
+// $Id$
Property changes on: trunk/src/check/structure/export.h
___________________________________________________________________
Added: svn:keywords
+ Id
Added: svn:eol-style
+ native
Added: trunk/src/check/structure/module.cpp
===================================================================
--- trunk/src/check/structure/module.cpp (rev 0)
+++ trunk/src/check/structure/module.cpp 2009-04-22 07:54:18 UTC (rev 226)
@@ -0,0 +1,33 @@
+/*
+ * 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 Petr Gotthard <pet...@ce...>
+ *
+ * $Id$
+ */
+
+#include "check/structure/name_checker.h"
+
+// module initialization function
+// note: the Visio add-on searches for a function of this name
+extern "C" SCSTRUCTURE_EXPORT
+Checker** init_checkers()
+{
+ Checker **result = new Checker* [2];
+ result[0] = new NameChecker();
+ result[1] = NULL;
+
+ return result;
+}
+
+// $Id$
Property changes on: trunk/src/check/structure/module.cpp
___________________________________________________________________
Added: svn:keywords
+ Id
Added: svn:eol-style
+ native
Added: trunk/src/check/structure/name_checker.cpp
===================================================================
--- trunk/src/check/structure/name_checker.cpp (rev 0)
+++ trunk/src/check/structure/name_checker.cpp 2009-04-22 07:54:18 UTC (rev 226)
@@ -0,0 +1,206 @@
+/*
+ * 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 V\xE1clav Vacek <va...@ic...>
+ *
+ * $Id$
+ */
+
+#include "check/structure/name_checker.h"
+
+NameCheckerPtr NameChecker::m_instance;
+
+void FindFirstNodeListener::on_white_node_found(HMscNode *n)
+{
+ ReferenceNode* refnode = dynamic_cast<ReferenceNode*>(n);
+ if(refnode != NULL)
+ {
+ BMscPtr bmsc = refnode->get_bmsc();
+ if(bmsc != NULL)
+ {
+ throw FirstNodeFoundException();
+ }
+
+ }
+}
+void NameListener::on_white_node_found(HMscNode *n)
+{
+ size_t num_of_instances;
+ std::vector<std::string> current_labels;
+
+ InstancePtrList::const_iterator instance_iterator;
+ ReferenceNode* refnode = dynamic_cast<ReferenceNode*>(n);
+ if(refnode != NULL)
+ {
+ BMscPtr bmsc = refnode->get_bmsc();
+ if(bmsc != NULL)
+ {
+ const InstancePtrList& instances = bmsc->get_instances();
+ for(instance_iterator = instances.begin(); instance_iterator != instances.end(); instance_iterator++)
+ current_labels.push_back(instance_iterator->get()->get_label());
+ num_of_instances = current_labels.size();
+
+ std::sort(current_labels.begin(), current_labels.end());
+ for(unsigned i = 1; i < current_labels.size(); i++)
+ if(current_labels[i] == current_labels[i - 1])
+ throw DuplicateNamesException();
+
+ if(m_first_node)
+ {
+ m_instance_names = current_labels;
+ m_first_node = false;
+ }
+ else
+ {
+ if(current_labels != m_instance_names)
+ throw InconsistentNamesException();
+ }
+ }
+
+ }
+}
+
+void NodeAdder::on_white_node_found(HMscNode *n)
+{
+ m_where_to_add->add_node(n);
+}
+
+
+HMscPtr NameChecker::create_duplicate_counter_example(const MscElementPListList& path)
+{
+ HMscPathDuplicator duplicator;
+ HMscPtr example = duplicator.duplicate_path(path);
+ MscElementPListList::const_iterator h;
+ for(h=path.begin();h!=path.end();h++)
+ {
+ MscElement* last = (*h).back();
+ duplicator.get_copy(last)->set_marked(true);
+ }
+ return example;
+}
+
+HMscPtr NameChecker::create_inconsistent_counter_example(const MscElementPListList& path1, const MscElementPListList& path2)
+{
+ HMscPtr p, q;
+ HMscPathDuplicator duplicator;
+
+ MscElementPListList::const_iterator h;
+
+ p = duplicator.duplicate_path(path1);
+ for(h=path1.begin();h!=path1.end();h++)
+ {
+ MscElement* last = (*h).back();
+ duplicator.get_copy(last)->set_marked(true);
+ }
+
+ for(h=path2.begin();h!=path2.end();h++)
+ {
+ MscElement* last = (*h).back();
+ if(duplicator.get_copy(last))
+ duplicator.get_copy(last)->set_marked(true);
+ }
+
+ duplicator.cleanup_attributes();
+
+
+ q = duplicator.duplicate_path(path2);
+
+ for(h=path2.begin();h!=path2.end();h++)
+ {
+ MscElement* last = (*h).back();
+ duplicator.get_copy(last)->set_marked(true);
+ }
+
+ for(h=path1.begin();h!=path1.end();h++)
+ {
+ MscElement* last = (*h).back();
+ if(duplicator.get_copy(last))
+ duplicator.get_copy(last)->set_marked(true);
+ }
+
+ NodeAdder no_a(p);
+ DFSBMscGraphTraverser node_adder;
+ node_adder.add_white_node_found_listener(&no_a);
+ node_adder.traverse(q);
+ const NodeRelationPtr& rel = *(q->get_start()->get_successors().begin());
+ p->get_start()->add_successor(rel->get_successor());
+ return p;
+}
+
+
+BMscPtr NameChecker::check(BMscPtr bmsc, ChannelMapperPtr chm)
+{
+ HMscPtr hmsc1(new HMsc("HMsc1"));
+ StartNodePtr start1 = new StartNode();
+ hmsc1->set_start(start1);
+ ReferenceNodePtr r1_1(new ReferenceNode());
+ EndNodePtr end1(new EndNode());
+ hmsc1->add_node(r1_1);
+ hmsc1->add_node(end1);
+ start1->add_successor(r1_1.get());
+ r1_1->add_successor(end1.get());
+ r1_1->set_msc(bmsc);
+
+ HMscPtr r = check(hmsc1, chm);
+ if(r)
+ return bmsc;
+ else
+ return NULL;
+}
+HMscPtr NameChecker::check(HMscPtr hmsc, ChannelMapperPtr chm)
+{
+ DFSHMscTraverser name_traverser, first_node_traverser;
+ NameListener n_ch;
+ FindFirstNodeListener ffnl;
+ HMscPtr p(NULL);
+ MscElementPListList path_to_first;
+ name_traverser.add_white_node_found_listener(&n_ch);
+ first_node_traverser.add_white_node_found_listener(&ffnl);
+
+ try
+ {
+ first_node_traverser.traverse(hmsc);
+ }
+ catch(FirstNodeFoundException)
+ {
+ path_to_first = first_node_traverser.get_reached_elements();
+ first_node_traverser.cleanup_traversing_attributes();
+ }
+
+ try
+ {
+ name_traverser.traverse(hmsc);
+ }
+ catch(DuplicateNamesException)
+ {
+ p = create_duplicate_counter_example(name_traverser.get_reached_elements());
+ name_traverser.cleanup_traversing_attributes();
+ m_graph_duplicator.cleanup_attributes();
+ return p;
+ }
+
+ catch(InconsistentNamesException)
+ {
+ p = create_inconsistent_counter_example(name_traverser.get_reached_elements(), path_to_first);
+ name_traverser.cleanup_traversing_attributes();
+ m_graph_duplicator.cleanup_attributes();
+ return p;
+ }
+ return NULL;
+}
+
+void NameChecker::cleanup_attributes()
+{
+}
+
+// $Id$
Property changes on: trunk/src/check/structure/name_checker.cpp
___________________________________________________________________
Added: svn:keywords
+ Id
Added: svn:eol-style
+ native
Added: trunk/src/check/structure/name_checker.h
===================================================================
--- trunk/src/check/structure/name_checker.h (rev 0)
+++ trunk/src/check/structure/name_checker.h 2009-04-22 07:54:18 UTC (rev 226)
@@ -0,0 +1,154 @@
+/*
+ * 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 V\xE1clav Vacek <va...@ic...>
+ *
+ * $Id$
+ */
+
+#include <vector>
+#include <map>
+#include "data/checker.h"
+#include "data/msc.h"
+#include "check/structure/export.h"
+#include "data/dfs_hmsc_traverser.h"
+#include "data/dfs_bmsc_graph_traverser.h"
+#include "check/pseudocode/msc_duplicators.h"
+
+
+class NameChecker;
+
+
+typedef boost::shared_ptr<NameChecker> NameCheckerPtr;
+
+
+class InconsistentNamesException: public std::exception
+{
+public:
+
+ const char* what()
+ {
+ return "Inconsistent names.";
+ }
+};
+
+class DuplicateNamesException: public std::exception
+{
+public:
+
+ const char* what()
+ {
+ return "Duplicate names.";
+ }
+};
+
+class FindFirstNodeListener:public WhiteNodeFoundListener
+{
+public:
+ void on_white_node_found(HMscNode *n);
+};
+
+class FirstNodeFoundException: public std::exception
+{
+public:
+ const char* what()
+ {
+ return "First node found.";
+ }
+};
+
+
+class NameListener: public WhiteNodeFoundListener
+{
+private:
+ bool m_first_node;
+ std::vector<std::string> m_instance_names;
+
+public:
+ void on_white_node_found(HMscNode *n);
+ NameListener()
+ :m_first_node(true)
+ {}
+
+};
+
+class NodeAdder: public WhiteNodeFoundListener
+{
+ HMscPtr m_where_to_add;
+public:
+ void on_white_node_found(HMscNode *n);
+ NodeAdder(HMscPtr &where_add)
+ {
+ m_where_to_add = where_add;
+ }
+};
+
+class SCSTRUCTURE_EXPORT NameChecker: public Checker, public HMscChecker, public BMscChecker
+{
+protected:
+
+ /**
+ * Common instance.
+ */
+ static NameCheckerPtr m_instance;
+
+ HMscPtr create_duplicate_counter_example(const MscElementPListList& path);
+
+ HMscPtr create_inconsistent_counter_example(const MscElementPListList& path1, const MscElementPListList& path2);
+
+ BMscGraphDuplicator m_graph_duplicator;
+
+
+
+public:
+
+ NameChecker(){};
+
+ /**
+ * Human readable description of this check.
+ */
+ // note: DLL in Windows cannot return pointers to static data
+ virtual std::string get_description() const
+ { return "Instance names"; }
+
+ /**
+ * Checks whether a given hmsc contains consistent set of instances.
+ */
+ HMscPtr check(HMscPtr hmsc, ChannelMapperPtr chm);
+
+ BMscPtr check(BMscPtr bmsc, ChannelMapperPtr chm);
+
+ /**
+ * Cleans up no more needed attributes.
+ */
+ void cleanup_attributes();
+
+ /**
+ * Supports all mappers
+ */
+ bool is_supported(ChannelMapperPtr chm)
+ {
+ return true;
+ }
+
+
+ static NameCheckerPtr instance()
+ {
+ if(!m_instance.get())
+ m_instance = NameCheckerPtr(new NameChecker());
+ return m_instance;
+ }
+
+};
+
+// $Id$
Property changes on: trunk/src/check/structure/name_checker.h
___________________________________________________________________
Added: svn:keywords
+ Id
Added: svn:eol-style
+ native
Modified: trunk/src/data/msc.cpp
===================================================================
--- trunk/src/data/msc.cpp 2009-04-19 21:37:05 UTC (rev 225)
+++ trunk/src/data/msc.cpp 2009-04-22 07:54:18 UTC (rev 226)
@@ -261,6 +261,16 @@
m_width = original->get_width();
}
+bool Instance::any_event(EventAreaPtr area)
+{
+ if(!area)
+ return false;
+ if(area->is_empty())
+ return any_event(area->get_next());
+ else
+ return true;
+}
+
/////////////////////////////////////////////////////////////////////////////
MscMessage::MscMessage(const std::string& label):
Modified: trunk/src/data/msc.h
===================================================================
--- trunk/src/data/msc.h 2009-04-19 21:37:05 UTC (rev 225)
+++ trunk/src/data/msc.h 2009-04-22 07:54:18 UTC (rev 226)
@@ -1008,6 +1008,8 @@
Point m_line_end;
Size m_width;
+
+ bool any_event(EventAreaPtr area);
public:
@@ -1118,6 +1120,14 @@
return !m_last.get();
}
+ /** \brief Returns true iff the instance contains at least one event
+ */
+ bool has_events()
+ {
+ return any_event(this->get_first());
+ }
+
+
};
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <got...@us...> - 2009-04-25 20:04:23
|
Revision: 229
http://scstudio.svn.sourceforge.net/scstudio/?rev=229&view=rev
Author: gotthardp
Date: 2009-04-25 20:04:08 +0000 (Sat, 25 Apr 2009)
Log Message:
-----------
Implemented checker priority evaluation.
Modified Paths:
--------------
trunk/src/check/boundedness/universal_boundedness_checker.cpp
trunk/src/data/checker.h
trunk/src/view/visio/addon/dllmodule.rc
trunk/src/view/visio/addon/document.cpp
trunk/src/view/visio/addon/document.h
trunk/src/view/visio/scstudio.nsi
Modified: trunk/src/check/boundedness/universal_boundedness_checker.cpp
===================================================================
--- trunk/src/check/boundedness/universal_boundedness_checker.cpp 2009-04-22 21:28:52 UTC (rev 228)
+++ trunk/src/check/boundedness/universal_boundedness_checker.cpp 2009-04-25 20:04:08 UTC (rev 229)
@@ -108,7 +108,7 @@
Checker::PreconditionList UniversalBoundednessChecker::get_preconditions(MscPtr msc) const
{
Checker::PreconditionList result;
- result.push_back(CheckerPrecondition("Unique instance names", CP_RECOMMENDED));
+ result.push_back(CheckerPrecondition("Unique Instance Names", PP_RECOMMENDED));
return result;
}
Modified: trunk/src/data/checker.h
===================================================================
--- trunk/src/data/checker.h 2009-04-22 21:28:52 UTC (rev 228)
+++ trunk/src/data/checker.h 2009-04-25 20:04:08 UTC (rev 229)
@@ -49,21 +49,21 @@
*/
virtual std::string get_property_name() const = 0;
- enum CheckerPriority
+ enum PreconditionPriority
{
- CP_REQUIRED, //! error if not satisfied
- CP_RECOMMENDED, //! warning if not satisfied
- CP_DISREGARDED //! may not be satisfied
+ PP_REQUIRED, //! error if not satisfied
+ PP_RECOMMENDED, //! warning if not satisfied
+ PP_DISREGARDED //! may not be satisfied
};
struct CheckerPrecondition
{
- CheckerPrecondition(const std::string& name, CheckerPriority prio)
+ CheckerPrecondition(const std::string& name, PreconditionPriority prio)
: property_name(name), priority(prio)
{ }
std::string property_name;
- CheckerPriority priority;
+ PreconditionPriority priority;
};
//! List of properties that must be satisfied before executing the check.
typedef std::vector<CheckerPrecondition> PreconditionList;
@@ -220,12 +220,7 @@
* Holds identificators of channels represented by MessagePart of MscMessage.
*/
std::map<MessagePart,size_t> m_channels;
-
- /**
- * Use GeneralMapper::instance() to obtain instance of GeneralMapper
- */
- GeneralMapper(){};
-
+
public:
/**
Modified: trunk/src/view/visio/addon/dllmodule.rc
===================================================================
--- trunk/src/view/visio/addon/dllmodule.rc 2009-04-22 21:28:52 UTC (rev 228)
+++ trunk/src/view/visio/addon/dllmodule.rc 2009-04-25 20:04:08 UTC (rev 229)
@@ -72,8 +72,8 @@
//
VS_VERSION_INFO VERSIONINFO
- FILEVERSION 0,2,10,0
- PRODUCTVERSION 0,2,10,0
+ FILEVERSION 0,3,0,0
+ PRODUCTVERSION 0,3,0,0
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x9L
@@ -90,13 +90,13 @@
BEGIN
VALUE "CompanyName", "Masaryk University Brno"
VALUE "FileDescription", "Microsoft Visio add-on for design and verification of Message Sequence Charts (MSC)."
- VALUE "FileVersion", "0.2.10"
+ VALUE "FileVersion", "0.3.0"
VALUE "InternalName", "scstudio.vsl"
VALUE "LegalCopyright", "(c) Petr Gotthard. All rights reserved."
VALUE "OriginalFilename", "scstudio.vsl"
VALUE "PrivateBuild", "$Revision$"
VALUE "ProductName", "Sequence Chart Studio"
- VALUE "ProductVersion", "0.2.10"
+ VALUE "ProductVersion", "0.3.0"
END
END
BLOCK "VarFileInfo"
Modified: trunk/src/view/visio/addon/document.cpp
===================================================================
--- trunk/src/view/visio/addon/document.cpp 2009-04-22 21:28:52 UTC (rev 228)
+++ trunk/src/view/visio/addon/document.cpp 2009-04-25 20:04:08 UTC (rev 229)
@@ -33,6 +33,7 @@
#include <atldlgs.h>
#include <boost/graph/adjacency_list.hpp>
+#include <boost/graph/breadth_first_search.hpp>
#include <boost/graph/topological_sort.hpp>
CDocumentMonitor::CDocumentMonitor(CStudioAddon *addon,
@@ -369,18 +370,86 @@
CheckerPtrList::const_iterator CDocumentMonitor::find_checker(const std::string& property_name) const
{
- nocase_comparator is_equal;
-
for(CheckerPtrList::const_iterator cpos = m_checkers.begin();
cpos != m_checkers.end(); cpos++)
{
- if(is_equal((*cpos)->get_property_name(), property_name))
+ if(stricmp((*cpos)->get_property_name().c_str(), property_name.c_str()) == 0)
return cpos;
}
return m_checkers.end();
}
+DWORD CDocumentMonitor::GetCheckerConfig(const char* subkey, const char* parameter, DWORD default_value) const
+{
+ TCHAR _subkey[MAX_PATH];
+ mbstowcs(_subkey, subkey, MAX_PATH);
+
+ HKEY hPathKey;
+ if(RegOpenKeyEx(HKEY_CURRENT_USER, _subkey, 0, KEY_READ, &hPathKey) != ERROR_SUCCESS)
+ return default_value;
+
+ TCHAR _parameter[MAX_PATH];
+ mbstowcs(_parameter, parameter, MAX_PATH);
+
+ DWORD valueType;
+ DWORD value;
+ DWORD valueLength = sizeof(DWORD);
+
+ if(RegQueryValueEx(hPathKey, _parameter,
+ NULL, &valueType, (LPBYTE)&value, &valueLength) != ERROR_SUCCESS)
+ {
+ // registry entry doesn't exist, use the default value
+ value = default_value;
+ }
+
+ RegCloseKey(hPathKey);
+ return value;
+}
+
+struct check_priority_t
+{
+ typedef boost::edge_property_tag kind;
+};
+
+struct max_priority_t
+{
+ typedef boost::vertex_property_tag kind;
+};
+
+template<typename MaxPriorityMap, typename CheckPriorityMap>
+class bfs_priority_visitor : public boost::default_bfs_visitor
+{
+public:
+ bfs_priority_visitor(MaxPriorityMap mmap, CheckPriorityMap cmap)
+ : m_max_priority_map(mmap), m_check_priority_map(cmap)
+ { }
+
+ // check-->dependency edge
+ template<typename Edge, typename DependencyGraph>
+ void examine_edge(Edge e, const DependencyGraph& g) const
+ {
+ // priority of the dependency
+ int priority = boost::get(m_check_priority_map, e);
+ // priority of the check
+ int src_priority = boost::get(m_max_priority_map, boost::source(e, g));
+ // effective priority is the lowest priority of [check priority, dependency priority]
+ // note: higher priority is represented by lower numbers
+ if(src_priority > priority)
+ priority = src_priority;
+
+ // priority of a dependent check is the highest effective priority of all dependencies
+ int trg_priority = boost::get(m_max_priority_map, boost::target(e, g));
+ if(trg_priority > priority)
+ boost::put(m_max_priority_map, boost::target(e, g), priority);
+ return;
+ }
+
+private:
+ MaxPriorityMap m_max_priority_map;
+ CheckPriorityMap m_check_priority_map;
+};
+
VAORC CDocumentMonitor::OnMenuRun(Visio::IVApplicationPtr vsoApp)
{
// clear the verification report
@@ -402,14 +471,49 @@
status.insert(status.begin(), m_checkers.size(), CheckExecutionStatus());
typedef boost::adjacency_list<boost::vecS, boost::vecS, boost::directedS,
- boost::property<boost::vertex_color_t, boost::default_color_type> > Graph;
- Graph G(m_checkers.size());
+ // vertex properties
+ boost::property<boost::vertex_color_t, boost::default_color_type,
+ boost::property<max_priority_t, int> >,
+ // edge properties
+ boost::property<check_priority_t, int> > DependencyGraph;
+ typedef boost::graph_traits<DependencyGraph>::vertex_descriptor Vertex;
+ typedef boost::graph_traits<DependencyGraph>::edge_descriptor Edge;
+
+ size_t main_index = m_checkers.size();
+ // vertex 0..N-1 correspond to individual checkers
+ // vertex N corresponds to the user required check
+ DependencyGraph G(main_index+1);
+
+ typedef boost::property_map<DependencyGraph, max_priority_t>::type MaxPriorityMap;
+ typedef boost::property_map<DependencyGraph, check_priority_t>::type CheckPriorityMap;
+ // vertex property describing priority of the check
+ MaxPriorityMap max_priority_map = boost::get(max_priority_t(), G);
+ // edge property describing priority of the dependency
+ CheckPriorityMap check_priority_map = boost::get(check_priority_t(), G);
+
+ // user checks are always required
+ boost::put(max_priority_map, main_index, Checker::PP_REQUIRED);
+ // walk through all installed checkers
for(CheckerPtrList::const_iterator cpos = m_checkers.begin();
cpos != m_checkers.end(); cpos++)
{
size_t icheck = cpos - m_checkers.begin();
+ // initialize the property
+ boost::put(max_priority_map, icheck, Checker::PP_DISREGARDED);
+ char subkey[MAX_PATH];
+ strcpy(subkey, "Software\\Sequence Chart Studio\\Checks\\");
+ strcat(subkey, (*cpos)->get_property_name().c_str());
+
+ int user_priority = GetCheckerConfig(subkey, "Priority", 0);
+ if(user_priority < Checker::PP_DISREGARDED)
+ {
+ // add dependency for each user required check
+ std::pair<Edge,bool> res = boost::add_edge(main_index, icheck, G);
+ boost::put(check_priority_map, res.first, user_priority);
+ }
+
Checker::PreconditionList preconditions = (*cpos)->get_preconditions(msc);
// check the preconditions
for(Checker::PreconditionList::const_iterator ppos = preconditions.begin();
@@ -421,18 +525,24 @@
size_t idep = checker - m_checkers.begin();
// add dependency to the graph
// if edge (u,v) appears in the graph, then v comes before u in the ordering
- boost::add_edge(icheck, idep, G);
+ std::pair<Edge,bool> res = boost::add_edge(icheck, idep, G);
+ boost::put(check_priority_map, res.first, ppos->priority);
}
}
}
- typedef boost::graph_traits<Graph>::vertex_descriptor Vertex;
+ bfs_priority_visitor<MaxPriorityMap, CheckPriorityMap>
+ vis(max_priority_map, check_priority_map);
+ // calculate priorities of dependent checks
+ boost::breadth_first_search(G, boost::vertex(main_index, G), boost::visitor(vis));
+
typedef std::vector<Vertex> Container;
Container check_order;
try
{
- // output iterator in reverse topological order
+ // calculate execution order
+ // note: output iterator in reverse topological order
boost::topological_sort(G, std::back_inserter(check_order));
}
catch(boost::not_a_dag)
@@ -441,22 +551,29 @@
return VAORC_FAILURE;
}
- BMscPtr bmsc = boost::dynamic_pointer_cast<BMsc>(msc);
- HMscPtr hmsc = boost::dynamic_pointer_cast<HMsc>(msc);
+ enum OutputLevel
+ {
+ OL_ERROR,
+ OL_WARNING,
+ OL_NOTIFY
+ };
+ OutputLevel output_level = (OutputLevel)GetCheckerConfig("Software\\Sequence Chart Studio", "OutputLevel", 1);
- SRChannelMapperPtr srm = SRChannelMapper::instance();
-
int satisfied_count = 0;
int violated_count = 0;
+ // execute the checkers
for(Container::const_iterator cpos = check_order.begin();
cpos != check_order.end(); cpos++)
{
+ if(*cpos == main_index)
+ continue;
+
CheckerPtr msc_checker = m_checkers[*cpos];
bool all_preconditions = true;
Checker::PreconditionList preconditions = msc_checker->get_preconditions(msc);
- // check the preconditions
+ // verify the preconditions
for(Checker::PreconditionList::const_iterator ppos = preconditions.begin();
ppos != preconditions.end(); ppos++)
{
@@ -466,14 +583,14 @@
size_t idep = checker - m_checkers.begin();
if((!status[idep].executed || !status[idep].satisfied)
- && ppos->priority == Checker::CP_REQUIRED)
+ && ppos->priority == Checker::PP_REQUIRED)
{
all_preconditions = false;
}
}
else
{
- if(ppos->priority == Checker::CP_REQUIRED)
+ if(ppos->priority == Checker::PP_REQUIRED)
all_preconditions = false;
m_reportView->Print(RS_WARNING, stringize() << vsoPage->Name << ": "
@@ -489,49 +606,59 @@
continue;
}
+ SRChannelMapperPtr srm(new SRChannelMapper());
+ MscPtr result;
+
+ BMscPtr bmsc = boost::dynamic_pointer_cast<BMsc>(msc);
BMscCheckerPtr bmsc_checker = boost::dynamic_pointer_cast<BMscChecker>(msc_checker);
if(bmsc_checker != NULL && bmsc != NULL)
{
- BMscPtr result = bmsc_checker->check(bmsc, srm);
+ BMscPtr bresult = bmsc_checker->check(bmsc, srm);
status[*cpos].executed = true;
-
- if(result != NULL)
- {
- status[*cpos].satisfied = false;
- violated_count++;
-
- m_reportView->Print(RS_ERROR, stringize() << vsoPage->Name << ": "
- << msc_checker->get_property_name() << " violated.", result);
- }
- else
- {
- status[*cpos].satisfied = true;
- satisfied_count++;
-
- m_reportView->Print(RS_NOTICE, stringize() << vsoPage->Name << ": "
- << msc_checker->get_property_name() << " satisfied.");
- }
+ // note: the explicit cast is a workaround for a bug in Visual Studio .NET
+ result = boost::dynamic_pointer_cast<Msc>(bresult);
}
+ HMscPtr hmsc = boost::dynamic_pointer_cast<HMsc>(msc);
HMscCheckerPtr hmsc_checker = boost::dynamic_pointer_cast<HMscChecker>(msc_checker);
if(hmsc_checker != NULL && hmsc != NULL)
{
- HMscPtr result = hmsc_checker->check(hmsc, srm);
+ HMscPtr hresult = hmsc_checker->check(hmsc, srm);
status[*cpos].executed = true;
+ result = boost::dynamic_pointer_cast<Msc>(hresult);
+ }
- if(result != NULL)
+ if(result != NULL)
+ {
+ status[*cpos].satisfied = false;
+ violated_count++;
+
+ // report failure of
+ // - user required tests
+ // - required dependencies of required tests
+ if(boost::get(max_priority_map, *cpos) == Checker::PP_REQUIRED)
{
- status[*cpos].satisfied = false;
- violated_count++;
-
m_reportView->Print(RS_ERROR, stringize() << vsoPage->Name << ": "
<< msc_checker->get_property_name() << " violated.", result);
}
- else
+
+ // if enabled, report failure all executed tests
+ if(boost::get(max_priority_map, *cpos) == Checker::PP_RECOMMENDED
+ && output_level >= OL_WARNING)
{
- status[*cpos].satisfied = true;
- satisfied_count++;
+ m_reportView->Print(RS_WARNING, stringize() << vsoPage->Name << ": "
+ << msc_checker->get_property_name() << " violated.", result);
+ }
+ }
+ else
+ {
+ status[*cpos].satisfied = true;
+ satisfied_count++;
+ // if enabled, report success of user required tests
+ if(boost::get(max_priority_map, *cpos) == Checker::PP_REQUIRED
+ && output_level >= OL_NOTIFY)
+ {
m_reportView->Print(RS_NOTICE, stringize() << vsoPage->Name << ": "
<< msc_checker->get_property_name() << " satisfied.");
}
Modified: trunk/src/view/visio/addon/document.h
===================================================================
--- trunk/src/view/visio/addon/document.h 2009-04-22 21:28:52 UTC (rev 228)
+++ trunk/src/view/visio/addon/document.h 2009-04-25 20:04:08 UTC (rev 229)
@@ -73,6 +73,7 @@
CheckerPtrList m_checkers;
CheckerPtrList::const_iterator find_checker(const std::string& property_name) const;
+ DWORD GetCheckerConfig(const char* subkey, const char* parameter, DWORD default_value) const;
CStudioAddon *m_addon;
Visio::IVApplicationPtr m_vsoApp;
Modified: trunk/src/view/visio/scstudio.nsi
===================================================================
--- trunk/src/view/visio/scstudio.nsi 2009-04-22 21:28:52 UTC (rev 228)
+++ trunk/src/view/visio/scstudio.nsi 2009-04-25 20:04:08 UTC (rev 229)
@@ -21,7 +21,7 @@
; -- General ---------------------------
-!define VERSION "0.2.10"
+!define VERSION "0.3.0"
Name "Sequence Chart Studio"
OutFile "scstudio-setup-${VERSION}.exe"
@@ -30,6 +30,7 @@
!define RegMainPath "Software\Sequence Chart Studio"
!define RegModulesPath "Software\Sequence Chart Studio\Modules"
+!define RegChecksPath "Software\Sequence Chart Studio\Checks"
!define Visio11RegPath "Software\Microsoft\Office\11.0\Visio"
!define Visio12RegPath "Software\Microsoft\Office\12.0\Visio"
@@ -143,6 +144,7 @@
DeleteRegKey HKCU "${RegMainPath}"
; register modules
WriteRegStr HKCU '${RegMainPath}' 'ModulesPath' '$INSTDIR\bin'
+ WriteRegDWORD HKCU '${RegMainPath}' 'OutputLevel' '2'
WriteRegStr HKCU '${RegModulesPath}' 'sc_boundedness' 'scboundedness.dll'
WriteRegStr HKCU '${RegModulesPath}' 'sc_liveness' 'scliveness.dll'
WriteRegStr HKCU '${RegModulesPath}' 'sc_order' 'scorder.dll'
@@ -150,6 +152,14 @@
WriteRegStr HKCU '${RegModulesPath}' 'sc_race' 'scrace.dll'
WriteRegStr HKCU '${RegModulesPath}' 'sc_z120' 'scZ120.dll'
WriteRegStr HKCU '${RegModulesPath}' 'sc_engmann' 'scengmann.dll'
+ ; configure checks
+ WriteRegDWORD HKCU '${RegChecksPath}\Acyclic' 'Priority' '0'
+ WriteRegDWORD HKCU '${RegChecksPath}\Deadlock' 'Priority' '0'
+ WriteRegDWORD HKCU '${RegChecksPath}\FIFO' 'Priority' '0'
+ WriteRegDWORD HKCU '${RegChecksPath}\Livelock' 'Priority' '0'
+ WriteRegDWORD HKCU '${RegChecksPath}\Race Conditions' 'Priority' '0'
+ WriteRegDWORD HKCU '${RegChecksPath}\Unique Instance Names' 'Priority' '2'
+ WriteRegDWORD HKCU '${RegChecksPath}\Universal Boundedness' 'Priority' '0'
; Create uninstaller
WriteUninstaller "$INSTDIR\Uninstall.exe"
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <got...@us...> - 2009-04-26 19:31:02
|
Revision: 230
http://scstudio.svn.sourceforge.net/scstudio/?rev=230&view=rev
Author: gotthardp
Date: 2009-04-26 19:30:44 +0000 (Sun, 26 Apr 2009)
Log Message:
-----------
Implemented the "Options" dialog.
Modified Paths:
--------------
trunk/src/check/structure/name_checker.cpp
trunk/src/check/structure/name_checker.h
trunk/src/view/visio/addon/addon.cpp
trunk/src/view/visio/addon/addon.h
trunk/src/view/visio/addon/dllmodule.rc
trunk/src/view/visio/addon/document.cpp
trunk/src/view/visio/addon/document.h
trunk/src/view/visio/addon/resource.h
trunk/src/view/visio/addon/scstudio.vcproj
Added Paths:
-----------
trunk/src/view/visio/addon/optionsdlg.cpp
trunk/src/view/visio/addon/optionsdlg.h
Modified: trunk/src/check/structure/name_checker.cpp
===================================================================
--- trunk/src/check/structure/name_checker.cpp 2009-04-25 20:04:08 UTC (rev 229)
+++ trunk/src/check/structure/name_checker.cpp 2009-04-26 19:30:44 UTC (rev 230)
@@ -53,7 +53,7 @@
std::sort(current_labels.begin(), current_labels.end());
for(unsigned i = 1; i < current_labels.size(); i++)
if(current_labels[i] == current_labels[i - 1])
- throw DuplicateNamesException();
+ throw DuplicateNamesException(current_labels[i]);
if(m_first_node)
{
@@ -188,7 +188,7 @@
{
name_traverser.traverse(hmsc);
}
- catch(DuplicateNamesException)
+ catch(DuplicateNamesException& err)
{
p = create_duplicate_counter_example(name_traverser.get_reached_elements());
name_traverser.cleanup_traversing_attributes();
Modified: trunk/src/check/structure/name_checker.h
===================================================================
--- trunk/src/check/structure/name_checker.h 2009-04-25 20:04:08 UTC (rev 229)
+++ trunk/src/check/structure/name_checker.h 2009-04-26 19:30:44 UTC (rev 230)
@@ -45,11 +45,22 @@
class DuplicateNamesException: public std::exception
{
public:
+ DuplicateNamesException(const std::string& name)
+ : m_name(name)
+ { }
+ const std::string& get_name() const
+ {
+ return m_name;
+ }
+
const char* what()
{
return "Duplicate names.";
}
+
+private:
+ std::string m_name;
};
class FindFirstNodeListener:public WhiteNodeFoundListener
Modified: trunk/src/view/visio/addon/addon.cpp
===================================================================
--- trunk/src/view/visio/addon/addon.cpp 2009-04-25 20:04:08 UTC (rev 229)
+++ trunk/src/view/visio/addon/addon.cpp 2009-04-26 19:30:44 UTC (rev 230)
@@ -20,6 +20,7 @@
#include "dllmodule.h"
#include "addon.h"
#include "aboutdlg.h"
+#include "optionsdlg.h"
#include "document.h"
#include "extract.h"
#include "errors.h"
@@ -307,6 +308,9 @@
case 205:
TRACE("CStudioAddon::Run() menu item 'Check--Drawing--Repaint'");
return pDocumentMonitor->OnMenuRepaint(vsoApp);
+ case 206:
+ TRACE("CStudioAddon::Run() menu item 'Check--Options'");
+ return DisplayOptions();
default:
TRACE("CStudioAddon::Run() unexpected event id=" << iEvent);
@@ -347,6 +351,15 @@
return VAddon::Unload(wParam, p);
}
+VAORC CStudioAddon::DisplayOptions()
+{
+ TRACE("CStudioAddon::DisplayOptions() called");
+ COptionsDlg dlg;
+
+ dlg.DoModal();
+ return VAORC_SUCCESS;
+}
+
HRESULT CStudioAddon::HandleVisioEvent(
IUnknown *ipSink, short nEventCode, IDispatch *pSourceObj, long nEventID,
long nEventSeqNum, IDispatch *pSubjectObj, VARIANT vMoreInfo, VARIANT *pvResult)
Modified: trunk/src/view/visio/addon/addon.h
===================================================================
--- trunk/src/view/visio/addon/addon.h 2009-04-25 20:04:08 UTC (rev 229)
+++ trunk/src/view/visio/addon/addon.h 2009-04-26 19:30:44 UTC (rev 230)
@@ -34,6 +34,8 @@
virtual VAORC Run(LPVAOV2LSTRUCT pV2L);
virtual VAORC Unload(WORD wParam, LPVOID p);
+ VAORC DisplayOptions();
+
virtual HRESULT HandleVisioEvent(
IUnknown *ipSink, // [in] ipSink [assert]
short nEventCode, // [in] code of event that's firing
Modified: trunk/src/view/visio/addon/dllmodule.rc
===================================================================
--- trunk/src/view/visio/addon/dllmodule.rc 2009-04-25 20:04:08 UTC (rev 229)
+++ trunk/src/view/visio/addon/dllmodule.rc 2009-04-26 19:30:44 UTC (rev 230)
@@ -39,7 +39,24 @@
DEFPUSHBUTTON "&OK",IDOK,184,60,50,14
END
+IDD_OPTIONS DIALOGEX 0, 0, 186, 124
+STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION |
+ WS_SYSMENU
+CAPTION "Options"
+FONT 8, "MS Shell Dlg", 400, 0, 0x1
+BEGIN
+ DEFPUSHBUTTON "OK",IDOK,131,14,50,14
+ PUSHBUTTON "Cancel",IDCANCEL,131,33,50,14
+ LTEXT "Properties to check",IDC_STATIC,5,5,100,8
+ CONTROL "",IDC_CHECKLIST,"SysListView32",LVS_LIST |
+ LVS_SINGLESEL | LVS_ALIGNLEFT | WS_BORDER | WS_TABSTOP,5,
+ 14,100,80
+ LTEXT "Display",IDC_STATIC,5,98,100,8
+ COMBOBOX IDC_OUTPUTLEVEL,5,107,100,61,CBS_DROPDOWNLIST | CBS_SORT |
+ WS_VSCROLL | WS_TABSTOP
+END
+
#ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
@@ -115,6 +132,38 @@
/////////////////////////////////////////////////////////////////////////////
//
+// DESIGNINFO
+//
+
+#ifdef APSTUDIO_INVOKED
+GUIDELINES DESIGNINFO
+BEGIN
+ IDD_OPTIONS, DIALOG
+ BEGIN
+ LEFTMARGIN, 5
+ RIGHTMARGIN, 181
+ TOPMARGIN, 5
+ BOTTOMMARGIN, 119
+ END
+END
+#endif // APSTUDIO_INVOKED
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Dialog Info
+//
+
+IDD_OPTIONS DLGINIT
+BEGIN
+ IDC_OUTPUTLEVEL, 0x403, 3, 0
+0x6464, "\000"
+ 0
+END
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
// String Table
//
Modified: trunk/src/view/visio/addon/document.cpp
===================================================================
--- trunk/src/view/visio/addon/document.cpp 2009-04-25 20:04:08 UTC (rev 229)
+++ trunk/src/view/visio/addon/document.cpp 2009-04-26 19:30:44 UTC (rev 230)
@@ -23,6 +23,7 @@
#include "errors.h"
#include "extract.h"
#include "visualize.h"
+#include "optionsdlg.h"
#include <fstream>
#include "data/msc.h"
@@ -73,7 +74,7 @@
{
// step 1: read the module directory path
HKEY hPathKey;
- if(RegOpenKeyEx(hKey, _T("Software\\Sequence Chart Studio"),
+ if(RegOpenKeyEx(hKey, _T(SCSTUDIO_REGISTRY_ROOT),
0, KEY_READ, &hPathKey) != ERROR_SUCCESS)
{
return 1;
@@ -99,7 +100,7 @@
// step 2: load the modules
HKEY hSubKey;
- if(RegOpenKeyEx(hKey, _T("Software\\Sequence Chart Studio\\Modules"),
+ if(RegOpenKeyEx(hKey, _T(SCSTUDIO_REGISTRY_ROOT) _T("\\Modules"),
0, KEY_READ, &hSubKey) != ERROR_SUCCESS)
{
return 1;
@@ -354,6 +355,11 @@
menuItem33->AddOnArgs = "/event=205";
menuItem33->BeginGroup = true;
+ Visio::IVMenuItemPtr menuItem4 = menu->MenuItems->Add();
+ menuItem4->Caption = "&Options...";
+ menuItem4->AddOnName = ADDON_NAME;
+ menuItem4->AddOnArgs = "/event=206";
+
vsoDocument->SetCustomMenus(vsoMenus);
}
@@ -380,33 +386,6 @@
return m_checkers.end();
}
-DWORD CDocumentMonitor::GetCheckerConfig(const char* subkey, const char* parameter, DWORD default_value) const
-{
- TCHAR _subkey[MAX_PATH];
- mbstowcs(_subkey, subkey, MAX_PATH);
-
- HKEY hPathKey;
- if(RegOpenKeyEx(HKEY_CURRENT_USER, _subkey, 0, KEY_READ, &hPathKey) != ERROR_SUCCESS)
- return default_value;
-
- TCHAR _parameter[MAX_PATH];
- mbstowcs(_parameter, parameter, MAX_PATH);
-
- DWORD valueType;
- DWORD value;
- DWORD valueLength = sizeof(DWORD);
-
- if(RegQueryValueEx(hPathKey, _parameter,
- NULL, &valueType, (LPBYTE)&value, &valueLength) != ERROR_SUCCESS)
- {
- // registry entry doesn't exist, use the default value
- value = default_value;
- }
-
- RegCloseKey(hPathKey);
- return value;
-}
-
struct check_priority_t
{
typedef boost::edge_property_tag kind;
@@ -503,10 +482,10 @@
boost::put(max_priority_map, icheck, Checker::PP_DISREGARDED);
char subkey[MAX_PATH];
- strcpy(subkey, "Software\\Sequence Chart Studio\\Checks\\");
+ strcpy(subkey, SCSTUDIO_REGISTRY_ROOT "\\Checks\\");
strcat(subkey, (*cpos)->get_property_name().c_str());
- int user_priority = GetCheckerConfig(subkey, "Priority", 0);
+ int user_priority = GetRegistryDWORD(subkey, "Priority", DEFAULT_CHECKER_PRIORITY);
if(user_priority < Checker::PP_DISREGARDED)
{
// add dependency for each user required check
@@ -557,7 +536,8 @@
OL_WARNING,
OL_NOTIFY
};
- OutputLevel output_level = (OutputLevel)GetCheckerConfig("Software\\Sequence Chart Studio", "OutputLevel", 1);
+ OutputLevel output_level =
+ (OutputLevel)GetRegistryDWORD(SCSTUDIO_REGISTRY_ROOT, "OutputLevel", DEFAULT_OUTPUT_LEVEL);
int satisfied_count = 0;
int violated_count = 0;
Modified: trunk/src/view/visio/addon/document.h
===================================================================
--- trunk/src/view/visio/addon/document.h 2009-04-25 20:04:08 UTC (rev 229)
+++ trunk/src/view/visio/addon/document.h 2009-04-26 19:30:44 UTC (rev 230)
@@ -73,7 +73,6 @@
CheckerPtrList m_checkers;
CheckerPtrList::const_iterator find_checker(const std::string& property_name) const;
- DWORD GetCheckerConfig(const char* subkey, const char* parameter, DWORD default_value) const;
CStudioAddon *m_addon;
Visio::IVApplicationPtr m_vsoApp;
Added: trunk/src/view/visio/addon/optionsdlg.cpp
===================================================================
--- trunk/src/view/visio/addon/optionsdlg.cpp (rev 0)
+++ trunk/src/view/visio/addon/optionsdlg.cpp 2009-04-26 19:30:44 UTC (rev 230)
@@ -0,0 +1,209 @@
+/*
+ * 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) 2007-2008 Petr Gotthard <pet...@ce...>
+ *
+ * $Id$
+ */
+
+#include "stdafx.h"
+#include "optionsdlg.h"
+
+#include "data/checker.h"
+
+class RegistryValueNotFound
+{ };
+
+DWORD GetRegistryDWORD(HKEY key, const TCHAR* subkey, const TCHAR* parameter)
+{
+ HKEY hPathKey;
+ if(RegOpenKeyEx(key, subkey, 0, KEY_READ, &hPathKey) != ERROR_SUCCESS)
+ {
+ throw RegistryValueNotFound();
+ }
+
+ DWORD valueType;
+ DWORD value;
+ DWORD valueLength = sizeof(DWORD);
+
+ if(RegQueryValueEx(hPathKey, parameter,
+ NULL, &valueType, (LPBYTE)&value, &valueLength) != ERROR_SUCCESS)
+ {
+ throw RegistryValueNotFound();
+ }
+
+ RegCloseKey(hPathKey);
+ return value;
+}
+
+int SetRegistryDWORD(HKEY key, const TCHAR* subkey, const TCHAR* parameter, DWORD value)
+{
+ HKEY hPathKey;
+ if(RegCreateKeyEx(
+ key,
+ subkey,
+ 0,
+ NULL,
+ REG_OPTION_NON_VOLATILE,
+ KEY_ALL_ACCESS,
+ NULL,
+ &hPathKey,
+ NULL) != ERROR_SUCCESS)
+ {
+ return 0;
+ }
+
+ if(RegSetValueEx(hPathKey,
+ parameter,
+ 0, // must be zero
+ REG_DWORD, // value type
+ (LPBYTE)&value, sizeof(DWORD)) != ERROR_SUCCESS)
+ {
+ return 0;
+ }
+
+ RegCloseKey(hPathKey);
+ return 1;
+}
+
+DWORD GetRegistryDWORD(const TCHAR* subkey, const TCHAR* parameter, DWORD default_value)
+{
+ try
+ {
+ return GetRegistryDWORD(HKEY_CURRENT_USER, subkey, parameter);
+ }
+ catch(RegistryValueNotFound)
+ { }
+
+ try
+ {
+ return GetRegistryDWORD(HKEY_LOCAL_MACHINE, subkey, parameter);
+ }
+ catch(RegistryValueNotFound)
+ { }
+
+ return default_value;
+}
+
+DWORD GetRegistryDWORD(const char* subkey, const char* parameter, DWORD default_value)
+{
+ TCHAR _subkey[MAX_PATH];
+ mbstowcs(_subkey, subkey, MAX_PATH);
+
+ TCHAR _parameter[MAX_PATH];
+ mbstowcs(_parameter, parameter, MAX_PATH);
+
+ return GetRegistryDWORD(_subkey, _parameter, default_value);
+}
+
+int COptionsDlg::LoadRegistryData()
+{
+ // (1) load the output level
+ m_ouputtype.InsertString(0, _T("Errors only"));
+ m_ouputtype.InsertString(1, _T("Errors and warnings"));
+ m_ouputtype.InsertString(2, _T("All results"));
+ DWORD output_level = GetRegistryDWORD(SCSTUDIO_REGISTRY_ROOT, "OutputLevel", DEFAULT_OUTPUT_LEVEL);
+ m_ouputtype.SetCurSel(output_level);
+
+ // (2) load checker priorities
+ m_checklist.SetExtendedListViewStyle(LVS_EX_CHECKBOXES);
+
+ HKEY hSubKey;
+ if(RegOpenKeyEx(HKEY_CURRENT_USER, _T(SCSTUDIO_REGISTRY_ROOT) _T("\\Checks"),
+ 0, KEY_READ, &hSubKey) != ERROR_SUCCESS)
+ {
+ return 1;
+ }
+
+ TCHAR achClass[MAX_PATH]; // buffer for class name
+ DWORD cchClassName = MAX_PATH; // size of class string
+ DWORD cSubKeys; // number of subkeys
+ DWORD cbMaxSubKey; // longest subkey size
+ DWORD cchMaxClass; // longest class string
+ DWORD cValues; // number of values for key
+ DWORD cchMaxValue; // longest value name
+ DWORD cbMaxValueData; // longest value data
+ DWORD cbSecurityDescriptor; // size of security descriptor
+ FILETIME ftLastWriteTime; // last write time
+
+ // Get the class name and the value count.
+ RegQueryInfoKey(hSubKey, // key handle
+ achClass, // buffer for class name
+ &cchClassName, // size of class string
+ NULL, // reserved
+ &cSubKeys, // number of subkeys
+ &cbMaxSubKey, // longest subkey size
+ &cchMaxClass, // longest class string
+ &cValues, // number of values for this key
+ &cchMaxValue, // longest value name
+ &cbMaxValueData, // longest value data
+ &cbSecurityDescriptor, // security descriptor
+ &ftLastWriteTime); // last write time
+
+ // enumerate the child keys, until RegEnumKeyEx fails
+ for(int i = cSubKeys; i >= 0; i--)
+ {
+ TCHAR achKey[MAX_PATH];
+ DWORD keyLength = MAX_PATH;
+
+ LONG retCode = RegEnumKeyEx(hSubKey,
+ i,
+ achKey,
+ &keyLength,
+ NULL,
+ NULL,
+ NULL,
+ &ftLastWriteTime);
+ if(retCode == ERROR_SUCCESS)
+ {
+ int item = m_checklist.InsertItem(0, achKey, 0);
+
+ TCHAR subkey[MAX_PATH];
+ _tcscpy(subkey, _T(SCSTUDIO_REGISTRY_ROOT) _T("\\Checks\\"));
+ _tcscat(subkey, achKey);
+
+ DWORD user_priority = GetRegistryDWORD(subkey, _T("Priority"), DEFAULT_CHECKER_PRIORITY);
+ if(user_priority <= Checker::PP_REQUIRED)
+ m_checklist.SetCheckState(item, TRUE);
+ }
+ }
+
+ return 0;
+}
+
+int COptionsDlg::SaveRegistryData()
+{
+ // (1) store the output level
+ DWORD output_level = m_ouputtype.GetCurSel();
+ SetRegistryDWORD(HKEY_CURRENT_USER, _T(SCSTUDIO_REGISTRY_ROOT), _T("OutputLevel"), output_level);
+
+ // (2) store checker priorities
+ for(int item = 0; item < m_checklist.GetItemCount(); item++)
+ {
+ TCHAR item_text[MAX_PATH];
+ m_checklist.GetItemText(item, 0, item_text, MAX_PATH);
+
+ Checker::PreconditionPriority user_priority =
+ m_checklist.GetCheckState(item) ? Checker::PP_REQUIRED : Checker::PP_DISREGARDED;
+
+ TCHAR subkey[MAX_PATH];
+ _tcscpy(subkey, _T(SCSTUDIO_REGISTRY_ROOT) _T("\\Checks\\"));
+ _tcscat(subkey, item_text);
+
+ SetRegistryDWORD(HKEY_CURRENT_USER, subkey, _T("Priority"), user_priority);
+ }
+
+ return 0;
+}
+
+// $Id$
Property changes on: trunk/src/view/visio/addon/optionsdlg.cpp
___________________________________________________________________
Added: svn:keywords
+ Id
Added: svn:eol-style
+ native
Added: trunk/src/view/visio/addon/optionsdlg.h
===================================================================
--- trunk/src/view/visio/addon/optionsdlg.h (rev 0)
+++ trunk/src/view/visio/addon/optionsdlg.h 2009-04-26 19:30:44 UTC (rev 230)
@@ -0,0 +1,81 @@
+/*
+ * 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) 2007-2008 Petr Gotthard <pet...@ce...>
+ *
+ * $Id$
+ */
+
+#pragma once
+
+// Include libraries from the Windows Template Library (WTL).
+// http://wtl.sourceforge.net
+#include <atldlgs.h>
+#include <atlctrls.h>
+#include <atlddx.h>
+
+class COptionsDlg
+ : public ATL::CDialogImpl<COptionsDlg>, public CWinDataExchange<COptionsDlg>
+{
+public:
+ enum { IDD = IDD_OPTIONS };
+ CListViewCtrl m_checklist;
+ CComboBox m_ouputtype;
+
+protected:
+BEGIN_DDX_MAP(COptionsDlg)
+ DDX_CONTROL_HANDLE(IDC_CHECKLIST, m_checklist)
+ DDX_CONTROL_HANDLE(IDC_OUTPUTLEVEL, m_ouputtype)
+END_DDX_MAP()
+
+BEGIN_MSG_MAP(COptionsDlg)
+ MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog)
+ COMMAND_ID_HANDLER(IDOK, OnCloseCmd)
+ COMMAND_ID_HANDLER(IDCANCEL, OnCloseCmd)
+END_MSG_MAP()
+
+// Handler prototypes:
+// LRESULT MessageHandler(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
+// LRESULT CommandHandler(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
+// LRESULT NotifyHandler(int idCtrl, LPNMHDR pnmh, BOOL& bHandled)
+
+ LRESULT OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
+ {
+ CenterWindow(GetParent());
+
+ DoDataExchange();
+ LoadRegistryData();
+
+ return bHandled = FALSE;
+ }
+
+ LRESULT OnCloseCmd(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
+ {
+ if(wID == IDOK)
+ SaveRegistryData();
+
+ EndDialog(wID);
+ return 0;
+ }
+
+ int LoadRegistryData();
+ int SaveRegistryData();
+};
+
+#define SCSTUDIO_REGISTRY_ROOT "Software\\Sequence Chart Studio"
+static const DWORD DEFAULT_CHECKER_PRIORITY = 0;
+static const DWORD DEFAULT_OUTPUT_LEVEL = 2;
+
+DWORD GetRegistryDWORD(const char* subkey, const char* parameter, DWORD default_value);
+
+// $Id$
Property changes on: trunk/src/view/visio/addon/optionsdlg.h
___________________________________________________________________
Added: svn:keywords
+ Id
Added: svn:eol-style
+ native
Modified: trunk/src/view/visio/addon/resource.h
===================================================================
--- trunk/src/view/visio/addon/resource.h 2009-04-25 20:04:08 UTC (rev 229)
+++ trunk/src/view/visio/addon/resource.h 2009-04-26 19:30:44 UTC (rev 230)
@@ -8,13 +8,16 @@
#define IDS_VSL_NAME 102
#define IDS_REPORT_VIEW 103
#define IDD_ABOUTBOX 203
-#define IDC_ABOUT_VERSION 206
+#define IDD_OPTIONS 204
+#define IDC_ABOUT_VERSION 205
+#define IDC_CHECKLIST 206
+#define IDC_OUTPUTLEVEL 207
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
-#define _APS_NEXT_RESOURCE_VALUE 204
+#define _APS_NEXT_RESOURCE_VALUE 206
#define _APS_NEXT_COMMAND_VALUE 32768
#define _APS_NEXT_CONTROL_VALUE 208
#define _APS_NEXT_SYMED_VALUE 105
Modified: trunk/src/view/visio/addon/scstudio.vcproj
===================================================================
--- trunk/src/view/visio/addon/scstudio.vcproj 2009-04-25 20:04:08 UTC (rev 229)
+++ trunk/src/view/visio/addon/scstudio.vcproj 2009-04-26 19:30:44 UTC (rev 230)
@@ -227,6 +227,12 @@
RelativePath=".\fcmp.h">
</File>
<File
+ RelativePath=".\optionsdlg.cpp">
+ </File>
+ <File
+ RelativePath=".\optionsdlg.h">
+ </File>
+ <File
RelativePath=".\reportview.cpp">
</File>
<File
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <got...@us...> - 2009-04-27 19:31:52
|
Revision: 237
http://scstudio.svn.sourceforge.net/scstudio/?rev=237&view=rev
Author: gotthardp
Date: 2009-04-27 19:31:36 +0000 (Mon, 27 Apr 2009)
Log Message:
-----------
Property names reworded. Initial dependencies added.
Modified Paths:
--------------
trunk/src/check/boundedness/universal_boundedness_checker.h
trunk/src/check/liveness/deadlock_checker.h
trunk/src/check/liveness/livelock_checker.h
trunk/src/check/order/fifo_checker.cpp
trunk/src/check/race/race_checker.cpp
trunk/src/check/race/race_checker.h
trunk/src/view/visio/addon/dllmodule.rc
trunk/src/view/visio/addon/document.cpp
trunk/src/view/visio/addon/optionsdlg.cpp
trunk/src/view/visio/scstudio.nsi
Modified: trunk/src/check/boundedness/universal_boundedness_checker.h
===================================================================
--- trunk/src/check/boundedness/universal_boundedness_checker.h 2009-04-27 17:50:12 UTC (rev 236)
+++ trunk/src/check/boundedness/universal_boundedness_checker.h 2009-04-27 19:31:36 UTC (rev 237)
@@ -142,7 +142,7 @@
*/
// note: DLL in Windows cannot return pointers to static data
virtual std::string get_property_name() const
- { return "Universal Boundedness"; }
+ { return "Universally Bounded"; }
virtual PreconditionList get_preconditions(MscPtr msc) const;
Modified: trunk/src/check/liveness/deadlock_checker.h
===================================================================
--- trunk/src/check/liveness/deadlock_checker.h 2009-04-27 17:50:12 UTC (rev 236)
+++ trunk/src/check/liveness/deadlock_checker.h 2009-04-27 19:31:36 UTC (rev 237)
@@ -130,7 +130,7 @@
*/
// note: DLL in Windows cannot return pointers to static data
virtual std::string get_property_name() const
- { return "Deadlock"; }
+ { return "Deadlock Free"; }
virtual PreconditionList get_preconditions(MscPtr msc) const;
Modified: trunk/src/check/liveness/livelock_checker.h
===================================================================
--- trunk/src/check/liveness/livelock_checker.h 2009-04-27 17:50:12 UTC (rev 236)
+++ trunk/src/check/liveness/livelock_checker.h 2009-04-27 19:31:36 UTC (rev 237)
@@ -104,7 +104,7 @@
*/
// note: DLL in Windows cannot return pointers to static data
virtual std::string get_property_name() const
- { return "Livelock"; }
+ { return "Livelock Free"; }
virtual PreconditionList get_preconditions(MscPtr msc) const;
Modified: trunk/src/check/order/fifo_checker.cpp
===================================================================
--- trunk/src/check/order/fifo_checker.cpp 2009-04-27 17:50:12 UTC (rev 236)
+++ trunk/src/check/order/fifo_checker.cpp 2009-04-27 19:31:36 UTC (rev 237)
@@ -26,7 +26,8 @@
Checker::PreconditionList FifoChecker::get_preconditions(MscPtr msc) const
{
Checker::PreconditionList result;
- // no preconditions
+ result.push_back(CheckerPrecondition("Acyclic", PP_REQUIRED));
+
return result;
}
Modified: trunk/src/check/race/race_checker.cpp
===================================================================
--- trunk/src/check/race/race_checker.cpp 2009-04-27 17:50:12 UTC (rev 236)
+++ trunk/src/check/race/race_checker.cpp 2009-04-27 19:31:36 UTC (rev 237)
@@ -242,7 +242,23 @@
Checker::PreconditionList RaceChecker::get_preconditions(MscPtr msc) const
{
Checker::PreconditionList result;
- // no preconditions
+
+ // checker for HMSC assumes msc to be deadlock free, livelock free, acyclic and FIFO
+ HMscPtr hmsc = boost::dynamic_pointer_cast<HMsc>(msc);
+ if(hmsc != NULL)
+ {
+ result.push_back(CheckerPrecondition("Deadlock Free", PP_REQUIRED));
+ result.push_back(CheckerPrecondition("Livelock Free", PP_REQUIRED));
+ }
+
+ // FIXME: Acylic and FIFO cannot check HMSC (bug #2557089)
+ BMscPtr bmsc = boost::dynamic_pointer_cast<BMsc>(msc);
+ if(bmsc != NULL)
+ {
+ result.push_back(CheckerPrecondition("Acyclic", PP_REQUIRED));
+ result.push_back(CheckerPrecondition("FIFO", PP_REQUIRED));
+ }
+
return result;
}
Modified: trunk/src/check/race/race_checker.h
===================================================================
--- trunk/src/check/race/race_checker.h 2009-04-27 17:50:12 UTC (rev 236)
+++ trunk/src/check/race/race_checker.h 2009-04-27 19:31:36 UTC (rev 237)
@@ -226,7 +226,7 @@
*/
// note: DLL in Windows cannot return pointers to static data
virtual std::string get_property_name() const
- { return "Race Conditions"; }
+ { return "Race Free"; }
virtual PreconditionList get_preconditions(MscPtr msc) const;
Modified: trunk/src/view/visio/addon/dllmodule.rc
===================================================================
--- trunk/src/view/visio/addon/dllmodule.rc 2009-04-27 17:50:12 UTC (rev 236)
+++ trunk/src/view/visio/addon/dllmodule.rc 2009-04-27 19:31:36 UTC (rev 237)
@@ -39,7 +39,7 @@
DEFPUSHBUTTON "&OK",IDOK,184,60,50,14
END
-IDD_OPTIONS DIALOGEX 0, 0, 186, 124
+IDD_OPTIONS DIALOGEX 0, 0, 186, 134
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION |
WS_SYSMENU
CAPTION "Options"
@@ -47,12 +47,12 @@
BEGIN
DEFPUSHBUTTON "OK",IDOK,131,14,50,14
PUSHBUTTON "Cancel",IDCANCEL,131,33,50,14
- LTEXT "Properties to check",IDC_STATIC,5,5,100,8
+ LTEXT "Properties to check",IDC_STATIC,5,5,110,8
CONTROL "",IDC_CHECKLIST,"SysListView32",LVS_REPORT |
- LVS_SINGLESEL | LVS_ALIGNLEFT | LVS_NOCOLUMNHEADER |
- WS_BORDER | WS_TABSTOP,5,14,103,79
- LTEXT "Display",IDC_STATIC,5,98,100,8
- COMBOBOX IDC_OUTPUTLEVEL,5,107,102,61,CBS_DROPDOWNLIST | CBS_SORT |
+ LVS_SINGLESEL | LVS_ALIGNLEFT | WS_BORDER | WS_TABSTOP,5,
+ 14,110,90
+ LTEXT "Display",IDC_STATIC,5,108,110,8
+ COMBOBOX IDC_OUTPUTLEVEL,5,117,110,61,CBS_DROPDOWNLIST | CBS_SORT |
WS_VSCROLL | WS_TABSTOP
END
@@ -143,7 +143,7 @@
LEFTMARGIN, 5
RIGHTMARGIN, 181
TOPMARGIN, 5
- BOTTOMMARGIN, 119
+ BOTTOMMARGIN, 129
END
END
#endif // APSTUDIO_INVOKED
Modified: trunk/src/view/visio/addon/document.cpp
===================================================================
--- trunk/src/view/visio/addon/document.cpp 2009-04-27 17:50:12 UTC (rev 236)
+++ trunk/src/view/visio/addon/document.cpp 2009-04-27 19:31:36 UTC (rev 237)
@@ -573,20 +573,14 @@
if(ppos->priority == Checker::PP_REQUIRED)
all_preconditions = false;
- m_reportView->Print(RS_WARNING, stringize() << vsoPage->Name << ": "
+ m_reportView->Print(RS_WARNING, stringize() << "internal error: "
<< "skipping " << msc_checker->get_property_name()
<< " due to unknown dependency: " << ppos->property_name);
}
}
- if(!all_preconditions)
- {
- m_reportView->Print(RS_WARNING, stringize() << vsoPage->Name << ": "
- << msc_checker->get_property_name() << " skipped.");
- continue;
- }
+ SRChannelMapperPtr srm(new SRChannelMapper());
- SRChannelMapperPtr srm(new SRChannelMapper());
MscPtr result = NULL;
bool result_set = false;
@@ -594,8 +588,14 @@
BMscCheckerPtr bmsc_checker = boost::dynamic_pointer_cast<BMscChecker>(msc_checker);
if(bmsc_checker != NULL && bmsc != NULL)
{
+ if(!all_preconditions)
+ {
+ m_reportView->Print(RS_WARNING, stringize() << vsoPage->Name << ": "
+ << msc_checker->get_property_name() << " skipped.");
+ continue;
+ }
+
BMscPtr bresult = bmsc_checker->check(bmsc, srm);
- status[*cpos].executed = true;
// note: the explicit cast is a workaround for a bug in Visual Studio .NET
result = boost::dynamic_pointer_cast<Msc>(bresult);
result_set = true;
@@ -605,14 +605,27 @@
HMscCheckerPtr hmsc_checker = boost::dynamic_pointer_cast<HMscChecker>(msc_checker);
if(hmsc_checker != NULL && hmsc != NULL)
{
+ if(!all_preconditions)
+ {
+ m_reportView->Print(RS_WARNING, stringize() << vsoPage->Name << ": "
+ << msc_checker->get_property_name() << " skipped.");
+ continue;
+ }
+
HMscPtr hresult = hmsc_checker->check(hmsc, srm);
- status[*cpos].executed = true;
result = boost::dynamic_pointer_cast<Msc>(hresult);
result_set = true;
}
- if(result != NULL)
+ if(!result_set)
{
+ // checker is not compatible with the drawing
+ status[*cpos].executed = false;
+ }
+ else if(result != NULL)
+ {
+ // check failed
+ status[*cpos].executed = true;
status[*cpos].satisfied = false;
violated_count++;
@@ -633,8 +646,10 @@
<< msc_checker->get_property_name() << " violated.", result);
}
}
- else if(result_set)
+ else
{
+ // check succeeded
+ status[*cpos].executed = true;
status[*cpos].satisfied = true;
satisfied_count++;
Modified: trunk/src/view/visio/addon/optionsdlg.cpp
===================================================================
--- trunk/src/view/visio/addon/optionsdlg.cpp 2009-04-27 17:50:12 UTC (rev 236)
+++ trunk/src/view/visio/addon/optionsdlg.cpp 2009-04-27 19:31:36 UTC (rev 237)
@@ -116,8 +116,8 @@
m_ouputtype.SetCurSel(output_level);
// (2) load checker priorities
- m_checklist.SetExtendedListViewStyle(LVS_EX_CHECKBOXES);
- m_checklist.InsertColumn(0, _T("Checker"), LVCFMT_LEFT, 150);
+ m_checklist.SetExtendedListViewStyle(LVS_EX_CHECKBOXES | LVS_EX_FULLROWSELECT);
+ m_checklist.InsertColumn(0, _T("Name"), LVCFMT_LEFT, 150);
HKEY hSubKey;
if(RegOpenKeyEx(HKEY_CURRENT_USER, _T(SCSTUDIO_REGISTRY_ROOT) _T("\\Checks"),
Modified: trunk/src/view/visio/scstudio.nsi
===================================================================
--- trunk/src/view/visio/scstudio.nsi 2009-04-27 17:50:12 UTC (rev 236)
+++ trunk/src/view/visio/scstudio.nsi 2009-04-27 19:31:36 UTC (rev 237)
@@ -153,13 +153,13 @@
WriteRegStr HKCU '${RegModulesPath}' 'sc_z120' 'scZ120.dll'
WriteRegStr HKCU '${RegModulesPath}' 'sc_engmann' 'scengmann.dll'
; configure checks
+ WriteRegDWORD HKCU '${RegChecksPath}\Deadlock Free' 'Priority' '0'
+ WriteRegDWORD HKCU '${RegChecksPath}\Livelock Free' 'Priority' '0'
WriteRegDWORD HKCU '${RegChecksPath}\Acyclic' 'Priority' '0'
- WriteRegDWORD HKCU '${RegChecksPath}\Deadlock' 'Priority' '0'
WriteRegDWORD HKCU '${RegChecksPath}\FIFO' 'Priority' '0'
- WriteRegDWORD HKCU '${RegChecksPath}\Livelock' 'Priority' '0'
- WriteRegDWORD HKCU '${RegChecksPath}\Race Conditions' 'Priority' '0'
+ WriteRegDWORD HKCU '${RegChecksPath}\Race Free' 'Priority' '0'
WriteRegDWORD HKCU '${RegChecksPath}\Unique Instance Names' 'Priority' '2'
- WriteRegDWORD HKCU '${RegChecksPath}\Universal Boundedness' 'Priority' '0'
+ WriteRegDWORD HKCU '${RegChecksPath}\Universally Bounded' 'Priority' '0'
; Create uninstaller
WriteUninstaller "$INSTDIR\Uninstall.exe"
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <got...@us...> - 2009-05-05 12:03:23
|
Revision: 245
http://scstudio.svn.sourceforge.net/scstudio/?rev=245&view=rev
Author: gotthardp
Date: 2009-05-05 12:03:16 +0000 (Tue, 05 May 2009)
Log Message:
-----------
Feature request #2557089 implemented: Generic checker for BMSC in HMSC is now available. FIFO and Acyclic properties are now checked also for HMSC and Race preconditions were fixed.
Modified Paths:
--------------
trunk/src/check/order/acyclic_checker.h
trunk/src/check/order/fifo_checker.h
trunk/src/check/race/race_checker.cpp
trunk/src/data/CMakeLists.txt
Added Paths:
-----------
trunk/src/data/hmsc_reference_checker.h
Modified: trunk/src/check/order/acyclic_checker.h
===================================================================
--- trunk/src/check/order/acyclic_checker.h 2009-05-03 19:13:46 UTC (rev 244)
+++ trunk/src/check/order/acyclic_checker.h 2009-05-05 12:03:16 UTC (rev 245)
@@ -19,6 +19,7 @@
#include "data/checker.h"
#include "data/msc.h"
#include "data/dfs_events_traverser.h"
+#include "data/hmsc_reference_checker.h"
#include "check/order/export.h"
class AcyclicChecker;
@@ -38,7 +39,8 @@
};
-class SCORDER_EXPORT AcyclicChecker: public Checker, public BMscChecker
+class SCORDER_EXPORT AcyclicChecker
+ : public Checker, public BMscChecker, public HMscReferenceChecker<AcyclicChecker>
{
protected:
Modified: trunk/src/check/order/fifo_checker.h
===================================================================
--- trunk/src/check/order/fifo_checker.h 2009-05-03 19:13:46 UTC (rev 244)
+++ trunk/src/check/order/fifo_checker.h 2009-05-05 12:03:16 UTC (rev 245)
@@ -25,6 +25,7 @@
#include "data/msc.h"
#include "data/checker.h"
#include "check/pseudocode/visual_closure_initiator.h"
+#include "data/hmsc_reference_checker.h"
#include "check/order/export.h"
class FifoChecker;
@@ -32,7 +33,8 @@
typedef std::stack<Event*> EventPStack;
typedef boost::shared_ptr<FifoChecker> FifoCheckerPtr;
-class SCORDER_EXPORT FifoChecker: public Checker, public BMscChecker
+class SCORDER_EXPORT FifoChecker
+ : public Checker, public BMscChecker, public HMscReferenceChecker<FifoChecker>
{
protected:
Modified: trunk/src/check/race/race_checker.cpp
===================================================================
--- trunk/src/check/race/race_checker.cpp 2009-05-03 19:13:46 UTC (rev 244)
+++ trunk/src/check/race/race_checker.cpp 2009-05-05 12:03:16 UTC (rev 245)
@@ -251,13 +251,8 @@
result.push_back(CheckerPrecondition(L"Livelock Free", PP_REQUIRED));
}
- // FIXME: Acylic and FIFO cannot check HMSC (bug #2557089)
- BMscPtr bmsc = boost::dynamic_pointer_cast<BMsc>(msc);
- if(bmsc != NULL)
- {
- result.push_back(CheckerPrecondition(L"Acyclic", PP_REQUIRED));
- result.push_back(CheckerPrecondition(L"FIFO", PP_REQUIRED));
- }
+ result.push_back(CheckerPrecondition(L"Acyclic", PP_REQUIRED));
+ result.push_back(CheckerPrecondition(L"FIFO", PP_REQUIRED));
return result;
}
Modified: trunk/src/data/CMakeLists.txt
===================================================================
--- trunk/src/data/CMakeLists.txt 2009-05-03 19:13:46 UTC (rev 244)
+++ trunk/src/data/CMakeLists.txt 2009-05-05 12:03:16 UTC (rev 245)
@@ -25,6 +25,7 @@
dfs_bmsc_graph_traverser.cpp
dfs_bmsc_graph_traverser.h
time.h
+ hmsc_reference_checker.h
)
# build import-export formatters
Added: trunk/src/data/hmsc_reference_checker.h
===================================================================
--- trunk/src/data/hmsc_reference_checker.h (rev 0)
+++ trunk/src/data/hmsc_reference_checker.h 2009-05-05 12:03:16 UTC (rev 245)
@@ -0,0 +1,114 @@
+/*
+ * 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 Petr Gotthard <pet...@ce...>
+ *
+ * $Id$
+ */
+
+#ifndef _HMSC_REFERENCE_CHECKER_H
+#define _HMSC_REFERENCE_CHECKER_H
+
+#include "data/checker.h"
+#include "data/dfs_hmsc_traverser.h"
+#include "check/pseudocode/msc_duplicators.h"
+
+/**
+ * Represents a property violation in a BMSC referenced from a given reference node.
+ */
+class ReferenceException
+{
+public:
+ ReferenceException(ReferenceNodePtr reference, BMscPtr counterexample)
+ : m_reference(reference), m_counterexample(counterexample)
+ { }
+
+ ReferenceNodePtr get_reference() const
+ {
+ return m_reference;
+ }
+
+ BMscPtr get_counterexample() const
+ {
+ return m_counterexample;
+ }
+
+private:
+ ReferenceNodePtr m_reference;
+ BMscPtr m_counterexample;
+};
+
+/**
+ * Walks through all references in HMSC and invokes a given checker.
+ */
+class ReferenceWalker:public WhiteNodeFoundListener
+{
+public:
+ ReferenceWalker(BMscChecker* bmsc_checker, ChannelMapperPtr mapper)
+ : m_checker(bmsc_checker), m_mapper(mapper)
+ { }
+
+ void on_white_node_found(HMscNode* node)
+ {
+ ReferenceNodePtr reference_node = dynamic_cast<ReferenceNode*>(node);
+ if(reference_node != NULL)
+ {
+ BMscPtr bmsc = reference_node->get_bmsc();
+ BMscPtr counterexample = m_checker->check(bmsc, m_mapper);
+ if(counterexample != NULL)
+ throw ReferenceException(reference_node, counterexample);
+ }
+ }
+
+private:
+ BMscChecker* m_checker;
+ ChannelMapperPtr m_mapper;
+};
+
+/**
+ * Abstract checker that verifies a property against every BMsc in HMsc.
+ */
+template <class BMSC_CHECKER>
+class HMscReferenceChecker: public HMscChecker
+{
+public:
+ HMscPtr check(HMscPtr hmsc, ChannelMapperPtr chm)
+ {
+ HMscPtr example;
+
+ DFSBMscGraphTraverser traverser;
+ // the descendant is expected to be BMscChecker
+ ReferenceWalker walker(dynamic_cast<BMSC_CHECKER*>(this), chm);
+ traverser.add_white_node_found_listener(&walker);
+ try
+ {
+ traverser.traverse(hmsc);
+ }
+ catch (ReferenceException &error)
+ {
+ HMscPathDuplicator duplicator;
+ example = duplicator.duplicate_path(traverser.get_reached_elements());
+
+ MscElementPtr element = duplicator.get_copy(error.get_reference().get());
+ ReferenceNodePtr reference = boost::dynamic_pointer_cast<ReferenceNode>(element);
+ reference->set_marked(true);
+ reference->set_msc(error.get_counterexample());
+ }
+
+ return example;
+ }
+};
+
+#endif /* _HMSC_REFERENCE_CHECKER_H */
+
+// $Id$
Property changes on: trunk/src/data/hmsc_reference_checker.h
___________________________________________________________________
Added: svn:keywords
+ Id
Added: svn:eol-style
+ native
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|