25 #ifndef FAUDES_BASESET_H
26 #define FAUDES_BASESET_H
43 template<
class T,
class Attr,
class Cmp>
class TAttrMap;
92 template<
class T,
class Cmp=std::less<T> >
100 template<
class TP,
class AP,
class CP>
friend class TAttrMap;
126 TBaseSet(
const std::string& rFilename,
const std::string& rLabel =
"BaseSet");
139 const std::string&
Name(
void)
const;
147 void Name(
const std::string& rName);
181 virtual std::string
Str(
const T& rElem)
const;
216 virtual bool Valid(
const T& rElem)
const;
238 virtual Iterator
Erase(
const Iterator& pos);
286 virtual Iterator
Inject(
const Iterator& pos,
const T& rElem);
327 Iterator
Find(
const T& rElem)
const;
364 void DValid(
const std::string& rMessage=
"")
const;
399 const typename std::set<T,Cmp>::const_iterator& sit,
405 if(pBaseSet && att) {
414 pBaseSet(fit.pBaseSet),
418 pBaseSet->AttachIterator(
this);
425 if(mAttached) pBaseSet->DetachIterator(
this);
430 std::stringstream rstr;
431 rstr <<
"[dit base " << pBaseSet <<
" a" << mAttached <<
" data " << pBaseSet->pSet;
432 if(pBaseSet) rstr <<
" elem " << pBaseSet->Str(**
this);
439 #ifdef FAUDES_DEBUG_CODE
441 FD_ERR(
"TBaseSet<T,Cmp>::Iterator(" <<
this <<
"):operator= invalid iterator: no baseset");
446 if(mAttached)
if(pBaseSet==rSrc.
pBaseSet) {
447 std::set<T,Cmp>::const_iterator::operator= (rSrc);
451 if(mAttached) pBaseSet->DetachIterator(
this);
452 std::set<T,Cmp>::const_iterator::operator= (rSrc);
464 void StlIterator(
const typename std::set<T,Cmp>::const_iterator& sit) {
465 std::set<T,Cmp>::const_iterator::operator= (sit);
469 const typename std::set<T,Cmp>::const_iterator&
StlIterator(
void)
const {
488 FD_ERR(
"TBaseSet<T,Cmp>::Iterator(" <<
this <<
"):DValid(): invalid iterator: no baseset");
491 pBaseSet->DValid(
"Iterator");
495 const T* operator-> (
void)
const {
496 #ifdef FAUDES_DEBUG_CODE
498 FD_ERR(
"TBaseSet<T,Cmp>::Iterator(" <<
this <<
"):operator->: invalid iterator: no baseset");
502 return std::set<T,Cmp>::const_iterator::operator-> ();
506 const T& operator* (
void)
const {
507 #ifdef FAUDES_DEBUG_CODE
509 FD_ERR(
"TBaseSet<T,Cmp>::Iterator(" <<
this <<
"):operator*: invalid iterator: no baseset");
513 return std::set<T,Cmp>::const_iterator::operator* ();
518 #ifdef FAUDES_DEBUG_CODE
520 FD_ERR(
"TBaseSet<T,Cmp>::Iterator(" <<
this <<
"):operator==: invalid iterator: no baseset");
524 return *
static_cast< const typename std::set<T,Cmp>::const_iterator *
>(
this) == rOther;
529 #ifdef FAUDES_DEBUG_CODE
531 FD_ERR(
"TBaseSet<T,Cmp>::Iterator(" <<
this <<
"):operator!=: invalid iterator: no baseset");
535 return *
static_cast< const typename std::set<T,Cmp>::const_iterator *
>(
this) != rOther;
540 #ifdef FAUDES_DEBUG_CODE
542 FD_ERR(
"TBaseSet<T,Cmp>::Iterator(" <<
this <<
"):operator++: invalid iterator: no baseset");
547 std::set<T,Cmp>::const_iterator::operator++ (step);
553 #ifdef FAUDES_DEBUG_CODE
555 FD_ERR(
"TBaseSet<T,Cmp>::Iterator(" <<
this <<
"):operator++: invalid iterator: no baseset");
559 std::set<T,Cmp>::const_iterator::operator++ ();
565 #ifdef FAUDES_DEBUG_CODE
567 FD_ERR(
"TBaseSet<T,Cmp>::Iterator(" <<
this <<
"):operator--: invalid iterator: no baseset");
571 Iterator old(pBaseSet, *
this,
true);
572 std::set<T,Cmp>::const_iterator::operator-- (step);
578 #ifdef FAUDES_DEBUG_CODE
580 FD_ERR(
"TBaseSet<T,Cmp>::Iterator(" <<
this <<
"):operator--: invalid iterator: no baseset");
584 std::set<T,Cmp>::const_iterator::operator-- ();
603 #ifdef DONT_TRACK_REFERENCES
614 std::set<T,Cmp>::const_iterator()
618 Iterator(
const Iterator& fit) :
619 std::set<T,Cmp>::const_iterator(fit)
623 Iterator(
const typename std::set<T,Cmp>::const_iterator& sit) :
624 std::set<T,Cmp>::const_iterator(sit)
629 const TBaseSet<T,Cmp>* pBaseSet,
630 const typename std::set<T,Cmp>::const_iterator& sit) :
631 std::set<T,Cmp>::const_iterator(sit)
635 void StlIterator(
const typename std::set<T,Cmp>::const_iterator& sit) {
636 std::set<T,Cmp>::const_iterator::operator= (sit);
640 const typename std::set<T,Cmp>::const_iterator& StlIterator(
void)
const {
645 void Invalidate(
void) {};
778 virtual void AttributeTry(
const T& rElem,
const Type& rAttr) { (void) rElem; (void) rAttr; };
916 typedef typename std::set<T,Cmp>::iterator
iterator;
933 typedef typename std::map<T,AttributeVoid*>::iterator
aiterator;
1018 template<
class T,
class Cmp>
1020 FD_DC(
"FAUDES_DEBUG_CONTAINER: SetUnion(TBaseSet<T,Cmp>): res at " << &rRes);
1024 if(&rSetA==&rSetB && &rSetA==&rRes) {rRes.
Name(name);
return;}
1026 if(&rSetA==&rSetB) {rRes.
Assign(rSetA); rRes.
Name(name);
return;}
1028 if(&rSetA==&rRes) {rRes.
InsertSet(rSetB); rRes.
Name(name);
return;};
1030 if(&rSetB==&rRes) {rRes.
InsertSet(rSetA); rRes.
Name(name);
return;};
1035 FD_DC(
"FAUDES_DEBUG_CONTAINER: SetUnion(TBaseSet<T,Cmp>): done, res at " << &rRes <<
" #" << rRes.
Size());
1048 template<
class T,
class Cmp >
1053 if(&rSetA==&rSetB && &rSetA==&rRes) {rRes.
Name(name);
return;}
1055 if(&rSetA==&rSetB) { rRes.
Assign(rSetA); rRes.
Name(name);
return;}
1057 if(&rSetA==&rRes) {rRes.
RestrictSet(rSetB); rRes.
Name(name);
return;};
1059 if(&rSetB==&rRes) {rRes.
RestrictSet(rSetA); rRes.
Name(name);
return;};
1077 template<
class T,
class Cmp >
1082 if(&rSetA==&rSetB) { rRes.
Clear(); rRes.
Name(name);
return;}
1084 if(&rSetA==&rRes) {rRes.
EraseSet(rSetB); rRes.
Name(name);
return;};
1111 template<
class T,
class Cmp >
1113 return rSetA==rSetB;
1127 template<
class T,
class Cmp >
1129 return rSetA<=rSetB;
1151 #define THIS TBaseSet<T,Cmp>
1152 #define TEMP template<class T, class Cmp>
1171 TEMP std::set<T,Cmp> THIS::msEmptySet=std::set<T,Cmp>();
1172 TEMP std::map<T,AttributeVoid*> THIS::msEmptyAttributes=std::map<T,AttributeVoid*>();
1179 pAttributes(&msEmptyAttributes),
1182 mpClients(new std::list<
TBaseSet<T,Cmp>* >),
1185 pTypeDefinition(NULL)
1188 FD_DC(
"TBaseSet(" <<
this <<
")::TBaseSet()");
1194 TEMP THIS::TBaseSet(
const std::string& rFileName,
const std::string& rLabel) :
1198 pAttributes(&msEmptyAttributes),
1201 mpClients(new std::list<
TBaseSet<T,Cmp>* >),
1204 pTypeDefinition(NULL)
1207 FD_DC(
"TBaseSet(" <<
this <<
")::TBaseSet()");
1211 Read(rFileName,rLabel);
1219 pAttributes(&msEmptyAttributes),
1222 mpClients(new std::list<
TBaseSet<T,Cmp>* >),
1225 pTypeDefinition(NULL)
1228 FD_DC(
"TBaseSet(" <<
this <<
")::TBaseSet(rOtherSet " << &rOtherSet <<
"): fake copy construct");
1231 #ifdef FAUDES_DEBUG_CODE
1239 FD_DC(
"TBaseSet(" <<
this <<
")::~TBaseSet()");
1242 pHostSet->DetachClient(
this);
1243 if(mpClients)
delete mpClients;
1246 typename std::set< Iterator* >::const_iterator iit;
1247 for(iit=mIterators.begin(); iit!=mIterators.end(); ++iit) {
1248 (**iit).Invalidate();
1251 if(mpSet)
delete mpSet;
1253 for(
aiterator ait=mpAttributes->begin(); ait!=mpAttributes->end(); ++ait)
1255 delete mpAttributes;
1262 FD_DC(
"TBaseSet(" <<
this <<
"/" << this->Name() <<
")::DoAssign(rOtherSet " << &rSourceSet <<
"): shallow copy -- src attr# " << rSourceSet.pAttributes->size());
1263 FD_DC(
"TBaseSet():DoAssign(): " <<
typeid(*this->AttributeType()).name() <<
" <== " <<
typeid(*rSourceSet.AttributeType()).name());
1265 if(
this==&rSourceSet)
return;
1267 mMyName=rSourceSet.mMyName;
1269 if(pHostSet==rSourceSet.pHostSet)
return;
1272 pHostSet->DetachClient(
this);
1279 for(
aiterator ait=mpAttributes->begin(); ait!=mpAttributes->end(); ++ait)
1281 delete mpAttributes;
1290 if(
typeid(*rSourceSet.AttributeType())==
typeid(*this->AttributeType())) {
1291 pHostSet=rSourceSet.pHostSet;
1292 pHostSet->AttachClient(
this);
1293 pSet=rSourceSet.pSet;
1294 pAttributes=rSourceSet.pAttributes;
1298 mpSet =
new std::set<T,Cmp>();
1299 *mpSet = *rSourceSet.pSet;
1301 mpAttributes =
new std::map<T,AttributeVoid*>();
1302 if(
typeid(*this->AttributeType()) !=
typeid(
const AttributeVoid)) {
1303 for(
aiterator ait=rSourceSet.pAttributes->begin(); ait!=rSourceSet.pAttributes->end(); ++ait) {
1305 (*mpAttributes)[ait->first]=attr;
1308 pAttributes = mpAttributes;
1312 typename std::set< Iterator* >::iterator iit;
1313 for(iit=mIterators.begin(); iit!=mIterators.end(); ++iit) {
1314 (**iit).Invalidate();
1324 #ifdef FAUDES_DEBUG_CODE
1325 DValid(
"PostFakeAssignment");
1327 FD_DC(
"TBaseSet(" <<
this <<
")::DoAssign(rOtherSet " << &rSourceSet <<
"): fake copy -- done with attr# " << pAttributes->size());
1332 FD_DC(
"TBaseSet(" <<
this <<
")::Detach(void)");
1333 #ifdef FAUDES_DEBUG_CODE
1334 DValid(
"PreDetach");
1339 if(flag==SetOnly) pAttributes->clear();
1344 THIS* fake_const =
const_cast< THIS*
>(
this);
1346 #ifdef FAUDES_DEBUG_CODE
1349 if(pSet!=&msEmptySet)
1351 if(mpClients->empty()) {
1352 FD_ERR(
"TBaseSet(" <<
this <<
")::Detach(): missed detach (?)");
1354 fake_const->mDetached=
true;
1359 std::set<T,Cmp>* scopy =
new std::set<T,Cmp>();
1363 std::map<T,AttributeVoid*>* acopy =
new std::map<T,AttributeVoid*>();
1364 if(flag==AttrIncl) {
1365 for(
aiterator ait=pAttributes->begin(); ait!=pAttributes->end(); ++ait) {
1367 (*acopy)[ait->first]=attr;
1376 FD_DC(
"TBaseSet(" <<
this <<
")::Detach(): allocate and copy, strategie A");
1378 THIS* newhost = *mpClients->begin();
1379 #ifdef FAUDES_DEBUG_CODE
1380 if(newhost->mpClients)
1381 FD_ERR(
"TBaseSet(" <<
this <<
")::Detach(): new host used to heve clients (?)");
1383 newhost->pHostSet=newhost;
1384 newhost->mpSet=scopy;
1385 newhost->pSet=scopy;
1386 newhost->mpAttributes=acopy;
1387 newhost->pAttributes=acopy;
1388 newhost->mpClients=mpClients;
1389 newhost->DetachClient(newhost);
1391 typename std::list< THIS* >::const_iterator rit;
1392 for(rit=newhost->mpClients->begin();rit!=newhost->mpClients->end(); ++rit) {
1393 (*rit)->pHostSet=newhost;
1394 (*rit)->pSet=newhost->pSet;
1395 (*rit)->pAttributes=newhost->pAttributes;
1398 typename std::set< Iterator* >::iterator iit;
1399 for(rit=newhost->mpClients->begin(); rit!=newhost->mpClients->end(); ++rit) {
1400 for(iit=(*rit)->mIterators.begin(); iit!=(*rit)->mIterators.end(); ++iit) {
1401 if((**iit).StlIterator()==pSet->end())
1402 **iit=
Iterator(
this, scopy->end());
1404 **iit=
Iterator(
this, scopy->find(***iit));
1408 for(iit=newhost->mIterators.begin(); iit!=newhost->mIterators.end(); ++iit) {
1409 if((**iit).StlIterator()==pSet->end())
1410 **iit=
Iterator(
this, scopy->end());
1412 **iit=
Iterator(
this, scopy->find(***iit));
1415 fake_const->mpSet=pSet;
1416 fake_const->mpAttributes=pAttributes;
1417 fake_const->mpClients=
new std::list< TBaseSet<T,Cmp>* >;
1418 fake_const->mDetached=
true;
1420 for(iit=mIterators.begin(); iit!=mIterators.end(); ++iit)
1422 fake_const->mIterators.clear();
1430 FD_DC(
"TBaseSet(" <<
this <<
")::Detach(): allocate and copy, strategie B");
1432 fake_const->RelinkClients();
1433 pHostSet->DetachClient(fake_const);
1435 fake_const->mpSet = scopy;
1436 fake_const->mpAttributes=acopy;
1438 typename std::set< Iterator* >::iterator iit;
1439 for(iit=mIterators.begin(); iit!=mIterators.end(); ++iit) {
1440 if((**iit).StlIterator()==pSet->end())
1441 **iit=
Iterator(
this, mpSet->end());
1443 **iit=
Iterator(
this, mpSet->find(***iit));
1446 fake_const->pHostSet=fake_const;
1447 fake_const->pSet=mpSet;
1448 fake_const->pAttributes=mpAttributes;
1449 fake_const->mDetached=
true;
1450 if(fake_const->mpClients)
delete fake_const->mpClients;
1451 fake_const->mpClients=
new std::list< TBaseSet<T,Cmp>* >;
1455 #ifdef FAUDES_DEBUG_CODE
1456 DValid(
"PostDetach");
1458 FD_DC(
"TBaseSet(" <<
this <<
")::Detach(): done");
1463 FD_DC(
"TBaseSet(" <<
this <<
")::Lock(void)");
1464 #ifdef FAUDES_DEBUG_CODE
1474 THIS* fake_const =
const_cast< THIS*
>(
this);
1477 typename std::set< Iterator* >::const_iterator iit;
1478 for(iit=mIterators.begin(); iit!=mIterators.end(); ++iit) {
1481 fake_const->mIterators.clear();
1484 fake_const->mLocked=
true;
1486 #ifdef FAUDES_DEBUG_CODE
1493 TEMP inline void THIS::RelinkClients(
void) {
1494 FD_DC(
"TBaseSet::RelinkClients(" <<
this <<
")")
1495 #ifdef FAUDES_DEBUG_CODE
1496 DValid(
"PreRelink");
1500 if(!mpClients)
return;
1502 if(mpClients->empty())
return;
1504 FD_DC(
"TBaseSet::RelinkClients(" <<
this <<
"): doit")
1507 THIS* newhost = *mpClients->begin();
1508 #ifdef FAUDES_DEBUG_CODE
1509 if(newhost->pHostSet!=
this)
1510 FD_ERR(
"BaseSet::RelinkRefernces: old reference must have this as provider");
1511 if(newhost->mpClients)
1512 FD_ERR(
"TBaseSet(" <<
this <<
")::RelinkClients(void): client is a host (?)");
1514 newhost->pHostSet=newhost;
1515 newhost->mpSet=mpSet;
1517 newhost->mpAttributes=mpAttributes;
1518 newhost->pAttributes=pAttributes;
1519 newhost->mpClients=mpClients;
1520 newhost->DetachClient(newhost);
1522 typename std::list< THIS* >::const_iterator rit;
1523 for(rit=newhost->mpClients->begin();rit!=newhost->mpClients->end(); ++rit) {
1524 (*rit)->pHostSet=newhost;
1530 pAttributes=newhost->pAttributes;
1532 newhost->AttachClient(
this);
1534 #ifdef FAUDES_DEBUG_CODE
1535 DValid(
"PostRelink");
1537 FD_DC(
"TBaseSet::RelinkClients(" <<
this <<
"): done")
1544 const_cast< THIS*
>(
this)->mpClients->push_back(pRef);
1546 const_cast< THIS*
>(
this)->mDetached=
false;
1551 FD_DC(
"TBaseSet::DetachClient(" <<
this <<
"):" << pRef);
1553 if(!mpClients)
return;
1554 if(mpClients->empty())
return;
1557 THIS* fake_const =
const_cast< THIS*
>(
this);
1558 #ifdef FAUDES_DEBUG_CODE
1560 typename std::list< TBaseSet<T,Cmp>* >
::iterator cit;
1562 for(cit=fake_const->mpClients->begin(); cit!=fake_const->mpClients->end(); ++cit) {
1563 if(*cit==pRef) cf=
true;
1566 FD_ERR(
"TBaseSet::DetachClient(" <<
this <<
"): client not found " << pRef);
1579 typename std::list< TBaseSet<T,Cmp>* >
::iterator rit;
1580 for(rit=fake_const->mpClients->begin(); rit!=fake_const->mpClients->end(); ++rit) {
1581 if(*rit!=pRef)
continue;
1582 fake_const->mpClients->erase(rit);
1586 if(mpClients->empty() && (pSet!=&msEmptySet)) fake_const->mDetached=
true;
1587 FD_DC(
"TBaseSet::DetachClient(" <<
this <<
"): done.");
1594 FD_DC(
"TBaseSet::AttachIterator(" <<
this <<
"):" << pFit)
1595 const_cast< THIS*
>(
this)->mIterators.insert(pFit);
1601 FD_DC(
"TBaseSet::DetachIterator(" <<
this <<
"):" << pFit)
1602 const_cast< THIS*
>(
this)->mIterators.erase(pFit);
1606 TEMP void THIS::DValid(
const std::string& rMessage)
const {
1607 typename std::set< Iterator* >::const_iterator iit;
1608 typename std::list< THIS* >::const_iterator rit;
1609 #ifdef FAUDES_DEBUG_CONTAINER
1610 std::cerr <<
"TBaseSet(" <<
this <<
")::DValid(): " << rMessage <<
" source "
1611 << pHostSet <<
" " << (pHostSet->pSet==&msEmptySet ?
"+e+" :
"+f+") <<
1612 (mLocked ?
" +l+" :
" ") << (mDetached ?
" +d+" :
" ") <<
" -- refs ";
1613 if(pHostSet->mpClients)
1614 for(rit=pHostSet->mpClients->begin(); rit!=pHostSet->mpClients->end(); ++rit)
1615 std::cerr << *rit <<
" ";
1616 std::cerr <<
"-- its ";
1617 for(iit=mIterators.begin(); iit!=mIterators.end(); ++iit)
1618 std::cerr << *iit <<
" ";
1619 std::cerr <<
"-- attr #" << pAttributes->size();
1620 if(mpAttributes) std::cerr <<
"(" << mpAttributes->size() <<
") ";
1621 else std::cerr <<
" ";
1622 std::cerr << (pAttributes==&msEmptyAttributes ?
"+e+ " :
"+f+ ") << std::endl;
1625 for(iit=mIterators.begin(); iit!=mIterators.end(); ++iit) {
1626 if((*iit)->pBaseSet!=
this) {
1627 FD_WARN(
"BaseSet("<<
this <<
"," << rMessage <<
"): invalid iterator (baseset): "<< *iit);
1632 for(iit=mIterators.begin(); iit!=mIterators.end(); ++iit) {
1633 if(!(*iit)->mAttached) {
1634 FD_WARN(
"BaseSet("<<
this <<
"," << rMessage <<
"): invalid iterator (attached): "<< *iit);
1639 for(iit=mIterators.begin(); iit!=mIterators.end(); ++iit) {
1640 typename std::set<T,Cmp>::const_iterator vit;
1641 for(vit=pSet->begin(); vit!= pSet->end(); ++vit) {
1642 if(vit==(**iit).StlIterator())
break;
1644 if(vit!=(**iit).StlIterator()) {
1645 FD_WARN(
"BaseSet("<<
this <<
"," << rMessage <<
"): invalid iterator (stl) "<< *iit);
1646 (**iit).StlIterator(pSet->end());
1651 if(pHostSet==NULL) {
1652 FD_WARN(
"BaseSet(" <<
this <<
"," << rMessage <<
"): no host found");
1656 if(pHostSet->pHostSet != pHostSet) {
1657 FD_WARN(
"BaseSet(" <<
this <<
"," << rMessage <<
"): inconsistent host");
1661 if((mpSet!=NULL) && (pHostSet !=
this)) {
1662 FD_WARN(
"BaseSet(" <<
this <<
"," << rMessage <<
"): double data");
1666 if(pHostSet!=
this && mpClients!=NULL) {
1667 FD_WARN(
"BaseSet(" <<
this <<
"," << rMessage <<
"): cannot be client and have clients oneself");
1671 if(pHostSet->mpClients==NULL) {
1672 FD_WARN(
"BaseSet(" <<
this <<
"," << rMessage <<
"): refers to invalid host (a)");
1676 if(pHostSet!=
this && pHostSet->mpClients->empty()) {
1677 FD_WARN(
"BaseSet(" <<
this <<
"," << rMessage <<
"): refers to invalid host (b)");
1681 if((pHostSet ==
this) && (mpSet==NULL) && (pSet!=&msEmptySet)) {
1682 FD_WARN(
"BaseSet(" <<
this <<
"," << rMessage <<
"): no data");
1686 if((pHostSet==
this) && (pSet!=&msEmptySet) && (mpClients==NULL)) {
1687 FD_WARN(
"BaseSet(" <<
this <<
"," << rMessage <<
"): host with no client list");
1691 if((pHostSet ==
this) && (pSet != mpSet) && (pSet!=&msEmptySet)) {
1692 FD_WARN(
"BaseSet(" <<
this <<
"," << rMessage <<
"): data pointer mismatch A");
1696 if(pSet != pHostSet->pSet) {
1697 FD_WARN(
"BaseSet(" <<
this <<
"," << rMessage <<
"): data pointer mismatch B");
1702 for(rit=pHostSet->mpClients->begin(); rit!=pHostSet->mpClients->end(); ++rit) {
1703 if((*rit)==
this) hf=
true;
1704 if((*rit)->pHostSet== pHostSet)
continue;
1705 FD_WARN(
"BaseSet(" <<
this <<
"," << rMessage <<
"): invalid client " << (*rit));
1708 if(!hf && (pHostSet!=
this)) {
1709 FD_WARN(
"BaseSet(" <<
this <<
"," << rMessage <<
"): client not registered with host");
1713 if(pHostSet!=
this && *mClientRecord!=
this) {
1714 FD_WARN(
"BaseSet(" <<
this <<
"," << rMessage <<
"): refers to invalid host (c)");
1718 if(mDetached && mpClients==NULL) {
1719 FD_WARN(
"BaseSet(" <<
this <<
"," << rMessage <<
"): invalid detached flag A");
1723 if(mDetached && !mpClients->empty()) {
1724 FD_WARN(
"BaseSet(" <<
this <<
"," << rMessage <<
"): invalid detached flag B");
1728 if(mDetached && (pSet==&msEmptySet)) {
1729 FD_WARN(
"BaseSet(" <<
this <<
"," << rMessage <<
"): detached empty set");
1733 if(mLocked && (mpClients==NULL)) {
1734 FD_WARN(
"BaseSet(" <<
this <<
"," << rMessage <<
"): locked reference (a)");
1738 if(!msEmptySet.empty()) {
1739 FD_WARN(
"BaseSet(" <<
this <<
"," << rMessage <<
"): invalid empty set");
1743 if(!msEmptyAttributes.empty()) {
1744 FD_WARN(
"BaseSet(" <<
this <<
"," << rMessage <<
"): invalid empty attributes");
1747 #ifdef FAUDES_DEBUG_CONTAINER
1748 std::cerr <<
"TBaseSet(" <<
this <<
")::DValid(): passed" << std::endl;
1755 TEMP const std::string& THIS::Name(
void)
const {
1760 TEMP void THIS::Name(
const std::string& rName) {
1768 if(!pTypeDefinition) {
1770 THIS* fake_const =
const_cast< THIS*
>(
this);
1773 return pTypeDefinition;
1777 TEMP const std::string& THIS::XElementTag(
void)
const {
1778 if(mXElementTag.empty()) {
1780 THIS* fake_const =
const_cast< THIS*
>(
this);
1781 fake_const->mXElementTag=
"Element";
1783 if(fdp) fake_const->mXElementTag=fdp->
XElementTag();
1785 return mXElementTag;
1789 TEMP void THIS::XElementTag(
const std::string& rTag) {
1795 TEMP const std::string& THIS::TypeName(
void)
const {
1796 if(mFaudesTypeName.empty()) {
1798 THIS* fake_const =
const_cast< THIS*
>(
this);
1800 if(fdp) fake_const->mFaudesTypeName=fdp->
Name();
1802 return mFaudesTypeName;
1806 TEMP void THIS::TypeName(
const std::string& rType) {
1807 mFaudesTypeName=rType;
1812 TEMP std::string THIS::Str(
const T& rElem)
const {
1820 return (
Idx) pSet->size();
1824 TEMP bool THIS::Empty(
void)
const {
1825 return pSet->empty();
1832 std::string label=rLabel;
1833 if(label==
"") label=Name();
1834 if(label==
"") label=
"BaseSet";
1835 FD_DC(
"TBaseSet(" <<
this <<
")::DoWrite(..): section " << label <<
" #" << Size());
1845 BASE::DoSWrite(rTw);
1847 if(pHostSet->mpClients) shares=pHostSet->mpClients->size();
1854 #ifdef FAUDES_DEBUG_CODE
1861 BASE::DoSWrite(rTw);
1863 if(pHostSet->mpClients) shares=pHostSet->mpClients->size();
1866 if(pAttributes->size()!=0)
1868 if(pAttributes->size()!=0) {
1877 std::string label=rLabel;
1878 if(label==
"") label=Name();
1879 if(label==
"") label=
"BaseSet";
1886 TEMP typename THIS::Iterator THIS::ThisIterator(
const typename std::set<T,Cmp>::const_iterator& sit)
const {
1891 TEMP inline typename THIS::Iterator THIS::Begin(
void)
const {
1892 return ThisIterator(pSet->begin());
1896 TEMP inline typename THIS::Iterator THIS::End(
void)
const {
1897 return ThisIterator(pSet->end());
1903 FD_DC(
"TBaseSet(" <<
this <<
")::Clear()");
1904 #ifdef FAUDES_DEBUG_CODE
1908 if(pSet==&msEmptySet)
return;
1910 FD_DC(
"TBaseSet(" <<
this <<
")::Clear(): doit");
1911 FD_DC(
"TBaseSet(" <<
this <<
")::Clear(): type " <<
typeid(*this).name());
1913 if(mLocked) Detach(SetOnly);
1916 pHostSet->DetachClient(
this);
1919 if(!mpClients) mpClients=
new std::list< TBaseSet<T,Cmp>* >;
1928 for(
aiterator ait=mpAttributes->begin(); ait!=mpAttributes->end(); ++ait) {
1929 FD_DC(
"TBaseSet(" <<
this <<
")::Clear(): del attr " << ait->second);
1932 delete mpAttributes;
1937 pAttributes=&msEmptyAttributes;
1939 typename std::set< Iterator* >::iterator iit;
1940 for(iit=mIterators.begin(); iit!=mIterators.end(); ++iit) {
1941 (**iit).Invalidate();
1946 #ifdef FAUDES_DEBUG_CODE
1947 DValid(
"PostClear");
1949 FD_DC(
"TBaseSet(" <<
this <<
")::Clear(): done");
1954 TEMP inline bool THIS::Valid(
const T& rElem)
const {
1960 TEMP bool THIS::Insert(
const T& rElem) {
1961 #ifdef FAUDES_CHECKED
1963 std::stringstream errstr;
1964 errstr <<
"refuse to insert invalid element" << std::endl;
1965 throw Exception(
"BaseSet::Insert", errstr.str(), 61);
1968 if(!mDetached) Detach();
1969 return pSet->insert(rElem).second;
1973 TEMP typename THIS::Iterator THIS::Inject(
const Iterator& pos,
const T& rElem) {
1974 if(!mDetached) Detach();
1976 return ThisIterator(pSet->insert(dst,rElem));
1981 TEMP void THIS::Inject(
const T& rElem) {
1982 if(!mDetached) Detach();
1983 pSet->insert(pSet->end(),rElem);
1988 FD_DC(
"TBaseSet(" <<
this <<
")::InsertSet(" << &rOtherSet <<
")");
1989 if(!mDetached) Detach();
1998 while ((it1 != pSet->end()) && (it2 != rOtherSet.
pSet->end())) {
2002 else if (*it1 == *it2) {
2011 while (it2 != rOtherSet.
pSet->end()) {
2019 TEMP bool THIS::Erase(
const T& rElem) {
2020 if(!mDetached) Detach();
2021 return (pSet->erase(rElem)!=0);
2027 #ifdef FAUDES_CHECKED
2029 std::stringstream errstr;
2030 errstr <<
"iterator out of range " << std::endl;
2031 throw Exception(
"BaseSet::Erase", errstr.str(), 62);
2037 return ThisIterator(del);
2043 FD_DC(
"TBaseSet(" <<
this <<
")::EraseSet(" << &rOtherSet <<
")");
2044 if(!mDetached) Detach();
2048 while ((it != pSet->end()) && (oit != rOtherSet.
pSet->end())) {
2050 it=pSet->lower_bound(*oit);
2052 else if (*it == *oit) {
2057 oit=rOtherSet.
pSet->lower_bound(*it);
2065 FD_DC(
"TBaseSet(" <<
this <<
")::RestrictSet(" << &rOtherSet <<
")");
2066 if(!mDetached) Detach();
2070 while ((it != pSet->end()) && (oit != rOtherSet.
pSet->end())) {
2074 else if (*it == *oit) {
2079 oit=rOtherSet.
pSet->lower_bound(*it);
2082 while(it != pSet->end()) {
2090 FD_DC(
"TBaseSet(" <<
this <<
")::Disjoint(" << &rOtherSet <<
")");
2092 if(pSet->empty())
return true;
2093 if(rOtherSet.
pSet->empty())
return true;
2094 if(*pSet->rbegin()<*rOtherSet.
pSet->begin())
return true;
2095 if(*rOtherSet.
pSet->rbegin()<*pSet->begin())
return true;
2096 if(rOtherSet.
pSet==pSet)
return false;
2100 while ((it != pSet->end()) && (oit != rOtherSet.
pSet->end())) {
2101 if (*it < *oit) { it++;
continue;}
2102 if (*it == *oit) {
return false; }
2110 TEMP typename THIS::Iterator THIS::Find(
const T& rElem)
const {
2111 return ThisIterator(pSet->find(rElem));
2115 TEMP bool THIS::Exists(
const T& rElem)
const {
2116 return pSet->find(rElem) != pSet->end();
2145 FD_DC(
"TBaseSet::DoEqual()");
2147 if(pSet == rOtherSet.
pSet)
return true;
2149 return ( *pSet == *rOtherSet.
pSet );
2154 FD_DC(
"BaseSet::op<=()");
2155 return ( std::includes(rOtherSet.
pSet->begin(), rOtherSet.
pSet->end(), pSet->begin(), pSet->end()) ) ;
2160 FD_DC(
"BaseSet::op>=()");
2161 return ( std::includes(pSet->begin(), pSet->end(), rOtherSet.
pSet->begin(), rOtherSet.
pSet->end()) );
2166 return *pSet < *rOtherSet.
pSet;
2177 TEMP bool THIS::AttributeTest(
const Type& rAttr)
const {
2178 return AttributeType()->Cast(&rAttr)!=NULL;
2183 return (
Idx) pAttributes->size();
2187 TEMP void THIS::ClearAttributes(
void) {
2189 if(this->pAttributes->size()==0)
return;
2191 this->Detach(SetOnly);
2197 FD_DC(
"TBaseSet::EqualAttributes(TBaseSet)");
2199 FD_DC(
"TBaseSet::EqualAttributes(TBaseSet): 1");
2200 if(
typeid(*rOtherSet.
AttributeType())!=
typeid(*this->AttributeType()))
2203 FD_DC(
"TBaseSet::EqualAttributes(TBaseSet): 2");
2207 FD_DC(
"TBaseSet::EqualAttributes(TBaseSet): 3");
2209 if(this->AttributesSize()==0)
2214 while ((ait1 != pAttributes->end()) && (ait2 != rOtherSet.
pAttributes->end())) {
2215 if (ait1->first < ait2->first) {
2218 else if (ait1->first == ait2->first) {
2219 FD_DC(
"TBaseSet::EqualAttributes(TBaseSet): cmp " << ait1->second->ToString()
2220 <<
" vs " << ait2->second->ToString());
2221 if( ! ait1->second->Equal(*ait2->second))
return false;
2230 FD_DC(
"TBaseSet::EqualAttributes(TBaseSet): pass");
2239 this->DoAssign(rSourceSet);
2241 this->Detach(SetOnly);
2247 FD_DC(
"TBaseSet::Attributes("<<
this<<
")");
2250 std::stringstream errstr;
2251 errstr <<
"cannot cast attribute " << std::endl;
2252 throw Exception(
"TBaseSet::Attributes(otherset)", errstr.str(), 63);
2255 if(
typeid(*this->AttributeType())==
typeid(
const AttributeVoid))
return;
2257 this->Detach(AttrIncl);
2260 while ((it1 != pSet->end()) && (it2 != rOtherSet.
pSet->end())) {
2264 else if (*it1 == *it2) {
2265 DoAttribute(*it1,&rOtherSet.
Attribute(*it2));
2273 FD_DC(
"TBaseSet::Attributes(): copy ok");
2281 std::stringstream errstr;
2282 errstr <<
"cannot get attribute for TBaseSet \"" << mMyName <<
"\" type " <<
typeid(*this).name();
2283 throw Exception(
"TBaseSet::Attributep(rElem)", errstr.str(), 63);
2297 TEMP void THIS::Attribute(
const T& rElem,
const Type& rAttr) {
2300 #ifdef FAUDES_CHECKED
2301 if (!Exists(rElem)) {
2302 std::stringstream errstr;
2303 errstr <<
"element not member of set" << std::endl;
2304 throw Exception(
"TBaseSet::Attribute(elem,attr)", errstr.str(), 60);
2307 if(!AttributeTest(rAttr)) {
2308 std::stringstream errstr;
2309 errstr <<
"cannot cast attribute " << std::endl;
2310 throw Exception(
"TBaseSet::Attribute(elem,attr)", errstr.str(), 63);
2317 TEMP void THIS::ClrAttribute(
const T& rElem) {
2326 ait=this->pAttributes->find(rElem);
2327 if(ait==this->pAttributes->end())
return NULL;
2333 FD_DC(
"TBaseSet::DoAttributeExplicit(elem)");
2334 #ifdef FAUDES_DEBUG_CODE
2335 if(this->pAttributes!=this->::mpAttributes) {
2336 FD_ERR(
"TBaseSet::DoAttributeExplicit(elem): attributes not detached");
2341 ait=this->pAttributes->find(rElem);
2342 if(ait!=this->pAttributes->end())
2346 FD_DC(
"TBaseSet::DoAttributeExplicit(Elem): inserting explicit default " << attr <<
" type " <<
typeid(*attr).name());
2347 (*this->pAttributes)[rElem]=attr;
2352 TEMP void THIS::DoAttribute(
const T& rElem,
const Type* pAttr) {
2353 FD_DC(
"TBaseSet::DoAttribute([v] " << this->Str(rElem) <<
", ...)");
2354 #ifdef FAUDES_DEBUG_CODE
2355 if(this->pAttributes!=this->mpAttributes) {
2356 FD_ERR(
"TBaseSet::DoAttribute([v] set): attributes not detached");
2362 if(!this->AttributeType()->Cast(pAttr)) newattr=NULL;
2366 ait=this->pAttributes->find(rElem);
2367 if(ait!=this->pAttributes->end() )
2368 oldattr=ait->second;
2371 FD_DC(
"TBaseSet::DoAttribute([v] " << this->Str(rElem) <<
", ...): default 1");
2372 if(oldattr==NULL)
return;
2374 this->pAttributes->erase(ait);
2379 FD_DC(
"TBaseSet::DoAttribute([v] " << this->Str(rElem) <<
", ...): default 2");
2380 if(oldattr==NULL)
return;
2382 this->pAttributes->erase(ait);
2385 FD_DC(
"TBaseSet::DoAttribute([v] " << this->Str(rElem) <<
", ...): " << newattr->
ToString());
2390 (*this->pAttributes)[rElem]=attr;
2394 FD_DC(
"TBaseSet::DoAttribute([v] " << this->Str(rElem) <<
", ...): " << newattr->
ToString());
2395 oldattr->
Assign(*newattr);
Classes AttributeVoid and AttributeFlags
#define FD_DC(message)
Debug: optional report on container operations.
#define FD_WARN(message)
Debug: always report warnings.
#define FD_ERR(message)
Debug: report more errors with file/line info.
#define FAUDES_OBJCOUNT_DEC(type)
#define FAUDES_OBJCOUNT_INC(type)
Debug: count objects, report on exit.
Runtime interface, registry for faudes-types and functions.
Runtime interface, faudes types.
#define FAUDES_TYPE_TIMPLEMENTATION_CAST(ftype, ctype, cbase, ctemp)
#define FAUDES_TYPE_TIMPLEMENTATION_EQUAL(ftype, ctype, cbase, ctemp)
#define FAUDES_TYPE_TDECLARATION(ftype, ctype, cbase)
faudes type declaration macro, template version
#define FAUDES_TYPE_TIMPLEMENTATION_ASSIGN(ftype, ctype, cbase, ctemp)
#define FAUDES_TYPE_TIMPLEMENTATION_COPY(ftype, ctype, cbase, ctemp)
#define FAUDES_TYPE_TIMPLEMENTATION_NEW(ftype, ctype, cbase, ctemp)
faudes type implementation macros, template version
virtual bool IsDefault(void) const
Test for default value.
const std::string & Name(void) const
Get name of the entety to document (aka faudes-type or faudes-function).
Attribute interface for TBaseSet.
Iterator class for high-level api to TBaseSet.
void DValid(void) const
Check validity (provoke abort error)
Iterator(const TBaseSet< T, Cmp > *pBaseSet, const typename std::set< T, Cmp >::const_iterator &sit, bool att=false)
Construct by members (used by TBaseSet to create temporary iterators)
void StlIterator(const typename std::set< T, Cmp >::const_iterator &sit)
Assign STL iterator only.
bool mAttached
Indicate that this iterator is attached to some baseset.
~Iterator(void)
Destructor.
Iterator(const Iterator &fit)
Copy constructor, copies container reference, incl attach.
const TBaseSet< T, Cmp > * pBaseSet
Order by reference for containers of Iterators <.
void Invalidate(void)
Invalidate.
const std::set< T, Cmp >::const_iterator & StlIterator(void) const
Get STL iterator only.
std::string DStr(void) const
report (debugging)
Iterator()
Default constructor, container unknown.
std::list< TBaseSet< T, Cmp > * > * mpClients
BaseSets, that use data hosted by us (NULL if we dont host data, emptyset if we host to ourself excl....
std::string mXElementTag
Current/cached name of elements (used protected accessor method)
std::map< T, AttributeVoid * > * mpAttributes
Attribute map, if this object hosts data (else NULL).
bool mDetached
Indicate "hosts data to myself only".
std::list< TBaseSet< T, Cmp > * >::iterator mClientRecord
Iterator to the client list that hosts our data (maintained by host)
std::string mMyName
Name of this BaseSet.
std::set< Iterator * > mIterators
Iterators that refer to this TBaseSet.
std::set< T, Cmp >::iterator iterator
STL iterator, non-const version.
std::set< T, Cmp > * mpSet
STL set, if this object hosts data (else NULL)
std::string mFaudesTypeName
Current/cached faudes type-name.
const TypeDefinition * pTypeDefinition
static empty STL client list
virtual void AttributeTry(const T &rElem, const Type &rAttr)
Attribute access.
std::map< T, AttributeVoid * > * pAttributes
Pointer to attribute map to operate on.
std::map< T, AttributeVoid * >::const_iterator const_aiterator
STL attribute iterator, const version.
std::set< T, Cmp >::const_iterator const_iterator
STL iterator, const version.
std::map< T, AttributeVoid * >::iterator aiterator
STL attribute iterator, non-const version.
bool mLocked
Indicate "dont re-allocate the STL set ever again".
std::set< T, Cmp > * pSet
Pointer on STL set to operate on.
TBaseSet< T, Cmp > * pHostSet
Pointer on BaseSet that hosts our data (THIS if we host)
DetachMode
Detach from extern storage (incl allocation and true copy)
A TokenReader reads sequential tokens from a file or string.
void ReadEnd(const std::string &rLabel)
Close the current section by matching the previous ReadBegin().
void ReadBegin(const std::string &rLabel)
Open a section by specified label.
A TokenWriter writes sequential tokens to a file, a string or stdout.
void WriteComment(const std::string &rComment)
Write comment in faudes format.
void WriteEnd(const std::string &rLabel)
Write end label.
void WriteBegin(const std::string &rLabel)
Write begin label.
A TypeDefinition defines a faudes-type in that it specifies a faudes-type name to identify the type a...
const std::string & XElementTag(void) const
Parameter access: Xml Element Tag.
static TypeRegistry * G()
Method to access the single global instance of the registry.
const TypeDefinition * Definitionp(const std::string &rTypeName) const
Look up the type definition by faudes-type name.
Base class of all libFAUDES objects that participate in the run-time interface.
void Read(const std::string &rFileName, const std::string &rLabel="", const Type *pContext=0)
Read configuration data from file with label specified.
std::string ToString(const std::string &rLabel="", const Type *pContext=0) const
Write configuration data to a string.
virtual Type & Assign(const Type &rSrc)
Assign configuration data from other object.
virtual Type * New(void) const
Construct on heap.
virtual Type * Copy(void) const
Construct on heap.
virtual bool Insert(const T &rElem)
Insert specified element.
bool DoEqual(const TBaseSet &rOtherSet) const
test equality
virtual const AttributeVoid * AttributeType(void) const
Attribute typeinfo.
virtual const std::string & XElementTag(void) const
Get name of elements (used for XML IO)
void DoAttribute(const T &rElem, const Type *pAttr)
set attribute in map (assume elem exists in set, NULL <=> set to default)
void Lock(void) const
Detach and lock any further reallocation.
virtual TBaseSet & AssignWithoutAttributes(const TBaseSet &rSourceSet)
Attribute access.
void DoAssign(const TBaseSet &rSourceSet)
assign my members
void Detach(DetachMode flag=AttrIncl) const
bool SetInclusion(const TBaseSet< T, Cmp > &rSetA, const TBaseSet< T, Cmp > &rSetB)
virtual void DoWrite(TokenWriter &rTw, const std::string &rLabel="", const Type *pContext=0) const
Token output, see Type::DWrite for public wrappers.
void AttachClient(TBaseSet *pRef) const
Record that we provide contents to some other BaseSet.
bool SetEquality(const TBaseSet< T, Cmp > &rSetA, const TBaseSet< T, Cmp > &rSetB)
virtual void TypeName(const std::string &rType)
Overwrite faudes-type name.
bool Empty(void) const
Test whether if the TBaseSet is Empty.
void DetachClient(TBaseSet *pRef) const
Record that we stop providing data for some TBaseSet.
void SetDifference(const TBaseSet< T, Cmp > &rSetA, const TBaseSet< T, Cmp > &rSetB, TBaseSet< T, Cmp > &rRes)
bool Exists(const T &rElem) const
Test existence of element.
virtual void Attributes(const TBaseSet &rOtherSet)
Attributes access.
virtual void Attribute(const T &rElem, const Type &rAttr)
Attribute access.
virtual bool Disjoint(const TBaseSet &rOtherSet) const
Test for this set to be disjoint witg other set.
void Name(const std::string &rName)
Set name of TBaseSet.
virtual void Clear(void)
Clear all set.
const AttributeVoid * DoAttribute(const T &rElem) const
get attribute from map (return null if elem does not exist in map)
void DetachIterator(Iterator *pFit) const
Record that an iterator stops to refer to this TBaseSet.
TBaseSet< T, Cmp >::Iterator ThisIterator(const typename std::set< T, Cmp >::const_iterator &sit) const
Convert STL iterator to API iterator.
Iterator Find(const T &rElem) const
Find element and return iterator.
virtual bool Valid(const T &rElem) const
Test validty of candidate element.
virtual Iterator Inject(const Iterator &pos, const T &rElem)
Insert specified element.
virtual void DoDWrite(TokenWriter &rTw, const std::string &rLabel="", const Type *pContext=0) const
Token output, debugging see Type::DWrite for public wrappers.
virtual void XElementTag(const std::string &rTag)
Configure the element name tag.
Idx AttributesSize(void) const
Attribute access.
static std::set< T, Cmp > msEmptySet
static empty STL set for default constructor
virtual bool AttributeTest(const Type &rAttr) const
Attribute typeinfo.
TBaseSet(const std::string &rFilename, const std::string &rLabel="BaseSet")
Constructor from file.
virtual const TypeDefinition * TypeDefinitionp(void) const
Reimplment from type to use chache.
Iterator End(void) const
Iterator to the end of set.
virtual ~TBaseSet(void)
Virtual destructor.
virtual void RestrictSet(const TBaseSet &rOtherSet)
Restrict elements given by other set.
virtual void InsertSet(const TBaseSet &rOtherSet)
Insert elements given by rOtherSet.
virtual AttributeVoid * Attributep(const T &rElem)
Attribute access.
bool EqualAttributes(const TBaseSet &rOtherSet) const
Attribute access.
Iterator Begin(void) const
Iterator to the begin of set.
virtual const std::string & TypeName(void) const
Get objects's type name.
virtual const AttributeVoid & Attribute(const T &rElem) const
Attribute access.
void RelinkClients(void)
Ensure that we do not host contents to anyone else.
void DValid(const std::string &rMessage="") const
Some validation of deferred copy mechanism (provoke abort)
AttributeVoid * DoAttributeExplicit(const T &rElem)
get attribute from map (insert explicit default if elem does not exist in map)
virtual bool Erase(const T &rElem)
Erase element by reference.
const std::string & Name(void) const
Return name of TBaseSet.
void SetUnion(const TBaseSet< T, Cmp > &rSetA, const TBaseSet< T, Cmp > &rSetB, TBaseSet< T, Cmp > &rRes)
void SetIntersection(const TBaseSet< T, Cmp > &rSetA, const TBaseSet< T, Cmp > &rSetB, TBaseSet< T, Cmp > &rRes)
virtual void EraseSet(const TBaseSet &rOtherSet)
Erase elements given by other set.
TBaseSet(const TBaseSet &rOtherSet)
Copy-constructor.
Idx Size(void) const
Get Size of TBaseSet.
virtual void Inject(const T &rElem)
Insert specified element.
TBaseSet(void)
Constructor.
void ClearAttributes(void)
Attribute access.
virtual std::string Str(const T &rElem) const
Return pretty printable element.
virtual Iterator Erase(const Iterator &pos)
Erase element by iterator.
void AttachIterator(Iterator *pFit) const
Record that an iterator refers to this TBaseSet.
virtual void ClrAttribute(const T &rElem)
Attribute access.
static std::map< T, AttributeVoid * > msEmptyAttributes
static empty STL map for default constructor
virtual void DoRead(TokenReader &rTr, const std::string &rLabel="", const Type *pContext=0)
Token input, see Type::Read for public wrappers.
virtual void DoSWrite(TokenWriter &rTw) const
Token output, see Type::SWrite for public wrappers.
const std::string & FaudesTypeName(const Type &rObject)
Query type name.
libFAUDES resides within the namespace faudes.
uint32_t Idx
Type definition for index type (allways 32bit)
std::string CollapsString(const std::string &rString, unsigned int len)
Limit length of string, return head and tail of string.
std::string ToStringInteger(Int number)
integer to string