|
From: <mar...@us...> - 2010-03-09 22:53:45
|
Revision: 676
http://scstudio.svn.sourceforge.net/scstudio/?rev=676&view=rev
Author: martinnrt
Date: 2010-03-09 22:53:38 +0000 (Tue, 09 Mar 2010)
Log Message:
-----------
Modified Paths:
--------------
trunk/src/check/time/find_block.cpp
trunk/src/check/time/find_block.h
trunk/tests/find_block_test.cpp
Modified: trunk/src/check/time/find_block.cpp
===================================================================
--- trunk/src/check/time/find_block.cpp 2010-03-09 22:38:17 UTC (rev 675)
+++ trunk/src/check/time/find_block.cpp 2010-03-09 22:53:38 UTC (rev 676)
@@ -28,14 +28,14 @@
void MyTraverse::on_node_finished(HMscNode* n)
{
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
{
- 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); //mark block, now we know that end node of block has been set and won't be changed
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");
@@ -49,71 +49,71 @@
node_constraints.erase(node_constraints.begin(), node_constraints.end());
if (n!=NULL) //test if node v is also ReferenceNode
- {
+ {
node_constraints.insert(n->get_time_relations_top().begin(), n->get_time_relations_top().end()); //fill with contraints in node v
node_constraints.insert(n->get_time_relations_bottom().begin(), n->get_time_relations_bottom().end()); //fill with contraints in node v
if (trav->m_open_constraints.empty())
- {
+ {
trav->m_counter_of_blocks++;
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++) //iterate 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 one, we are looking for
{
- if (((*it).get_number()==trav->m_last_block)&&((*it).get_if_end()==0)) //find the one, we are looking for
- {
(*it).set_if_end(1); //find new block, so we must close previous block, to prevent any changes
- }
}
}
- Block block= 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());
+ }
+ Block block= 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
{
- 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
{
- 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 as temporal
continue;
- }
}
+ }
for (std::set<TimeRelationRefNodePtr>::iterator it = trav->m_open_constraints.begin(); it != trav->m_open_constraints.end(); it++) //itarate open constraints
+ {
+ for (std::set<TimeRelationRefNodePtr>::iterator it_2 = node_constraints.begin(); it_2 != node_constraints.end(); it_2++) //iterate node constraints
{
- for (std::set<TimeRelationRefNodePtr>::iterator it_2 = node_constraints.begin(); it_2 != node_constraints.end(); it_2++) //iterate node constraints
+ if (*it==*it_2)
{
- if (*it==*it_2)
- {
//erase constraint from open constraints, if same one is in node constraints
trav->m_open_constraints.erase(it);
node_constraints.erase(it_2);
std::set<TimeRelationRefNodePtr>::iterator it=trav->m_open_constraints.begin();
std::set<TimeRelationRefNodePtr>::iterator it_2=node_constraints.begin();
- }
}
}
+ }
trav->m_open_constraints.insert(node_constraints.begin(), node_constraints.end());
- }
+ }
}
else if (dynamic_cast<EndNode*>(v)!=NULL)
+ {
+ for (std::list<Block>::iterator it = trav->m_list_of_blocks.begin(); it != trav->m_list_of_blocks.end(); it++) //iterate 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_if_end()==0)&&((*it).get_number()==trav->m_last_block)) //find the right one, and check if end node has been set
{
- 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_if_end(1); //close changing end_node of last_block
continue;
- }
}
}
+ }
else if (!(dynamic_cast<ConnectionNode*>(v)
|| dynamic_cast<StartNode*>(v)
|| dynamic_cast<ConditionNode*>(v)))
- {
+ {
throw std::runtime_error("Unknown type");
- }
+ }
}
Modified: trunk/src/check/time/find_block.h
===================================================================
--- trunk/src/check/time/find_block.h 2010-03-09 22:38:17 UTC (rev 675)
+++ trunk/src/check/time/find_block.h 2010-03-09 22:53:38 UTC (rev 676)
@@ -39,12 +39,11 @@
{}
MyTraverse(TraverseAndMarkBlocks* t)
- {
+ {
trav=t;
- }
+ }
virtual ~MyTraverse()
- {
- }
+ {}
virtual void on_white_node_found(HMscNode* n);
virtual void on_node_finished(HMscNode* n);
@@ -63,44 +62,44 @@
bool if_end; //test variable - if true, then end has been set
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;
- }
+ }
};
@@ -116,10 +115,10 @@
//constructor - initializes variables
TraverseAndMarkBlocks()
- {
+ {
this->m_last_block=0;
this->m_counter_of_blocks=0;
- }
+ }
/*
@@ -127,7 +126,7 @@
then travers graph, using only white_node_found_listener and node_finished_listener.
*/
void travers_and_mark_blocks(HMscPtr m_msc)
- {
+ {
//BMscGraphDuplicator* duplicator= new BMscGraphDuplicator();
//m_msc=duplicator->duplicate_hmsc(m_msc);
DFSBMscGraphTraverser* traverser_block= new DFSBMscGraphTraverser();
@@ -135,7 +134,7 @@
traverser_block->add_white_node_found_listener(my_trav);
traverser_block->add_node_finished_listener(my_trav);
traverser_block->traverse(m_msc);
- }
+ }
};
#endif /* _FIND_BLOCK_H */
Modified: trunk/tests/find_block_test.cpp
===================================================================
--- trunk/tests/find_block_test.cpp 2010-03-09 22:38:17 UTC (rev 675)
+++ trunk/tests/find_block_test.cpp 2010-03-09 22:53:38 UTC (rev 676)
@@ -72,7 +72,7 @@
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;
+ std::cout << "Blok:" << (*it).get_number() << " if_end:" << (*it).get_if_end() << std::endl;
}
return 0;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|