|
From: <mar...@us...> - 2010-03-07 21:26:48
|
Revision: 668
http://scstudio.svn.sourceforge.net/scstudio/?rev=668&view=rev
Author: martinnrt
Date: 2010-03-07 21:26:40 +0000 (Sun, 07 Mar 2010)
Log Message:
-----------
Modified Paths:
--------------
trunk/src/check/time/CMakeLists.txt
trunk/tests/CMakeLists.txt
Added Paths:
-----------
trunk/src/check/time/find_block.cpp
trunk/src/check/time/find_block.cpp~
trunk/src/check/time/find_block.h
trunk/src/check/time/find_block.h~
trunk/tests/acyclic_checker_test
trunk/tests/find_block_test.cpp
Modified: trunk/src/check/time/CMakeLists.txt
===================================================================
--- trunk/src/check/time/CMakeLists.txt 2010-03-06 12:19:42 UTC (rev 667)
+++ trunk/src/check/time/CMakeLists.txt 2010-03-07 21:26:40 UTC (rev 668)
@@ -12,6 +12,8 @@
time_trace_race.h
hmsc_all_paths.h
hmsc_all_paths.cpp
+ find_block.h
+ find_block.cpp
)
TARGET_LINK_LIBRARIES(sctime
Added: trunk/src/check/time/find_block.cpp
===================================================================
--- trunk/src/check/time/find_block.cpp (rev 0)
+++ trunk/src/check/time/find_block.cpp 2010-03-07 21:26:40 UTC (rev 668)
@@ -0,0 +1,179 @@
+/*
+ * 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) 2010 Martin Vodila <fp...@ma...>
+ *
+ * $Id:
+ */
+
+
+#include "check/time/find_block.h"
+
+void MyTraverse::on_white_node_found(HMscNode* n)
+ {
+ //int last_block=trav.m_last_block;
+ //TimeRelationEventPtrList open_constraints=trav.m_open_constraints;
+ //counter_of_blocks=TraversAndBlocks::counter_of_blocks;
+
+ //n.found_with_block_number=last_block;
+
+ n->set_attribute<int>("found_with_block_number",trav->m_last_block);
+ //n.found_with_constraints=open_constraints;
+ n->set_attribute<TimeRelationRefNodePtrSet>("found_with_open_constraints",trav->m_open_constraints);
+ update_constraints(n);
+ }
+
+/*void MyTraverse::grey_node_found(HMscNode* n)
+{
+}
+
+void MyTraverse::black_node_found(HMscNode* n)
+{
+}*/
+
+void MyTraverse::on_node_finished(HMscNode* n)
+{
+ //int last_block=trav.m_last_block;
+ //TimeRelationEventPtrList open_constraints=trav.m_open_constraints;
+ //std::list<Block> list_of_blocks=trav.m_list_of_blocks;
+ for (std::list<Block>::iterator it = trav->m_list_of_blocks.begin(); it != trav->m_list_of_blocks.end(); it++) //iterate blocks
+ {
+ if (((*it).get_number()==trav->m_last_block) && ((*it).get_if_end()==0)) //find the right one, and check if end node has been set
+ {
+ (*it).set_end(dynamic_cast<ReferenceNode*>(n)); //if it hasn't, then set it
+ (*it).set_if_end(1);
+ continue;
+ }
+ }
+ trav->m_last_block=n->get_attribute<int>("found_with_block_number",0);
+ trav->m_open_constraints=n->get_attribute<TimeRelationRefNodePtrSet>("found_with_open_constraints",trav->m_open_constraints);
+ n->remove_attribute<int>("found_with_block_number");
+ n->remove_attribute<TimeRelationRefNodePtrSet>("found_with_open_constraints");
+}
+
+void MyTraverse::update_constraints(HMscNode* v)
+{
+ ReferenceNode* n= dynamic_cast<ReferenceNode*>(v);
+ TimeRelationRefNodePtrSet node_constraints;
+ TimeRelationRefNodePtrSet bottom;
+ TimeRelationRefNodePtrSet top;
+ //node_constraints=new TimeRelationRefNodePtrSet();
+ node_constraints.erase(node_constraints.begin(), node_constraints.end());
+
+ if (n!=NULL)
+ {
+
+/* std::cout << "Tu sme este dosli2" << std::endl;
+
+ n->get_time_relations_bottom();
+
+ std::cout << "Tu sme este dosli3" << std::endl;
+
+ bottom= n->get_time_relations_bottom();
+ top= n->get_time_relations_top();
+
+ for (std::set<TimeRelationRefNodePtr>::iterator it = top.begin(); it != top.end(); it++)
+ {
+ node_constraints.insert(*it);
+ }
+
+ for (std::set<TimeRelationRefNodePtr>::iterator it = bottom.begin(); it != bottom.end(); it++)
+ {
+ node_constraints.insert(*it);
+ }*/
+
+ node_constraints.insert(n->get_time_relations_top().begin(), n->get_time_relations_top().end()); //TODO tunak to hadze seg fault
+
+ //std::list<TimeRelationEvent> node_constraints;
+ //std::list<TimeRelationEvent> list_of_relations;
+ //int last_block=TraversAndMarkBlocks::last_block;
+ //TimeRelationEventPtrList open_constraints=TraversAndMarkBlocks::open_constraints;
+ //int counter_of_blocks=TraversAndMarkBlocks::counter_of_blocks;
+ //std::list<Block> list_of_blocks=TraversAndMarkBlocks::list_of_blocks;
+
+
+ node_constraints.insert(n->get_time_relations_bottom().begin(), n->get_time_relations_bottom().end());
+
+ //node_constraints=v->get_time_relations_top();
+ //node_constraints.splice( node_constraints.end() , v->get_time_relations_bottom() );
+
+ /*list_of_relations=v.get_time_relations_top(); //nejak zmaknut aby to ziskal node constraints
+ for (list<TimeRelationRefNodePtrSet>::iterator it = list_of_relations.begin(); it != list_of_relations.end(); it++)
+ {
+ if ( it&.get_begin() != it&.get_end() ) node_constraints.push_back(it&);
+ }
+ list_of_relations=v.get_time_relations_bottom();
+ for (list<TimeRelationRefNodePtrSet>::iterator it = list_of_relations.begin(); it != list_of_relations.end(); it++)
+ {list<TimeRelationRefNodePtrSet>::iterator it = list_of_relations.begin(); it != list_of_relations.end(); it++
+ if ( it&.get_begin() != it&.get_end() ) node_constraints.push_back(it&);
+ }
+ //node_constraints=constraints_in_v; zjavne kravina :)*/
+
+
+ if (trav->m_open_constraints.empty())
+ {
+ trav->m_counter_of_blocks++;
+
+ //ukladat pociatocne uzly bloku
+ if (trav->m_counter_of_blocks!=0)
+ {
+ for (std::list<Block>::iterator it = trav->m_list_of_blocks.begin(); it != trav->m_list_of_blocks.end(); it++)
+ {
+ if (((*it).get_number()==trav->m_last_block)&&((*it).get_if_end()==0))
+ {
+ (*it).set_if_end(1);
+ }
+ }
+ }
+ Block* block= new Block(trav->m_counter_of_blocks, n, n, 0);
+ trav->m_list_of_blocks.push_back(*block);
+
+ trav->m_last_block=trav->m_counter_of_blocks;
+ trav->m_open_constraints.insert(node_constraints.begin(), node_constraints.end());
+ }
+ else
+ {
+ for (std::list<Block>::iterator it = trav->m_list_of_blocks.begin(); it != trav->m_list_of_blocks.end(); it++) //iterate blocks
+ {
+ if (((*it).get_if_end()==0)&&((*it).get_number()==trav->m_last_block)) //find the right one, and check if end node has been set
+ {
+ (*it).set_end(n); //if it hasn't, then set it
+ continue;
+ }
+ }
+ for (std::set<TimeRelationRefNodePtr>::iterator it = trav->m_open_constraints.begin(); it != trav->m_open_constraints.end(); it++)
+ {
+ for (std::set<TimeRelationRefNodePtr>::iterator it_2 = node_constraints.begin(); it_2 != node_constraints.end(); it_2++)
+ {
+ if (*it==*it_2)
+ {
+ trav->m_open_constraints.erase(it);
+ node_constraints.erase(it_2);
+ }
+ }
+ }
+ trav->m_open_constraints.insert(node_constraints.begin(), node_constraints.end());
+ }
+ }
+ else if (!(dynamic_cast<ConnectionNode*>(v)
+ || dynamic_cast<StartNode*>(v)
+ || dynamic_cast<EndNode*>(v)
+ || dynamic_cast<ConditionNode*>(v)))
+ {
+ throw std::runtime_error("Unknown type");
+ }
+
+}
+
+
+
Added: trunk/src/check/time/find_block.cpp~
===================================================================
--- trunk/src/check/time/find_block.cpp~ (rev 0)
+++ trunk/src/check/time/find_block.cpp~ 2010-03-07 21:26:40 UTC (rev 668)
@@ -0,0 +1,184 @@
+/*
+ * 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) 2010 Martin Vodila <fp...@ma...>
+ *
+ * $Id:
+ */
+
+
+#include "check/time/find_block.h"
+
+void MyTraverse::on_white_node_found(HMscNode* n)
+ {
+ //int last_block=trav.m_last_block;
+ //TimeRelationEventPtrList open_constraints=trav.m_open_constraints;
+ //counter_of_blocks=TraversAndBlocks::counter_of_blocks;
+
+ //n.found_with_block_number=last_block;
+
+ std::cout << "Tu sme este dosli-WNFL" << std::endl;
+
+ n->set_attribute<int>("found_with_block_number",trav->m_last_block);
+ //n.found_with_constraints=open_constraints;
+ n->set_attribute<TimeRelationRefNodePtrSet>("found_with_open_constraints",trav->m_open_constraints);
+ update_constraints(n);
+ }
+
+/*void MyTraverse::grey_node_found(HMscNode* n)
+{
+}
+
+void MyTraverse::black_node_found(HMscNode* n)
+{
+}*/
+
+void MyTraverse::on_node_finished(HMscNode* n)
+{
+ //int last_block=trav.m_last_block;
+ //TimeRelationEventPtrList open_constraints=trav.m_open_constraints;
+ //std::list<Block> list_of_blocks=trav.m_list_of_blocks;
+ for (std::list<Block>::iterator it = trav->m_list_of_blocks.begin(); it != trav->m_list_of_blocks.end(); it++) //iterate blocks
+ {
+ if (((*it).get_number()==trav->m_last_block) && ((*it).get_if_end()==0)) //find the right one, and check if end node has been set
+ {
+ (*it).set_end(dynamic_cast<ReferenceNode*>(n)); //if it hasn't, then set it
+ (*it).set_if_end(1);
+ continue;
+ }
+ }
+ trav->m_last_block=n->get_attribute<int>("found_with_block_number",0);
+ trav->m_open_constraints=n->get_attribute<TimeRelationRefNodePtrSet>("found_with_open_constraints",trav->m_open_constraints);
+ n->remove_attribute<int>("found_with_block_number");
+ n->remove_attribute<TimeRelationRefNodePtrSet>("found_with_open_constraints");
+}
+
+void MyTraverse::update_constraints(HMscNode* v)
+{
+ ReferenceNode* n= dynamic_cast<ReferenceNode*>(v);
+ TimeRelationRefNodePtrSet node_constraints;
+ TimeRelationRefNodePtrSet bottom;
+ TimeRelationRefNodePtrSet top;
+ //node_constraints=new TimeRelationRefNodePtrSet();
+ node_constraints.erase(node_constraints.begin(), node_constraints.end());
+
+ if (n!=NULL)
+ {
+
+/* std::cout << "Tu sme este dosli2" << std::endl;
+
+ n->get_time_relations_bottom();
+
+ std::cout << "Tu sme este dosli3" << std::endl;
+
+ bottom= n->get_time_relations_bottom();
+ top= n->get_time_relations_top();
+
+ for (std::set<TimeRelationRefNodePtr>::iterator it = top.begin(); it != top.end(); it++)
+ {
+ node_constraints.insert(*it);
+ }
+
+ for (std::set<TimeRelationRefNodePtr>::iterator it = bottom.begin(); it != bottom.end(); it++)
+ {
+ node_constraints.insert(*it);
+ }*/
+
+ node_constraints.insert(n->get_time_relations_top().begin(), n->get_time_relations_top().end()); //TODO tunak to hadze seg fault
+
+ //std::list<TimeRelationEvent> node_constraints;
+ //std::list<TimeRelationEvent> list_of_relations;
+ //int last_block=TraversAndMarkBlocks::last_block;
+ //TimeRelationEventPtrList open_constraints=TraversAndMarkBlocks::open_constraints;
+ //int counter_of_blocks=TraversAndMarkBlocks::counter_of_blocks;
+ //std::list<Block> list_of_blocks=TraversAndMarkBlocks::list_of_blocks;
+
+ std::cout << "Tu sme este dosli-4" << std::endl;
+
+ node_constraints.insert(n->get_time_relations_bottom().begin(), n->get_time_relations_bottom().end());
+
+ //node_constraints=v->get_time_relations_top();
+ //node_constraints.splice( node_constraints.end() , v->get_time_relations_bottom() );
+
+ /*list_of_relations=v.get_time_relations_top(); //nejak zmaknut aby to ziskal node constraints
+ for (list<TimeRelationRefNodePtrSet>::iterator it = list_of_relations.begin(); it != list_of_relations.end(); it++)
+ {
+ if ( it&.get_begin() != it&.get_end() ) node_constraints.push_back(it&);
+ }
+ list_of_relations=v.get_time_relations_bottom();
+ for (list<TimeRelationRefNodePtrSet>::iterator it = list_of_relations.begin(); it != list_of_relations.end(); it++)
+ {list<TimeRelationRefNodePtrSet>::iterator it = list_of_relations.begin(); it != list_of_relations.end(); it++
+ if ( it&.get_begin() != it&.get_end() ) node_constraints.push_back(it&);
+ }
+ //node_constraints=constraints_in_v; zjavne kravina :)*/
+
+ std::cout << "Tu sme este dosli-5" << std::endl;
+
+ if (trav->m_open_constraints.empty())
+ {
+ trav->m_counter_of_blocks++;
+
+ //ukladat pociatocne uzly bloku
+ if (trav->m_counter_of_blocks!=0)
+ {
+ for (std::list<Block>::iterator it = trav->m_list_of_blocks.begin(); it != trav->m_list_of_blocks.end(); it++)
+ {
+ if (((*it).get_number()==trav->m_last_block)&&((*it).get_if_end()==0))
+ {
+ (*it).set_if_end(1);
+ }
+ }
+ }
+ Block* block= new Block(trav->m_counter_of_blocks, n, n, 0);
+ trav->m_list_of_blocks.push_back(*block);
+
+ trav->m_last_block=trav->m_counter_of_blocks;
+ trav->m_open_constraints.insert(node_constraints.begin(), node_constraints.end());
+ }
+ else
+ {
+ for (std::list<Block>::iterator it = trav->m_list_of_blocks.begin(); it != trav->m_list_of_blocks.end(); it++) //iterate blocks
+ {
+ if (((*it).get_if_end()==0)&&((*it).get_number()==trav->m_last_block)) //find the right one, and check if end node has been set
+ {
+ (*it).set_end(n); //if it hasn't, then set it
+ continue;
+ }
+ }
+ for (std::set<TimeRelationRefNodePtr>::iterator it = trav->m_open_constraints.begin(); it != trav->m_open_constraints.end(); it++)
+ {
+ for (std::set<TimeRelationRefNodePtr>::iterator it_2 = node_constraints.begin(); it_2 != node_constraints.end(); it_2++)
+ {
+ if (*it==*it_2)
+ {
+ trav->m_open_constraints.erase(it);
+ node_constraints.erase(it_2);
+ }
+ }
+ }
+ trav->m_open_constraints.insert(node_constraints.begin(), node_constraints.end());
+ }
+ std::cout << "Tu sme este dosli" << std::endl;
+ }
+ else if (!(dynamic_cast<ConnectionNode*>(v)
+ || dynamic_cast<StartNode*>(v)
+ || dynamic_cast<EndNode*>(v)
+ || dynamic_cast<ConditionNode*>(v)))
+ {
+ throw std::runtime_error("Unknown type");
+ }
+
+}
+
+
+
Added: trunk/src/check/time/find_block.h
===================================================================
--- trunk/src/check/time/find_block.h (rev 0)
+++ trunk/src/check/time/find_block.h 2010-03-07 21:26:40 UTC (rev 668)
@@ -0,0 +1,147 @@
+/*
+ * 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) 2010 Martin Vodila <fp...@ma...>
+ *
+ * $Id:
+ */
+
+#ifndef _FIND_BLOCK_H
+#define _FIND_BLOCK_H
+
+#include "data/time.h"
+#include "data/msc.h"
+#include "data/dfs_bmsc_graph_traverser.h"
+#include "check/pseudocode/msc_duplicators.h"
+
+#include <list>
+
+class TraverseAndMarkBlocks;
+
+class MyTraverse:public WhiteNodeFoundListener, public NodeFinishedListener{
+
+public:
+ TraverseAndMarkBlocks* trav;
+
+ MyTraverse() {};
+
+ MyTraverse(TraverseAndMarkBlocks* t) {
+ trav=t;
+ }
+ ~MyTraverse() {};
+
+ void on_white_node_found(HMscNode* n);
+ //void grey_node_found(HMscNode* n);
+ //void black_node_found(HMscNode* n);
+ void on_node_finished(HMscNode* n);
+ void update_constraints(HMscNode* n);
+};
+
+
+
+
+class Block
+{
+private:
+int number;
+ReferenceNode* begin;
+ReferenceNode* end;
+bool if_end;
+public:
+ Block(int n, ReferenceNode* begin, ReferenceNode* end, bool if_end) {
+ this->number=n;
+ this->begin=begin;
+ this->end=end;
+ this->if_end=if_end;
+ }
+ int get_number() {
+ return this->number;
+ }
+ void set_number(int n) {
+ this->number=n;
+ }
+ ReferenceNode* get_begin() {
+ return this->begin;
+ }
+ void set_begin(ReferenceNode* b) {
+ this->begin=b;
+ }
+ ReferenceNode* get_end() {
+ return this->end;
+ }
+ void set_end(ReferenceNode* e) {
+ this->end=e;
+ }
+ bool get_if_end() {
+ return this->if_end;
+ }
+ void set_if_end(bool i) {
+ this->if_end=i;
+ }
+};
+
+/* nakoniec nie je potrebna tato trieda :)
+class MscGraphBlocks
+{
+private:
+
+//list dvojic (cislo, zaciatok, koniec)
+list<Block> list_of_blocks;
+
+public:
+
+ Block get_i-th_block(int i) { //vrati smernik na blok
+ for (list<Block>::iterator it = list_of_blocks.begin(); it != list_of_blocks.end(); it++) {
+ if (it.get_number()==i) return it;
+ }
+ }
+ void add_block(Block block) { //prida blok do zoznamu
+ list_of_blocks.push_back(block);
+ }
+ void remove_block(Block block) { //odstrani blok zo zoznamu
+ list_of_blocks.remove(block);
+ }
+}*/
+
+
+class TraverseAndMarkBlocks
+{
+private:
+
+public:
+ std::list<Block> m_list_of_blocks;
+ int m_last_block;
+ int m_counter_of_blocks;
+ TimeRelationRefNodePtrSet m_open_constraints;
+ //std::list<TimeRelationEvent> open_constraints; //pozret si time relation event
+
+ TraverseAndMarkBlocks() {
+ this->m_last_block=0;
+ this->m_counter_of_blocks=0;
+ }
+
+ void travers_and_mark_blocks(HMscPtr m_msc) //dfs prehladanie a cez listener rata k uzlu prislusny blok
+ {
+ //BMscGraphDuplicator* duplicator= new BMscGraphDuplicator();
+ //m_msc=duplicator->duplicate_hmsc(m_msc);
+ DFSBMscGraphTraverser* traverser_block= new DFSBMscGraphTraverser();
+ MyTraverse* my_trav= new MyTraverse(this);
+ traverser_block->add_white_node_found_listener(my_trav);
+ traverser_block->add_node_finished_listener(my_trav);
+ //list_of_blocks= new MscGraphBlock();
+ traverser_block->traverse(m_msc);
+ }
+};
+
+#endif /* _FIND_BLOCK_H */
+
Added: trunk/src/check/time/find_block.h~
===================================================================
--- trunk/src/check/time/find_block.h~ (rev 0)
+++ trunk/src/check/time/find_block.h~ 2010-03-07 21:26:40 UTC (rev 668)
@@ -0,0 +1,148 @@
+/*
+ * 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) 2010 Martin Vodila <fp...@ma...>
+ *
+ * $Id:
+ */
+
+#ifndef _FIND_BLOCK_H
+#define _FIND_BLOCK_H
+
+#include "data/time.h"
+#include "data/msc.h"
+#include "data/dfs_bmsc_graph_traverser.h"
+#include "check/pseudocode/msc_duplicators.h"
+#include "find_block.moc"
+
+#include <list>
+
+class TraverseAndMarkBlocks;
+
+class MyTraverse:public WhiteNodeFoundListener, public NodeFinishedListener{
+
+public:
+ TraverseAndMarkBlocks* trav;
+
+ MyTraverse() {};
+
+ MyTraverse(TraverseAndMarkBlocks* t) {
+ trav=t;
+ }
+ ~MyTraverse() {};
+
+ void on_white_node_found(HMscNode* n);
+ //void grey_node_found(HMscNode* n);
+ //void black_node_found(HMscNode* n);
+ void on_node_finished(HMscNode* n);
+ void update_constraints(HMscNode* n);
+};
+
+
+
+
+class Block
+{
+private:
+int number;
+ReferenceNode* begin;
+ReferenceNode* end;
+bool if_end;
+public:
+ Block(int n, ReferenceNode* begin, ReferenceNode* end, bool if_end) {
+ this->number=n;
+ this->begin=begin;
+ this->end=end;
+ this->if_end=if_end;
+ }
+ int get_number() {
+ return this->number;
+ }
+ void set_number(int n) {
+ this->number=n;
+ }
+ ReferenceNode* get_begin() {
+ return this->begin;
+ }
+ void set_begin(ReferenceNode* b) {
+ this->begin=b;
+ }
+ ReferenceNode* get_end() {
+ return this->end;
+ }
+ void set_end(ReferenceNode* e) {
+ this->end=e;
+ }
+ bool get_if_end() {
+ return this->if_end;
+ }
+ void set_if_end(bool i) {
+ this->if_end=i;
+ }
+};
+
+/* nakoniec nie je potrebna tato trieda :)
+class MscGraphBlocks
+{
+private:
+
+//list dvojic (cislo, zaciatok, koniec)
+list<Block> list_of_blocks;
+
+public:
+
+ Block get_i-th_block(int i) { //vrati smernik na blok
+ for (list<Block>::iterator it = list_of_blocks.begin(); it != list_of_blocks.end(); it++) {
+ if (it.get_number()==i) return it;
+ }
+ }
+ void add_block(Block block) { //prida blok do zoznamu
+ list_of_blocks.push_back(block);
+ }
+ void remove_block(Block block) { //odstrani blok zo zoznamu
+ list_of_blocks.remove(block);
+ }
+}*/
+
+
+class TraverseAndMarkBlocks
+{
+private:
+
+public:
+ std::list<Block> m_list_of_blocks;
+ int m_last_block;
+ int m_counter_of_blocks;
+ TimeRelationRefNodePtrSet m_open_constraints;
+ //std::list<TimeRelationEvent> open_constraints; //pozret si time relation event
+
+ TraverseAndMarkBlocks() {
+ this->m_last_block=0;
+ this->m_counter_of_blocks=0;
+ }
+
+ void travers_and_mark_blocks(HMscPtr m_msc) //dfs prehladanie a cez listener rata k uzlu prislusny blok
+ {
+ //BMscGraphDuplicator* duplicator= new BMscGraphDuplicator();
+ //m_msc=duplicator->duplicate_hmsc(m_msc);
+ DFSBMscGraphTraverser* traverser_block= new DFSBMscGraphTraverser();
+ MyTraverse* my_trav= new MyTraverse(this);
+ traverser_block->add_white_node_found_listener(my_trav);
+ traverser_block->add_node_finished_listener(my_trav);
+ //list_of_blocks= new MscGraphBlock();
+ traverser_block->traverse(m_msc);
+ }
+};
+
+#endif /* _FIND_BLOCK_H */
+
Modified: trunk/tests/CMakeLists.txt
===================================================================
--- trunk/tests/CMakeLists.txt 2010-03-06 12:19:42 UTC (rev 667)
+++ trunk/tests/CMakeLists.txt 2010-03-07 21:26:40 UTC (rev 668)
@@ -56,10 +56,26 @@
TARGET_LINK_LIBRARIES(acyclic_checker_test
scorder
scmsc
+ sctime
scpseudocode
)
ADD_TEST(acyclic_checker ${EXECUTABLE_OUTPUT_PATH}/acyclic_checker_test)
+
+
+ADD_EXECUTABLE(find_block_test
+ find_block_test.cpp
+)
+TARGET_LINK_LIBRARIES(find_block_test
+ scmsc
+ sctime
+ scpseudocode
+ scorder
+)
+ADD_TEST(find_block ${EXECUTABLE_OUTPUT_PATH}/find_block_test)
+
+
+
ADD_EXECUTABLE(race_checker_test
race_checker_test.cpp
)
@@ -198,6 +214,8 @@
)
ENDIF(ANTLR_FOUND)
+
+
#ADD_EXECUTABLE(duplicator_test
# duplicator_test.cpp
Added: trunk/tests/acyclic_checker_test
===================================================================
(Binary files differ)
Property changes on: trunk/tests/acyclic_checker_test
___________________________________________________________________
Added: svn:executable
+ *
Added: svn:mime-type
+ application/octet-stream
Added: trunk/tests/find_block_test.cpp
===================================================================
--- trunk/tests/find_block_test.cpp (rev 0)
+++ trunk/tests/find_block_test.cpp 2010-03-07 21:26:40 UTC (rev 668)
@@ -0,0 +1,78 @@
+
+
+#include "data/msc.h"
+#include "check/time/find_block.h"
+#include "check/time/tightening.h"
+#include "check/liveness/deadlock_checker.h"
+#include <string>
+#include <iostream>
+
+
+int main(int argc, char** argv) {
+
+
+ std::cout << "Test of find_block: " << std::endl;
+ std::cout << "h1: " << std::endl;
+ std::cout << " start " << std::endl;
+ std::cout << " | " << std::endl;
+ std::cout << " p1 " << std::endl;
+ std::cout << " / \\ " << std::endl;
+ std::cout << " p2 p3 " << std::endl;
+ std::cout << " | \\ " << std::endl;
+ std::cout << " p5 p4 " << std::endl;
+ std::cout << " | / " << std::endl;
+ std::cout << " \\ / " << std::endl;
+ std::cout << " p6 " << std::endl;
+ std::cout << " | " << std::endl;
+ std::cout << " end1 " << std::endl;
+
+ HMscPtr h1(new HMsc(L"h1"));
+
+
+
+ StartNodePtr start1 = new StartNode();
+ h1->set_start(start1);
+ EndNodePtr end1(new EndNode);
+ h1->add_node(end1);
+ ReferenceNodePtr p1(new ReferenceNode());h1->add_node(p1);
+ ReferenceNodePtr p2(new ReferenceNode());h1->add_node(p2);
+ ReferenceNodePtr p3(new ReferenceNode());h1->add_node(p3);
+ ReferenceNodePtr p4(new ReferenceNode());h1->add_node(p4);
+ ReferenceNodePtr p5(new ReferenceNode());h1->add_node(p5);
+ ReferenceNodePtr p6(new ReferenceNode());h1->add_node(p6);
+
+
+ start1->add_successor(p1.get());
+ p1->add_successor(p2.get());
+ p1->add_successor(p3.get());
+ p3->add_successor(p4.get());
+ p2->add_successor(p5.get());
+ p5->add_successor(p6.get());
+ p4->add_successor(p6.get());
+ p6->add_successor(end1.get());
+
+
+ MscTimeIntervalD in6(10,20);
+ MscTimeIntervalSetD ins1;
+ ins1.insert(in6);
+
+/* MscTimeIntervalD in7(10,20);
+ MscTimeIntervalSetD ins2;
+ ins2.insert(in7); */
+
+ TimeRelationRefNodePtr rel1a = new TimeRelationRefNode(ins1);
+ rel1a->glue_ref_nodes(0,p1.get(),0,p6.get());
+
+/* TimeRelationRefNodePtr rel1a2 = new TimeRelationRefNode(ins2);
+ rel1a2->glue_ref_nodes(0,p3.get(),0,p4.get()); */
+
+ TraverseAndMarkBlocks* trav_mark = new TraverseAndMarkBlocks();
+ trav_mark->travers_and_mark_blocks(h1); //TODO tu sa tiez robilo
+
+ for (std::list<Block>::iterator it = trav_mark->m_list_of_blocks.begin(); it != trav_mark->m_list_of_blocks.end(); it++)
+ {
+ std::cout << "Blok:" << (*it).get_number() << std::endl;
+ }
+ return 0;
+
+}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|