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. |