|
Go to the documentation of this file.
25 #ifndef FAUDES_TRANSSET_H
26 #define FAUDES_TRANSSET_H
74 X1(x1), Ev(ev), X2(x2) {}
77 inline bool operator < ( const Transition& othertrans) const {
78 if (X1 < othertrans. X1) return true;
79 if (X1 > othertrans. X1) return false;
80 if (Ev < othertrans. Ev) return true;
81 if (Ev > othertrans. Ev) return false;
82 if (X2 < othertrans. X2) return true;
87 inline bool operator == ( const Transition& othertrans) const {
88 return ((X1 == othertrans. X1) && (Ev == othertrans. Ev) && (X2 == othertrans. X2));
92 inline bool operator != ( const Transition& othertrans) const {
93 return ((X1 != othertrans. X1) || (Ev != othertrans. Ev) || (X2 != othertrans. X2));
98 return (X1!=0) && (Ev!=0) && (X2!=0);
111 std::string Str( void) const {
130 if (left. Ev < right. Ev) return true;
131 if (left. Ev > right. Ev) return false;
132 if (left. X1 < right. X1) return true;
133 if (left. X1 > right. X1) return false;
134 if (left. X2 < right. X2) return true;
142 if (left. Ev < right. Ev) return true;
143 if (left. Ev > right. Ev) return false;
144 if (left. X2 < right. X2) return true;
145 if (left. X2 > right. X2) return false;
146 if (left. X1 < right. X1) return true;
154 if (left. X2 < right. X2) return true;
155 if (left. X2 > right. X2) return false;
156 if (left. Ev < right. Ev) return true;
157 if (left. Ev > right. Ev) return false;
158 if (left. X1 < right. X1) return true;
166 if (left. X2 < right. X2) return true;
167 if (left. X2 > right. X2) return false;
168 if (left. X1 < right. X1) return true;
169 if (left. X1 > right. X1) return false;
170 if (left. Ev < right. Ev) return true;
178 if (left. X1 < right. X1) return true;
179 if (left. X1 > right. X1) return false;
180 if (left. X2 < right. X2) return true;
181 if (left. X2 > right. X2) return false;
182 if (left. Ev < right. Ev) return true;
190 if (left. X1 < right. X1) return true;
191 if (left. X1 > right. X1) return false;
192 if (left. Ev < right. Ev) return true;
193 if (left. Ev > right. Ev) return false;
194 if (left. X2 < right. X2) return true;
238 template < class Cmp=TransSort::X1EvX2>
239 class FAUDES_API TTransSet : public TBaseSet<Transition,Cmp> {
241 template < class Cmp=TransSort::X1EvX2>
264 template< class OtherCmp>
318 Iterator Inject( const Iterator& pos, const Transition& rTransition);
353 Iterator Erase( const Iterator& it);
363 void EraseByX1( Idx x1);
375 void EraseByX1Ev( Idx x1, Idx ev);
384 void EraseByX2( Idx x2);
393 void EraseByEv( Idx ev);
402 void EraseByX1OrX2( Idx x);
411 void EraseByX1OrX2( const StateSet& rStates);
420 void RestrictStates( const StateSet& rStateSet);
429 void RestrictEvents( const EventSet& rEventSet);
445 Iterator Find( Idx x1, Idx ev, Idx x2) const;
484 bool Exists( Idx x1, Idx ev, Idx x2) const;
497 bool ExistsByX1Ev( Idx x1, Idx ev) const;
510 bool ExistsByX1( Idx x1) const;
522 bool ExistsByX1OrX2( Idx x) const;
548 Iterator Begin( void) const;
556 Iterator End( void) const;
571 Iterator Begin( Idx x1) const;
585 Iterator End( Idx x1) const;
601 Iterator Begin( Idx x1, Idx ev) const;
617 Iterator End( Idx x1, Idx ev) const;
632 Iterator BeginByEv( Idx ev) const;
647 Iterator EndByEv( Idx ev) const;
664 Iterator BeginByEvX1( Idx ev, Idx x1) const;
681 Iterator EndByEvX1( Idx ev, Idx x1) const;
698 Iterator BeginByEvX2( Idx ev, Idx x2) const;
715 Iterator EndByEvX2( Idx ev, Idx x2) const;
730 Iterator BeginByX2( Idx x2) const;
745 Iterator EndByX2( Idx x2) const;
762 Iterator BeginByX2Ev( Idx x2, Idx ev) const;
779 Iterator EndByX2Ev( Idx x2, Idx ev) const;
793 template< class OtherCmp>
880 std::string Str( const Transition& rTrans) const;
912 virtual void DoWrite( TokenWriter& rTw, const std::string& rLabel= "", const Type* pContext=0) const;
954 template < class Attr>
1050 bool Insert( const Transition& rTransition, const Attr& rAttr);
1062 virtual void InsertSet( const TransSet& rOtherSet);
1109 virtual void EraseSet( const TransSet& rOtherSet);
1134 void RestrictSet( const TransSet& rOtherSet);
1189 #define THIS TTransSet<Cmp>
1190 #define TEMP template<class Cmp>
1191 #define BASE TBaseSet<Transition,Cmp>
1199 FD_DC( "TTransSet(" << this << ")::TTransSet()");
1206 FD_DC( "TTransSet(" << this << ")::TTransSet(rOtherSet "<< &rOtherSet << ")");
1211 TEMP template< class OtherCmp>
1215 FD_DC( "TTransSet(" << this << ")::TTransSet(rOtherSet/ReSort "<< &rOtherSet << ")");
1221 FD_DC( "TTransSet(" << this << ")::DoAssign(..)");
1223 BASE::DoAssign(rSourceSet);
1227 TEMP typename THIS::Iterator THIS::Begin( void) const {
1228 return BASE::Begin();
1232 TEMP typename THIS::Iterator THIS::End( void) const {
1238 #define SORT_EXCEPTION { std::stringstream errstr; \
1239 errstr << "Transition set order mismatch " << std::endl; \
1240 throw Exception("TransSet::Iterator()", errstr.str(), 68); }
1244 TEMP typename THIS::Iterator THIS::Begin( Idx x1) const {
1245 #ifdef FAUDES_CHECKED
1251 return THIS::ThisIterator(BASE::pSet->lower_bound(tlx));
1255 TEMP typename THIS::Iterator THIS::End( Idx x1) const {
1256 #ifdef FAUDES_CHECKED
1262 return THIS::ThisIterator(BASE::pSet->lower_bound(tlx));
1267 #ifdef FAUDES_CHECKED
1272 return THIS::ThisIterator(BASE::pSet->lower_bound(tlx));
1277 #ifdef FAUDES_CHECKED
1282 return THIS::ThisIterator(BASE::pSet->lower_bound(tlx));
1286 TEMP typename THIS::Iterator THIS::BeginByEv( Idx ev) const {
1287 #ifdef FAUDES_CHECKED
1293 return THIS::ThisIterator(BASE::pSet->lower_bound(tlx));
1297 TEMP typename THIS::Iterator THIS::EndByEv( Idx ev) const {
1298 #ifdef FAUDES_CHECKED
1304 return THIS::ThisIterator(BASE::pSet->lower_bound(tlx));
1308 TEMP typename THIS::Iterator THIS::BeginByEvX1( Idx ev, Idx x1) const {
1309 #ifdef FAUDES_CHECKED
1314 return THIS::ThisIterator(BASE::pSet->lower_bound(tlx));
1318 TEMP typename THIS::Iterator THIS::EndByEvX1( Idx ev, Idx x1) const {
1319 #ifdef FAUDES_CHECKED
1324 return THIS::ThisIterator(BASE::pSet->lower_bound(tlx));
1328 TEMP typename THIS::Iterator THIS::BeginByEvX2( Idx ev, Idx x2) const {
1329 #ifdef FAUDES_CHECKED
1334 return THIS::ThisIterator(BASE::pSet->lower_bound(tlx));
1338 TEMP typename THIS::Iterator THIS::EndByEvX2( Idx ev, Idx x2) const {
1339 #ifdef FAUDES_CHECKED
1344 return THIS::ThisIterator(BASE::pSet->lower_bound(tlx));
1348 TEMP typename THIS::Iterator THIS::BeginByX2( Idx x2) const {
1349 #ifdef FAUDES_CHECKED
1355 return THIS::ThisIterator(BASE::pSet->lower_bound(tlx));
1359 TEMP typename THIS::Iterator THIS::EndByX2( Idx x2) const {
1360 #ifdef FAUDES_CHECKED
1366 return THIS::ThisIterator(BASE::pSet->lower_bound(tlx));
1370 TEMP typename THIS::Iterator THIS::BeginByX2Ev( Idx x2, Idx ev) const {
1371 #ifdef FAUDES_CHECKED
1376 return THIS::ThisIterator(BASE::pSet->lower_bound(tlx));
1380 TEMP typename THIS::Iterator THIS::EndByX2Ev( Idx x2, Idx ev) const {
1381 #ifdef FAUDES_CHECKED
1386 return THIS::ThisIterator(BASE::pSet->lower_bound(tlx));
1395 std::string label=rLabel;
1396 if(label== "") label=BASE::Name();
1398 int oldcolumns = rTw. Columns();
1402 for (tit = Begin(); tit != End(); ++tit) {
1403 rTw << tit->X1; rTw << tit->Ev; rTw << tit->X2;
1413 return BASE::Insert(t);
1418 FD_DC( "TTransSet(" << this << ")::Insert(" << x1 << "-" << ev << "-" << x2 << ")");
1424 return BASE::Inject(pos,t);
1435 FD_DC( "TTransSet(" << this << ")::Erase(" << Str() << " [t])");
1436 return BASE::Erase(t);
1441 FD_DC( "TTransSet(" << this << ")::Erase(" << x1 << "-" << ev << "-" << x2 << ")");
1447 FD_DC( "TTransSet(" << this << ")::Erase(" << this->Str(*it) << " [it])");
1448 return BASE::Erase(it);
1453 FD_DC( "TTransSet(" << this << ")::EraseByX1(" << x1 << ")");
1454 #ifdef FAUDES_CHECKED
1460 typename BASE::iterator lower, upper, it;
1463 lower = BASE::pSet->lower_bound(tl);
1464 upper = BASE::pSet->upper_bound(tu);
1465 if(this->AttributesSize()!=0)
1466 for(it=lower; it!=upper; ++it)
1467 BASE::ClrAttribute(*it);
1468 BASE::pSet->erase(lower, upper);
1473 FD_DC( "TTransSet(" << this << ")::EraseByX1Ev(" << x1 << "," << ev << ")");
1474 #ifdef FAUDES_CHECKED
1479 typename BASE::iterator lower, upper, it;
1482 lower = BASE::pSet->lower_bound(tl);
1483 upper = BASE::pSet->upper_bound(tu);
1484 if(this->AttributesSize()!=0)
1485 for(it=lower; it!=upper; ++it)
1486 BASE::ClrAttribute(*it);
1487 BASE::pSet->erase(lower, upper);
1492 FD_DC( "TTransSet(" << this << ")::EraseByX2(" << x2 << ")");
1494 bool doattr = (this->AttributesSize()!=0);
1495 typename BASE::iterator it;
1496 for(it = BASE::pSet->begin(); it != BASE::pSet->end();) {
1498 if(doattr) BASE::ClrAttribute(*it);
1499 BASE::pSet->erase(it++);
1508 FD_DC( "TTransSet(" << this << ")::EraseByEv(" << ev << ")");
1510 bool doattr = (this->AttributesSize()!=0);
1511 typename BASE::iterator it;
1512 for(it = BASE::pSet->begin(); it != BASE::pSet->end();) {
1514 if(doattr) BASE::ClrAttribute(*it);
1515 BASE::pSet->erase(it++);
1525 FD_DC( "TTransSet(" << this << ")::EraseByX1OrX2(" << x << ")");
1527 bool doattr = (this->AttributesSize()!=0);
1528 typename BASE::iterator it;
1529 for(it = BASE::pSet->begin(); it != BASE::pSet->end();) {
1530 if ((it->X1 == x) || (it->X2 == x)) {
1531 if(doattr) BASE::ClrAttribute(*it);
1532 BASE::pSet->erase(it++);
1537 FD_DC( "TTransSet(" << this << ")::EraseByX1OrX2(" << x << "): done");
1543 FD_DC( "TTransSet(" << this << ")::EraseByX1OrX2(#" << rStates. Size() << ")");
1545 bool doattr = (this->AttributesSize()!=0);
1546 typename BASE::iterator it=BASE::pSet->begin();
1547 while(it != BASE::pSet->end()) {
1548 if(!rStates. Exists(it->X1) && !rStates. Exists(it->X2)) { ++it; continue;}
1549 if(doattr) BASE::ClrAttribute(*it);
1550 BASE::pSet->erase(it++);
1552 FD_DC( "TTransSet(" << this << ")::EraseByX1OrX2(): done");
1558 FD_DC( "TTransSet(" << this << ")::RestrictByX1AndX2(#" << rStates. Size() << ")");
1560 bool doattr = (this->AttributesSize()!=0);
1561 typename BASE::iterator it;
1562 it = BASE::pSet->begin();
1563 while(it != BASE::pSet->end()) {
1564 if(rStates. Exists(it->X1) && rStates. Exists(it->X2)) { ++it; continue;}
1565 if(doattr) BASE::ClrAttribute(*it);
1566 BASE::pSet->erase(it++);
1568 FD_DC( "TTransSet(" << this << ")::EraseByX1OrX2(): done");
1574 FD_DC( "TTransSet(" << this << ")::RestrictEvents(#" << rEvents. Size() << ")");
1576 bool doattr = (this->AttributesSize()!=0);
1577 typename BASE::iterator it;
1578 it = BASE::pSet->begin();
1579 while(it != BASE::pSet->end()) {
1580 if(rEvents. Exists(it->Ev)) { ++it; continue;}
1581 if(doattr) BASE::ClrAttribute(*it);
1582 BASE::pSet->erase(it++);
1584 FD_DC( "TTransSet(" << this << ")::RestrictEvents(): done");
1596 return BASE::Find(t);
1601 return BASE::Exists(t);
1611 typename BASE::iterator it;
1612 for(it = BASE::pSet->begin(); it != BASE::pSet->end(); ++it) {
1613 if ((it->X1 == x) || (it->X2 == x)) {
1622 FD_DC( "TTransSet(" << this << ")::ExistsByX1Ev(" << x1 << "," << ev << ")");
1623 #ifdef FAUDES_CHECKED
1628 typename BASE::iterator lower, upper, it;
1631 lower = BASE::pSet->lower_bound(tl);
1632 upper = BASE::pSet->upper_bound(tu);
1633 return lower != upper;
1638 FD_DC( "TTransSet(" << this << ")::ExistsByX1(" << x1 << ")");
1639 #ifdef FAUDES_CHECKED
1645 typename BASE::iterator lower, upper, it;
1648 lower = BASE::pSet->lower_bound(tl);
1649 upper = BASE::pSet->upper_bound(tu);
1650 return lower != upper;
1655 TEMP template< class OtherCmp>
1659 for (it = Begin(); it != End(); ++it) {
1668 for (it=Begin(); it!=End(); ++it) {
1677 #ifdef FAUDES_CHECKED
1685 while (it != it_end) {
1694 #ifdef FAUDES_CHECKED
1700 StateSet::Iterator sit= rX1Set. Begin();
1701 StateSet::Iterator sit_end= rX1Set. End();
1702 for(;sit!=sit_end; ++sit) {
1705 while(tit!=tit_end) {
1715 #ifdef FAUDES_CHECKED
1722 while (it != it_end) {
1731 #ifdef FAUDES_CHECKED
1736 if(rEvSet. Empty()) return states;
1737 StateSet::Iterator sit= rX1Set. Begin();
1738 StateSet::Iterator sit_end= rX1Set. End();
1739 for(;sit!=sit_end; ++sit) {
1740 EventSet::Iterator eit= rEvSet. Begin();
1741 EventSet::Iterator eit_end= rEvSet. End();
1744 while(tit!=tit_end) {
1746 if(tit->Ev == *eit) {
1752 if(tit->Ev < *eit) {
1758 if(eit==eit_end) break;
1770 for (; it != it_end; ++it) {
1778 return rTrans. Str();
1797 #define THIS TaTransSet<Attr>
1798 #define TEMP template <class Attr>
1799 #define BASE TTransSet<TransSort::X1EvX2>
1800 #define ABASE TAttrMap<Transition,Attr,TransSort::X1EvX2>
1810 FD_DC( "TaTransSet(" << this << ")::TaTransSet()");
1818 FD_DC( "TaTransSet(" << this << ")::TaTransSet(rOtherSet "<< &rOtherSet << ")");
1828 FD_DC( "TaTransSet(" << this << ")::TaTransSet(rOtherSet "<< &rOtherSet << ")");
1836 BASE::DoAssign(rSourceSet);
1841 FD_DC( "TaTransSet(" << this << ")::Assign([v] " << &rSourceSet<< ")");
1842 #ifdef FAUDES_CHECKED
1843 FD_DC( "TaTransSet(" << this << ")::Assign(): src at " << &rSourceSet);
1844 FD_DC( "TaTransSet(" << this << ")::Assign(): src type " << typeid(rSourceSet).name());
1845 FD_DC( "TaTransSet(" << this << ")::Assign(): dst type " << typeid(*this).name());
1848 std::stringstream errstr;
1849 errstr << "cannot cast " << typeid(rSourceSet).name() << " to TransSet" << std::endl;
1850 throw Exception( "TaTransSet::Assign", errstr.str(), 67);
1854 ABASE::AssignWithAttributes(rSourceSet);
1862 FD_DC( "TaTransSet(" << this << ")::Insert(" << t. Str() << ")");
1863 return ABASE::Insert(t);
1868 FD_DC( "TaTransSet(" << this << ")::Insert(" << x1 << "-" << ev << "-" << x2 << ")");
1870 return ABASE::Insert(t);
1875 return ABASE::Insert(t,attr);
1881 FD_DC( "TaTransSet(" << this << ")::InsertSet( [a] " << &rOtherSet << ")");
1882 ABASE::InsertSet(rOtherSet);
1887 #ifdef FAUDES_CHECKED
1888 FD_DC( "TaTransSet(" << this << ")::InsertSet(" << rOtherSet. ToString() << ")");
1891 std::stringstream errstr;
1892 errstr << "cannot cast " << typeid(rOtherSet).name() << " to TransSet" << std::endl;
1893 throw Exception( "TaTransSet::InsertSet", errstr.str(), 67);
1896 ABASE::InsertSet(rOtherSet);
1902 return ABASE::Erase(t);
1907 FD_DC( "TaTransSet(" << this << ")::Erase(" << x1 << "-" << ev << "-" << x2 << ")");
1909 return ABASE::Erase(t);
1914 #ifdef FAUDES_CHECKED
1916 std::stringstream errstr;
1917 errstr << "iterator out of range " << std::endl;
1918 throw Exception( "TTransSet::Erase", errstr.str(), 69);
1921 return ABASE::Erase(it);
1926 FD_DC( "TaTransSet(" << this << ")::RestrictSet( [a] " << &rOtherSet << ")");
1927 ABASE::EraseSet(rOtherSet);
1932 #ifdef FAUDES_CHECKED
1933 FD_DC( "TaTransSet(" << this << ")::EraseSet(" << rOtherSet. ToString() << ")");
1936 std::stringstream errstr;
1937 errstr << "cannot cast " << typeid(rOtherSet).name() << " to TransSet" << std::endl;
1938 throw Exception( "TaTransSet::EraseSet", errstr.str(), 67);
1941 ABASE::EraseSet(rOtherSet);
1946 FD_DC( "TaTransSet(" << this << ")::RestrictSet( [a] " << &rOtherSet << ")");
1947 ABASE::RestrictSet(rOtherSet);
1953 #ifdef FAUDES_CHECKED
1954 FD_DC( "TaTransSet(" << this << ")::RestrictSet(" << rOtherSet. ToString() << ")");
1957 std::stringstream errstr;
1958 errstr << "cannot cast " << typeid(rOtherSet).name() << " to TransSet" << std::endl;
1959 throw Exception( "TaTransSet::RestrictSet", errstr.str(), 67);
1962 ABASE::RestrictSet(rOtherSet);
1972 #undef SORT_EXECPTION
libFAUDES 2.28a
--- 2016.09.13
--- c++ api documentaion by doxygen
|