|
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 unload the module
+ m_open_modules.push_back(module);
+ }
+ }
+
+ delete[] valName;
+ delete[] valData;
+
+ return 0;
+}
+
void CDocumentMonitor::InitMenu(Visio::IVApplicationPtr vsoApp)
{
Visio::IVUIObjectPtr vsoMenus = NULL;
@@ -75,16 +201,22 @@
menuItem1->BeginGroup = true;
menuItem1->CmdNum = Visio::visCmdHierarchical;
+ m_reportMenuItem = menuItem1->MenuItems->Add();
+ m_reportMenuItem->Caption = "Verification &Report";
+ m_reportMenuItem->AddOnName = ADDON_NAME;
+ m_reportMenuItem->AddOnArgs = "/event=201";
+
Visio::IVMenuItemPtr menuItem2 = menu->MenuItems->Add();
menuItem2->Caption = "&Run";
menuItem2->AddOnName = ADDON_NAME;
- menuItem2->AddOnArgs = "/event=201";
+ menuItem2->AddOnArgs = "/event=202";
menuItem2->BeginGroup = true;
- m_reportMenuItem = menuItem1->MenuItems->Add();
- m_reportMenuItem->Caption = "Verification &Report";
- m_reportMenuItem->AddOnName = ADDON_NAME;
- m_reportMenuItem->AddOnArgs = "/event=202";
+ Visio::IVMenuItemPtr menuItem3 = menu->MenuItems->Add();
+ menuItem3->Caption = "&Export Drawing...";
+ menuItem3->AddOnName = ADDON_NAME;
+ menuItem3->AddOnArgs = "/event=203";
+ menuItem3->BeginGroup = true;
vsoDocument->SetCustomMenus(vsoMenus);
}
@@ -104,21 +236,48 @@
if(msc != NULL)
{
BMscPtr bmsc = boost::dynamic_pointer_cast<BMsc>(msc);
- if(bmsc != NULL)
+ HMscPtr hmsc = boost::dynamic_pointer_cast<HMsc>(msc);
+
+ SRChannelMapperPtr srm = SRChannelMapper::instance();
+
+ for(CheckerPtrList::const_iterator cpos = m_checkers.begin();
+ cpos != m_checkers.end(); cpos++)
{
- m_reportView->Print(RS_NOTICE, "No error detected.");
- return VAORC_SUCCESS;
- }
+ BMscCheckerPtr bmsc_checker = boost::dynamic_pointer_cast<BMscChecker>(*cpos);
+ HMscCheckerPtr hmsc_checker = boost::dynamic_pointer_cast<HMscChecker>(*cpos);
- HMscPtr hmsc = boost::dynamic_pointer_cast<HMsc>(msc);
- if(hmsc != NULL)
- {
- m_reportView->Print(RS_NOTICE, "No error detected.");
- return VAORC_SUCCESS;
+ if(bmsc_checker != NULL && bmsc != NULL)
+ {
+ BMscPtr result = bmsc_checker->check(bmsc, srm);
+ if(result != NULL)
+ {
+ m_reportView->Print(RS_ERROR, stringize()
+ << (*cpos)->get_description() << " violated.");
+ }
+ else
+ {
+ m_reportView->Print(RS_NOTICE, stringize()
+ << (*cpos)->get_description() << " satisfied.");
+ }
+ }
+
+ if(hmsc_checker != NULL && hmsc != NULL)
+ {
+ HMscPtr result = hmsc_checker->check(hmsc, srm);
+ if(result != NULL)
+ {
+ m_reportView->Print(RS_ERROR, stringize()
+ << (*cpos)->get_description() << " violated.");
+ }
+ else
+ {
+ m_reportView->Print(RS_NOTICE, stringize()
+ << (*cpos)->get_description() << " satisfied.");
+ }
+ }
}
- // something strange have happened
- return VAORC_FAILURE;
+ return VAORC_SUCCESS;
}
else
{
@@ -128,6 +287,107 @@
}
}
+std::wstring filter_to_wstring(const std::string& str)
+{
+ std::wstring res;
+
+ const char *spos = str.data();
+ size_t ssize = str.length();
+ while(ssize > 0)
+ {
+ int inc;
+ // this converts '@' to '\0'
+ // note: this function is intended only for CFileDialog filter strings
+ if(*spos == '\0' || *spos == '@')
+ {
+ res.push_back(wchar_t('\0'));
+ inc = 1;
+ }
+ else
+ {
+ wchar_t wc;
+ inc = mbtowc(&wc, spos, ssize);
+ res.push_back(wc);
+ }
+
+ spos += inc;
+ ssize -= inc;
+ }
+ return res;
+}
+
+VAORC CDocumentMonitor::OnMenuExport(Visio::IVApplicationPtr vsoApp)
+{
+ std::string extension;
+ std::stringstream filter;
+
+ // construct the filter string
+ // _T("Text Documents (*.txt)\0*.txt\0All Files (*.*)\0*.*\0")
+ for(FormatterPtrList::const_iterator fpos = m_formatters.begin();
+ fpos != m_formatters.end(); fpos++)
+ {
+ filter << (*fpos)->get_description()
+ << " (*." << (*fpos)->get_extension() << ")@*." << (*fpos)->get_extension() << "@";
+
+ if(extension.empty())
+ extension = (*fpos)->get_extension();
+ }
+ // append a filter to display all files
+ filter << "All Files (*.*)@*.*@";
+ // translate char --> TCHAR and '@' --> '\0'
+ // note: Windows stringstream cannot handle '\0' inside a string
+ std::wstring extension_w = filter_to_wstring(extension);
+ std::wstring filter_w = filter_to_wstring(filter.str());
+
+ CFileDialog dialog(FALSE,
+ extension_w.c_str(), NULL,
+ OFN_EXPLORER | OFN_HIDEREADONLY | OFN_ENABLESIZING | OFN_OVERWRITEPROMPT,
+ filter_w.c_str());
+ INT_PTR res = dialog.DoModal();
+
+ if(res != IDOK)
+ return VAORC_SUCCESS;
+
+ TRACE("OnMenuExport() saving " << dialog.m_szFileTitle << " as " << dialog.m_szFileName);
+
+ char fileName[MAX_PATH];
+ wcstombs(fileName, dialog.m_szFileName, MAX_PATH);
+
+ char *fileExtension = strrchr(fileName, '.');
+ if(fileExtension == NULL || *fileExtension == '\0')
+ {
+ MessageBox(GetActiveWindow(),
+ _T("No extension given. Cannot determine file type."), _T("Error"), MB_OK | MB_ICONEXCLAMATION);
+ return VAORC_FAILURE;
+ }
+
+ // look for the appropriate formatter
+ for(FormatterPtrList::const_iterator fpos = m_formatters.begin();
+ fpos != m_formatters.end(); fpos++)
+ {
+ if(stricmp(fileExtension+1, (*fpos)->get_extension().c_str()) == 0)
+ {
+ 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;
+ }
+
+ ExportActiveDocument(*fpos, stream);
+
+ stream.close();
+ return VAORC_SUCCESS;
+ }
+ }
+
+ MessageBox(GetActiveWindow(),
+ _T("No suitable export filter found."), _T("Error"), MB_OK | MB_ICONEXCLAMATION);
+ return VAORC_FAILURE;
+}
+
VAORC CDocumentMonitor::OnMenuWindowsReporter(Visio::IVApplicationPtr vsoApp)
{
if(m_reportVisible)
@@ -173,6 +433,36 @@
m_reportVisible = false;
}
+void CDocumentMonitor::ExportActiveDocument(const FormatterPtr& formatter, std::ostream& stream)
+{
+ if(!m_reportVisible)
+ ShowReportView(m_vsoApp);
+
+ // clear the verification report
+ m_reportView->Reset();
+
+ CDrawingExtractor extractor(m_reportView);
+ // 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)
+ {
+ formatter->save_msc(stream, msc);
+ }
+ else
+ {
+ m_reportView->Print(RS_NOTICE,
+ stringize() << "Cannot export '" << vsoPage->Name << "'");
+ }
+ }
+
+ m_reportView->Print(RS_NOTICE,
+ stringize() << "File saved.");
+}
+
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-04 16:16:42 UTC (rev 150)
+++ trunk/src/view/visio/addon/document.h 2009-01-04 19:25:27 UTC (rev 151)
@@ -18,6 +18,8 @@
#pragma once
#include "reportview.h"
+#include "data/formatter.h"
+#include "data/checker.h"
#include <Vaddon.h>
@@ -34,10 +36,13 @@
VAORC OnMenuRun(Visio::IVApplicationPtr vsoApp);
VAORC OnMenuWindowsReporter(Visio::IVApplicationPtr vsoApp);
+ VAORC OnMenuExport(Visio::IVApplicationPtr vsoApp);
void ShowReportView(Visio::IVApplicationPtr vsoApp);
void OnHideReportView();
+ void ExportActiveDocument(const FormatterPtr& formatter, std::ostream& stream);
+
Visio::IVShapePtr FindShape(const _bstr_t& id);
int SelectShapes(const std::vector<_bstr_t>& ids);
@@ -48,6 +53,14 @@
private:
CDocumentMonitor(const CDocumentMonitor &other); // not implemented
+ int LoadModulesFromRegistry(HKEY hKey, LPCTSTR lpSubKey);
+
+ std::vector<HINSTANCE> m_open_modules;
+ typedef std::vector<FormatterPtr> FormatterPtrList;
+ FormatterPtrList m_formatters;
+ typedef std::vector<CheckerPtr> CheckerPtrList;
+ CheckerPtrList m_checkers;
+
CStudioAddon *m_addon;
Visio::IVApplicationPtr m_vsoApp;
Visio::IVDocumentPtr m_vsoDocument;
Modified: trunk/src/view/visio/addon/extract.cpp
===================================================================
--- trunk/src/view/visio/addon/extract.cpp 2009-01-04 16:16:42 UTC (rev 150)
+++ trunk/src/view/visio/addon/extract.cpp 2009-01-04 19:25:27 UTC (rev 151)
@@ -201,8 +201,7 @@
// shape connected to this point
Visio::IVShapePtr shape = connect->FromSheet;
- // create coregion event
- CoregionEventPtr event = area->add_event(new CoregionEvent());
+ CoregionEventPtr event;
// connect the message
TShapeType type = get_shape_type(shape);
@@ -213,7 +212,9 @@
CompleteMessagePtr message = find_message<CompleteMessage>(messages, shape->ID);
if(message == NULL)
continue;
-
+ // create coregion event
+ event = area->add_event(new CoregionEvent());
+ // connect the message
switch(connect->FromPart)
{
case visBegin:
@@ -237,7 +238,9 @@
IncompleteMessagePtr message = find_message<IncompleteMessage>(messages, shape->ID);
if(message == NULL)
continue;
-
+ // create coregion event
+ event = area->add_event(new CoregionEvent());
+ // connect the message
if(connect->FromPart == visBegin)
message->glue_event(event);
else
@@ -254,7 +257,9 @@
IncompleteMessagePtr message = find_message<IncompleteMessage>(messages, shape->ID);
if(message == NULL)
continue;
-
+ // create coregion event
+ event = area->add_event(new CoregionEvent());
+ // connect the message
if(connect->FromPart == visEnd)
message->glue_event(event);
else
Modified: trunk/src/view/visio/addon/reportview.cpp
===================================================================
--- trunk/src/view/visio/addon/reportview.cpp 2009-01-04 16:16:42 UTC (rev 150)
+++ trunk/src/view/visio/addon/reportview.cpp 2009-01-04 19:25:27 UTC (rev 151)
@@ -41,9 +41,9 @@
{
const char **ppstr = (const char**)dwCookie;
- if(strlen(*ppstr) < cb)
+ if(strlen(*ppstr) < (size_t)cb)
{
- *pcb = strlen(*ppstr);
+ *pcb = (LONG)strlen(*ppstr);
memcpy(pbBuff, *ppstr, *pcb );
}
else
Modified: trunk/src/view/visio/scstudio.nsi
===================================================================
--- trunk/src/view/visio/scstudio.nsi 2009-01-04 16:16:42 UTC (rev 150)
+++ trunk/src/view/visio/scstudio.nsi 2009-01-04 19:25:27 UTC (rev 151)
@@ -26,6 +26,8 @@
InstallDir "$PROGRAMFILES\Sequence Chart Studio"
+!define ModuleRegPath "Software\Sequence Chart Studio\Modules"
+
RequestExecutionLevel user
; -- Pages -----------------------------
@@ -90,8 +92,14 @@
File "stencils\Sequence Chart Studio\HMSC.vsx"
File "stencils\Sequence Chart Studio\MSC.vtx"
+ ; modify Visio add-on paths
${AppendRegStr} ${VisioRegPath} "StencilPath" "$INSTDIR\stencils"
${AppendRegStr} ${VisioRegPath} "TemplatePath" "$INSTDIR\stencils"
+ ; register modules
+ WriteRegStr HKCU '${ModuleRegPath}' 'init_liveness' 'scliveness.dll'
+ WriteRegStr HKCU '${ModuleRegPath}' 'init_order' 'scorder.dll'
+ WriteRegStr HKCU '${ModuleRegPath}' 'init_race' 'scrace.dll'
+ WriteRegStr HKCU '${ModuleRegPath}' 'init_z120' 'scZ120.dll'
;Create uninstaller
WriteUninstaller "$INSTDIR\Uninstall.exe"
@@ -110,7 +118,9 @@
RMDir /r "$INSTDIR\stencils\Sequence Chart Studio"
RMDir "$INSTDIR\stencils"
- ; FIXME: the registry entries need to be removed
+ ; TODO: modify Visio add-on paths
+ ; unregister modules
+ DeleteRegKey HKCU "Software\Sequence Chart Studio"
Delete "$INSTDIR\Uninstall.exe"
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|