33 #define HURRICANE_COMMONS_H
69 template<
typename DboType>
72 inline void operator() ( DboType* dbo ) { dbo->destroy(); }
76 template<
typename DboType>
77 class dbo_ptr :
public std::shared_ptr<DboType> {
79 dbo_ptr ( DboType* dbo ) : std::shared_ptr<DboType>(dbo,DboDestroy<DboType>()) { }
90 inline string _TName (
const string& s ) {
return s; }
91 inline string _PName (
const string& s ) {
return "Hurricane::" + s; }
94 inline Type abs (
const Type& value ) {
return (value<0) ? -value : value; }
97 inline string demangle (
string symbol ) {
return demangle(symbol.c_str()); }
100 template<
typename Element>
101 inline void erase_element ( vector<Element*>& v,
const Element* e )
103 for (
auto ielement = v.begin() ; ielement != v.end() ; ++ielement )
104 if (*ielement == e) { v.erase( ielement );
return; }
112 inline int floatCompare (
float a,
float b )
114 assert (
sizeof(
float) ==
sizeof(
int) );
116 if ( a == b )
return 0;
117 return *(
int*)&a - *(
int*)&b;
120 inline int floatDifference (
float a,
float b,
int threshold )
122 int difference = floatCompare(a,b);
123 if ( abs(difference) < threshold )
return 0;
125 return (difference<0) ? -1 : 1;
129 inline void floatRound (
float& value,
float precision )
131 float rounded = roundf ( value*precision );
132 value = rounded / precision;
136 inline float roundfp (
float value,
float precision=100.0 ) {
return roundf(value*precision)/precision; }
139 template<
typename Type>
inline void order ( Type& a, Type& b ) {
if (a>b) std::swap(a,b); }
141 template<
typename Type>
inline Type setInBound ( Type lower, Type upper, Type& value )
143 if (value < lower) value = lower;
144 else if (value > upper) value = upper;
152 #include "hurricane/Record.h"
164 template<
typename Data>
inline Hurricane::Slot* getSlot ( std::string name, Data );
172 template<
typename Data>
inline std::string getString ( Data data )
173 {
return std::string(
"<type ")
175 + std::string(
" unsupported by getString()>"); }
179 template<>
inline std::string getString<const bool&> (
const bool& b )
180 {
return (b)?
"True":
"False" ; }
182 template<>
inline std::string getString<const int&> (
const int& i )
183 { std::ostringstream os (
""); os << i;
return os.str(); }
185 template<>
inline std::string getString<const long&> (
const long& l )
186 { std::ostringstream os (
""); os << l;
return os.str(); }
188 template<>
inline std::string getString<const unsigned int&> (
const unsigned int& u )
189 { std::ostringstream os (
""); os << u;
return os.str(); }
191 template<>
inline std::string getString<const unsigned long&> (
const unsigned long& ul )
192 { std::ostringstream os (
""); os << ul;
return os.str(); }
194 template<>
inline std::string getString<const unsigned long long&> (
const unsigned long long& ull )
195 { std::ostringstream os (
""); os << ull;
return os.str(); }
197 template<>
inline std::string getString<const unsigned short int&> (
const unsigned short int& us )
198 { std::ostringstream os (
""); os << us;
return os.str(); }
200 template<>
inline std::string getString<const float&> (
const float& f )
201 { std::ostringstream os (
""); os << f;
return os.str(); }
203 template<>
inline std::string getString<const double&> (
const double& d )
204 { std::ostringstream os; os << d;
return os.str(); }
206 template<>
inline std::string getString<const std::string&> (
const std::string& s )
211 template<>
inline std::string getString<const bool*> (
const bool* b )
212 {
return (*b)?
"True":
"False" ; }
214 template<>
inline std::string getString<const char*> (
const char* c )
217 template<>
inline std::string getString<const int*> (
const int* i )
218 { std::ostringstream os (
""); os << *i;
return os.str(); }
220 template<>
inline std::string getString<const long*> (
const long* l )
221 { std::ostringstream os (
""); os << *l;
return os.str(); }
223 template<>
inline std::string getString<const unsigned int*> (
const unsigned int* u )
224 { std::ostringstream os (
""); os << *u;
return os.str(); }
226 template<>
inline std::string getString<const unsigned long*> (
const unsigned long* ul )
227 { std::ostringstream os (
""); os << *ul;
return os.str(); }
229 template<>
inline std::string getString<const unsigned long long*> (
const unsigned long long* ull )
230 { std::ostringstream os (
""); os << *ull;
return os.str(); }
232 template<>
inline std::string getString<const unsigned short int*> (
const unsigned short int* us )
233 { std::ostringstream os (
""); os << *us;
return os.str(); }
235 template<>
inline std::string getString<const float*> (
const float* f )
236 { std::ostringstream os (
""); os << *f;
return os.str(); }
238 template<>
inline std::string getString<const double*> (
const double* d )
239 { std::ostringstream os; os << *d;
return os.str(); }
241 template<>
inline std::string getString<const void*> (
const void* p )
242 { std::ostringstream os (
"0x"); os << std::hex << p;
return os.str(); }
244 template<>
inline std::string getString<const std::string*> (
const std::string* s )
250 template<>
inline std::string getString<bool*> (
bool* b )
251 {
return (*b)?
"True":
"False" ; }
253 template<>
inline std::string getString<char*> (
char* c )
256 template<>
inline std::string getString<int*> (
int* i )
257 { std::ostringstream os (
""); os << *i;
return os.str(); }
259 template<>
inline std::string getString<long*> (
long* l )
260 { std::ostringstream os (
""); os << *l;
return os.str(); }
262 template<>
inline std::string getString<unsigned int*> (
unsigned int* u )
263 { std::ostringstream os (
""); os << *u;
return os.str(); }
265 template<>
inline std::string getString<unsigned long*> (
unsigned long* ul )
266 { std::ostringstream os (
""); os << *ul;
return os.str(); }
268 template<>
inline std::string getString<unsigned long long*> (
unsigned long long* ull )
269 { std::ostringstream os (
""); os << *ull;
return os.str(); }
271 template<>
inline std::string getString<unsigned short int*> (
unsigned short int* us )
272 { std::ostringstream os (
""); os << *us;
return os.str(); }
274 template<>
inline std::string getString<float*> (
float* f )
275 { std::ostringstream os (
""); os << *f;
return os.str(); }
277 template<>
inline std::string getString<double*> (
double* d )
278 { std::ostringstream os; os << *d;
return os.str(); }
280 template<>
inline std::string getString<void*> (
void* p )
281 { std::ostringstream os (
"0x"); os << std::hex << p;
return os.str(); }
283 template<>
inline std::string getString<std::string*> ( std::string* s )
289 template<>
inline std::string getString<bool> (
bool b )
290 {
return (b)?
"True":
"False" ; }
292 template<>
inline std::string getString<char> (
char c )
293 {
return std::string(1,c); }
295 template<>
inline std::string getString<int> (
int i )
296 { std::ostringstream os (
""); os << i;
return os.str(); }
298 template<>
inline std::string getString<long> (
long l )
299 { std::ostringstream os (
""); os << l;
return os.str(); }
301 template<>
inline std::string getString<unsigned int> (
unsigned int u )
302 { std::ostringstream os (
""); os << u;
return os.str(); }
304 template<>
inline std::string getString<unsigned long> (
unsigned long ul )
305 { std::ostringstream os (
""); os << ul;
return os.str(); }
307 template<>
inline std::string getString<unsigned long long> (
unsigned long long ull )
308 { std::ostringstream os (
""); os << ull;
return os.str(); }
310 template<>
inline std::string getString<unsigned short int> (
unsigned short int us )
311 { std::ostringstream os (
""); os << us;
return os.str(); }
313 template<>
inline std::string getString<float> (
float f )
314 { std::ostringstream os (
""); os << f;
return os.str(); }
316 template<>
inline std::string getString<double> (
double d )
317 { std::ostringstream os; os << d;
return os.str(); }
319 template<>
inline std::string getString<std::string> ( std::string s )
323 template<
typename Data>
inline Hurricane::Record* getRecord ( Data data )
333 template<
typename T,
typename U>
334 inline std::string getString (
const std::pair<T,U>& p )
336 return "const std::pair<T,U>";
340 template<
typename T,
typename U>
341 inline Hurricane::Record* getRecord (
const std::pair<T,U>& p )
343 Hurricane::Record* record = NULL;
344 record =
new Hurricane::Record (
"const std::pair<T,U>" );
345 record->add( getSlot<const T>(std::string(
"first" ), &p.first ) );
346 record->add( getSlot<const U>(std::string(
"second"), &p.second) );
351 template<
typename T,
typename U>
352 inline std::string getString ( std::pair<T,U>& p )
354 return "std::pair<T,U>";
358 template<
typename T,
typename U>
359 inline Hurricane::Record* getRecord ( std::pair<T,U>& p )
361 Hurricane::Record* record = NULL;
362 record =
new Hurricane::Record (
"std::pair<T,U>" );
363 record->add( getSlot<T>(std::string(
"first" ), &p.first ) );
364 record->add( getSlot<U>(std::string(
"second"), &p.second) );
373 template<
typename Element,
size_t N>
374 inline std::string getString ( std::array<Element,N>* v )
376 std::string name =
"const std::array<Element,N>:";
377 return name + getString<size_t>(v->size());
381 template<
typename Element,
size_t N>
382 inline Hurricane::Record* getRecord ( std::array<Element,N>* v )
384 Hurricane::Record* record = NULL;
386 record =
new Hurricane::Record (
"std::array<Element,N>" );
388 typename std::array<Element,N>::iterator iterator = v->begin();
389 while ( iterator != v->end() ) {
390 record->add ( getSlot<Element>(getString(n++), *iterator) );
398 template<
typename Element,
size_t N>
399 inline std::string getString (
const std::array<Element,N>* v )
401 std::string name =
"const std::array<Element,N>:";
402 return name + getString<size_t>(v->size());
406 template<
typename Element,
size_t N>
407 inline Hurricane::Record* getRecord (
const std::array<Element,N>* v )
409 Hurricane::Record* record = NULL;
411 record =
new Hurricane::Record (
"const std::array<Element,N>" );
413 typename std::array<Element,N>::const_iterator iterator = v->begin();
414 while ( iterator != v->end() ) {
415 record->add ( getSlot<const Element>(getString(n++), *iterator) );
423 template<
typename Element,
size_t N>
424 inline std::string getString ( std::array<Element,N>& v )
426 std::string name =
"std::array<Element,N>&:";
427 return name + getString<size_t>(v.size());
431 template<
typename Element,
size_t N>
432 inline Hurricane::Record* getRecord ( std::array<Element,N>& v )
434 Hurricane::Record* record = NULL;
436 record =
new Hurricane::Record (
"std::array<Element,N>&" );
438 for (
auto element : v )
439 record->add( getSlot<Element>(getString(n++), element) );
445 template<
typename Element,
size_t N>
446 inline std::string getString (
const std::array<Element,N>& v )
448 std::string name =
"const std::array<Element,N>&:";
449 return name + getString<size_t>(v.size());
453 template<
typename Element,
size_t N>
454 inline Hurricane::Record* getRecord (
const std::array<Element,N>& v )
456 Hurricane::Record* record = NULL;
458 record =
new Hurricane::Record (
"const std::array<Element,N>&" );
460 for (
auto element : v )
461 record->add( getSlot<Element>(getString(n++), element) );
471 template<
typename Element>
472 inline std::string getString ( std::vector<Element>* v )
474 std::string name =
"std::vector<Element>*:";
475 return name + getString<size_t>(v->size());
479 template<
typename Element>
480 inline Hurricane::Record* getRecord ( std::vector<Element>* v )
482 Hurricane::Record* record = NULL;
484 record =
new Hurricane::Record (
"std::vector<Element>*" );
486 typename std::vector<Element>::iterator iterator = v->begin();
487 while ( iterator != v->end() ) {
488 record->add ( getSlot<const Element*>(getString(n++), &(*iterator)) );
500 template<
typename Element>
501 inline std::string getString ( std::vector<Element*>* v )
503 std::string name =
"std::vector<Element*>*:";
504 return name + getString<size_t>(v->size());
508 template<
typename Element>
509 inline Hurricane::Record* getRecord ( std::vector<Element*>* v )
511 Hurricane::Record* record = NULL;
513 record =
new Hurricane::Record (
"std::vector<Element*>*" );
515 typename std::vector<Element*>::iterator iterator = v->begin();
516 while ( iterator != v->end() ) {
517 record->add ( getSlot<Element*>(getString(n++), *iterator) );
529 template<
typename Element>
530 inline std::string getString (
const std::vector<Element>* v )
532 std::string name =
"const std::vector<Element>*:";
533 return name + getString<size_t>(v->size());
537 template<
typename Element>
538 inline Hurricane::Record* getRecord (
const std::vector<Element>* v )
540 Hurricane::Record* record = NULL;
542 record =
new Hurricane::Record (
"const std::vector<Element>*" );
544 typename std::vector<Element>::const_iterator iterator = v->begin();
545 while ( iterator != v->end() ) {
546 record->add ( getSlot<const Element*>(getString(n++), &(*iterator)) );
558 template<
typename Element>
559 inline std::string getString (
const std::vector<Element*>* v )
561 std::string name =
"const std::vector<Element*>*:";
562 return name + getString<size_t>(v->size());
566 template<
typename Element>
567 inline Hurricane::Record* getRecord (
const std::vector<Element*>* v )
569 Hurricane::Record* record = NULL;
570 if (not v->empty()) {
571 record =
new Hurricane::Record (
"const std::vector<Element*>*" );
573 typename std::vector<Element*>::const_iterator iterator = v->begin();
574 while (iterator != v->end()) {
575 record->add ( getSlot<const Element*>(getString(n++), *iterator) );
587 template<
typename Element>
588 inline std::string getString (
const std::list<Element>* l )
590 std::string name =
"const std::list<Element>*:";
591 return name + getString<size_t>(l->size());
595 template<
typename Element>
596 inline Hurricane::Record* getRecord (
const std::list<Element>* l )
598 Hurricane::Record* record = NULL;
600 record =
new Hurricane::Record (
"const std::list<Element>" );
602 typename std::list<Element>::const_iterator iterator = l->begin();
603 while ( iterator != l->end() ) {
604 record->add ( getSlot<const Element*>(getString(n++), &(*iterator)) );
612 template<
typename Element>
613 inline std::string getString ( std::list<Element>* l )
615 std::string name =
"std::list<Element>*:";
616 return name + getString<size_t>(l->size());
620 template<
typename Element>
621 inline Hurricane::Record* getRecord ( std::list<Element>* l )
623 Hurricane::Record* record = NULL;
625 record =
new Hurricane::Record (
"std::list<Element>" );
627 typename std::list<Element>::iterator iterator = l->begin();
628 while ( iterator != l->end() ) {
629 record->add ( getSlot<const Element*>(getString(n++), &(*iterator)) );
641 template<
typename Key,
typename Element>
642 inline std::string getString ( std::map<Key,Element>* m )
644 std::string name =
"std::map<Element>:";
645 return name + getString<size_t>(m->size());
649 template<
typename Key,
typename Element>
650 inline Hurricane::Record* getRecord ( std::map<Key,Element>* m )
652 Hurricane::Record* record = NULL;
654 record =
new Hurricane::Record (
"std::map<Element>" );
655 typename std::map<Key,Element>::iterator iterator = m->begin();
656 while ( iterator != m->end() ) {
657 record->add ( getSlot<Element>(getString(iterator->first), iterator->second) );
665 template<
typename Key,
typename Element>
666 inline std::string getString (
const std::map<Key,Element>* m )
668 std::string name =
"const std::map<Element>:";
669 return name + getString<size_t>(m->size());
673 template<
typename Key,
typename Element>
674 inline Hurricane::Record* getRecord (
const std::map<Key,Element>* m )
676 Hurricane::Record* record = NULL;
678 record =
new Hurricane::Record (
"const std::map<Element>" );
679 typename std::map<Key,Element>::const_iterator iterator = m->begin();
680 while ( iterator != m->end() ) {
681 record->add ( getSlot<const Element>(getString(iterator->first), iterator->second) );
693 template<
typename Key,
typename Element,
typename Compare>
694 inline std::string getString ( std::map<Key,Element,Compare>* m )
696 std::string name =
"std::map<Element>:";
697 return name + getString<size_t>(m->size());
701 template<
typename Key,
typename Element,
typename Compare>
702 inline Hurricane::Record* getRecord ( std::map<Key,Element,Compare>* m )
704 Hurricane::Record* record = NULL;
706 record =
new Hurricane::Record (
"std::map<Element>" );
707 typename std::map<Key,Element,Compare>::iterator iterator = m->begin();
708 while ( iterator != m->end() ) {
709 record->add ( getSlot<Element>(getString(iterator->first), iterator->second) );
717 template<
typename Key,
typename Element,
typename Compare>
718 inline std::string getString (
const std::map<Key,Element,Compare>* m )
720 std::string name =
"const std::map<Element>:";
721 return name + getString<size_t>(m->size());
725 template<
typename Key,
typename Element,
typename Compare>
726 inline Hurricane::Record* getRecord (
const std::map<Key,Element,Compare>* m )
728 Hurricane::Record* record = NULL;
730 record =
new Hurricane::Record (
"const std::map<Element>" );
731 typename std::map<Key,Element,Compare>::const_iterator iterator = m->begin();
732 while ( iterator != m->end() ) {
733 record->add ( getSlot<const Element>(getString(iterator->first), iterator->second) );
745 template<
typename Key,
typename Element,
typename Compare>
746 inline std::string getString (
const std::multimap<Key,Element,Compare>* m )
748 std::string name =
"const std::multimap<Element>:";
749 return name + getString<size_t>(m->size());
753 template<
typename Key,
typename Element,
typename Compare>
754 inline Hurricane::Record* getRecord (
const std::multimap<Key,Element,Compare>* m )
756 Hurricane::Record* record = NULL;
758 record =
new Hurricane::Record (
"const std::multimap<Element>" );
759 typename std::multimap<Key,Element,Compare>::const_iterator iterator = m->begin();
760 while ( iterator != m->end() ) {
761 record->add ( getSlot<const Element>(getString(iterator->first), iterator->second) );
769 template<
typename Key,
typename Element,
typename Compare>
770 inline std::string getString ( std::multimap<Key,Element,Compare>* m )
772 std::string name =
"std::multimap<Element>:";
773 return name + getString<size_t>(m->size());
777 template<
typename Key,
typename Element,
typename Compare>
778 inline Hurricane::Record* getRecord ( std::multimap<Key,Element,Compare>* m )
780 Hurricane::Record* record = NULL;
782 record =
new Hurricane::Record (
"std::multimap<Element>" );
783 typename std::multimap<Key,Element,Compare>::iterator iterator = m->begin();
784 while ( iterator != m->end() ) {
785 record->add ( getSlot<Element>(getString(iterator->first), iterator->second) );
797 template<
typename Element,
typename Compare>
798 inline std::string getString (
const std::set<Element,Compare>* s )
800 std::string name =
"const std::set<Element>:";
801 return name + getString<size_t>(s->size());
805 template<
typename Element,
typename Compare>
806 inline Hurricane::Record* getRecord (
const std::set<Element,Compare>* s )
808 Hurricane::Record* record = NULL;
810 record =
new Hurricane::Record (
"const std::set<Element>" );
812 typename std::set<Element,Compare>::const_iterator iterator = s->begin();
813 while ( iterator != s->end() ) {
814 record->add ( getSlot<const Element>(getString(n++), *iterator) );
822 template<
typename Element,
typename Compare,
typename Allocator >
823 inline std::string getString ( std::set<Element,Compare,Allocator>* s )
825 std::string name =
"std::set<Element>:";
826 return name + getString<size_t>(s->size());
830 template<
typename Element,
typename Compare,
typename Allocator >
831 inline Hurricane::Record* getRecord ( std::set<Element,Compare,Allocator>* s )
833 Hurricane::Record* record = NULL;
834 if (not s->empty()) {
835 record =
new Hurricane::Record (
"std::set<Element>" );
837 typename std::set<Element,Compare,Allocator>::iterator iterator = s->begin();
838 while ( iterator != s->end() ) {
839 record->add( getSlot<Element>(getString(n++), *iterator) );
850 template<
typename Element,
typename Compare>
851 inline std::string getString (
const std::set<Element,Compare>& s )
853 std::string name =
"const std::set<Element>:";
854 return name + getString<size_t>(s.size());
858 template<
typename Element,
typename Compare>
859 inline Hurricane::Record* getRecord (
const std::set<Element,Compare>& s )
861 Hurricane::Record* record = NULL;
863 record =
new Hurricane::Record (
"const std::set<Element>" );
865 typename std::set<Element,Compare>::const_iterator iterator = s.begin();
866 while ( iterator != s.end() ) {
867 record->add ( getSlot<Element>(getString(n++), *iterator) );
878 template<
typename Element,
typename Compare>
879 inline std::string getString (
const std::multiset<Element,Compare>* s )
881 std::string name =
"std::multiset<Element>:";
882 return name + getString<size_t>(s->size());
886 template<
typename Element,
typename Compare>
887 inline Hurricane::Record* getRecord (
const std::multiset<Element,Compare>* s )
889 Hurricane::Record* record = NULL;
891 record =
new Hurricane::Record (
"std::multiset<Element>" );
893 typename std::multiset<Element,Compare>::const_iterator iterator = s->begin();
894 while ( iterator != s->end() ) {
895 record->add ( getSlot<Element>(getString(n++), *iterator) );
903 # define GETSTRING_POINTER_SUPPORT(Data) \
904 template<> inline std::string getString<Data*>( Data* data ) \
906 if (!data) return "NULL [" #Data "]"; \
907 return data->_getString(); \
910 template<> inline std::string getString<const Data*>( const Data* data ) \
911 { if (!data) return "NULL [const " #Data "]"; return data->_getString(); }
914 # define IOSTREAM_POINTER_SUPPORT(Data) \
915 inline std::ostream& operator<< ( std::ostream& o, Data* d ) \
917 if (!d) return o << "NULL [" #Data "]"; \
918 return o << "&" << getString<const Data*>(d); \
920 inline std::ostream& operator<< ( std::ostream& o, const Data* d ) \
922 if (!d) return o << "NULL [const " #Data "]"; \
923 return o << "&" << getString<const Data*>(d); \
927 # define GETRECORD_POINTER_SUPPORT(Data) \
928 template<> inline Hurricane::Record* getRecord<Data*>( Data* data ) \
929 { if (!data) return NULL; return data->_getRecord(); } \
931 template<> inline Hurricane::Record* getRecord<const Data*>( const Data* data ) \
932 { if (!data) return NULL; return data->_getRecord(); }
935 # define GETSTRING_REFERENCE_SUPPORT(Data) \
936 template<> inline std::string getString<Data&>( Data& data ) \
937 { return data._getString(); } \
939 template<> inline std::string getString<const Data&>( const Data& data ) \
940 { return data._getString(); }
943 # define IOSTREAM_REFERENCE_SUPPORT(Data) \
944 inline std::ostream& operator<< ( std::ostream& o, Data& d ) \
945 { return o << getString<Data&>(d); } \
947 inline std::ostream& operator<< ( std::ostream& o, const Data& d ) \
948 { return o << getString<const Data&>(d); } \
951 # define GETRECORD_REFERENCE_SUPPORT(Data) \
952 template<> inline Hurricane::Record* getRecord<Data&>( Data& data ) \
953 { return data._getRecord(); } \
955 template<> inline Hurricane::Record* getRecord<const Data&>( const Data& data ) \
956 { return data._getRecord(); }
959 # define GETSTRING_VALUE_SUPPORT(Data) \
960 template<> inline std::string getString<Data>( Data data ) \
961 { return data._getString(); }
964 # define IOSTREAM_VALUE_SUPPORT(Data) \
965 inline std::ostream& operator<< ( std::ostream& o, Data d ) \
966 { return o << getString<Data>(d); }
969 # define GETRECORD_VALUE_SUPPORT(Data) \
970 template<> inline Hurricane::Record* getRecord<Data>( Data data ) \
971 { return data._getRecord(); }
974 # define INSPECTOR_P_SUPPORT(Data) \
975 GETRECORD_POINTER_SUPPORT(Data) \
976 GETSTRING_POINTER_SUPPORT(Data) \
977 IOSTREAM_POINTER_SUPPORT(Data)
980 # define INSPECTOR_R_SUPPORT(Data) \
981 GETRECORD_REFERENCE_SUPPORT(Data) \
982 GETSTRING_REFERENCE_SUPPORT(Data) \
983 IOSTREAM_REFERENCE_SUPPORT(Data)
986 # define INSPECTOR_PR_SUPPORT(Data) \
987 GETSTRING_POINTER_SUPPORT(Data) \
988 GETSTRING_REFERENCE_SUPPORT(Data) \
989 GETSTRING_VALUE_SUPPORT(Data) \
990 IOSTREAM_POINTER_SUPPORT(Data) \
991 IOSTREAM_REFERENCE_SUPPORT(Data) \
992 GETRECORD_POINTER_SUPPORT(Data) \
993 GETRECORD_REFERENCE_SUPPORT(Data)
996 # define INSPECTOR_PV_SUPPORT(Data) \
997 GETSTRING_POINTER_SUPPORT(Data) \
998 GETSTRING_VALUE_SUPPORT(Data) \
999 IOSTREAM_POINTER_SUPPORT(Data) \
1000 IOSTREAM_VALUE_SUPPORT(Data) \
1001 GETRECORD_POINTER_SUPPORT(Data) \
1002 GETRECORD_VALUE_SUPPORT(Data)
1005 #include "hurricane/Tabulation.h"
1015 inline int getMinLevel ()
const;
1016 inline int getMaxLevel ()
const;
1017 inline int setMinLevel (
int );
1018 inline int setMaxLevel (
int );
1019 inline int getLevel ()
const;
1020 inline int setLevel (
int );
1021 inline bool enabled ()
const;
1022 inline bool enabled (
int )
const;
1023 inline tstream& log (
int level,
int count=0 );
1024 inline tstream& tabw (
int level,
int count );
1025 inline tstream ( std::ostream & );
1026 inline tstream& put (
char c );
1030 inline tstream& _tabw (
int count );
1033 inline tstream& operator<< ( std::ostream& (*pf)(std::ostream &) );
1042 inline tstream::tstream ( std::ostream& s )
1043 : std::ostream(s.rdbuf())
1044 , _minLevel (100000)
1056 inline bool tstream::enabled ()
const {
return (_level >= _minLevel) and (_level < _maxLevel); }
1059 inline tstream& tstream::put (
char c ) {
if (
enabled())
static_cast<std::ostream*
>(
this)->put(c);
return *
this; }
1060 inline tstream& tstream::flush () {
if (
enabled())
static_cast<std::ostream*
>(
this)->flush();
return *
this; }
1061 inline tstream& tstream::operator<< ( std::ostream& (*pf)(std::ostream&) ) {
if (
enabled()) (*pf)(*this);
return *
this; }
1064 inline tstream& tstream::_tab () {
if (
enabled()) (*this) << _tabulation;
return *
this; }
1065 inline tstream& tstream::_tabw (
int count )
1068 if (count > 0)
while(count--) _tabulation++;
1069 else if (count < 0)
while(count++) _tabulation--;
1075 {
setLevel(level); _tab();
return _tabw(count); }
1079 {
if (o.
enabled()) {
static_cast<std::ostream&
>(o) << s; }
return o; };
1086 template<
typename T>
1088 {
if (o.
enabled()) {
static_cast<std::ostream&
>(o) << getString<T*>(t); }
return o; };
1094 template<
typename T>
1096 {
if (o.
enabled()) {
static_cast<std::ostream&
>(o) << getString<T>(t); }
return o; };
1098 template<
typename T>
1100 {
if (o.
enabled()) {
static_cast<std::ostream&
>(o) << getString<const T*>(t); }
return o; };
1103 inline tstream& operator<< (
tstream& o, std::ios_base& (*pf)(std::ios_base&) )
1104 {
if (o.
enabled()) {
static_cast<std::ostream&
>(o) << pf; }
return o; };
1106 struct _Tsetw {
int n_; };
1107 inline _Tsetw tsetw (
int n ) {
return { n }; }
1109 struct _Tsetf {
int n_; };
1110 inline _Tsetf tsetf (
int n ) {
return { n }; }
1114 {
if (o.
enabled()) {
static_cast<std::ostream&
>(o) << std::setw(manip.n_); }
return o; }
1119 #define cdebug_log(level,indent) if (cdebug.enabled(level)) cdebug.log(level,indent)
1120 #define cdebug_tabw(level,indent) cdebug.tabw(level,indent)
1127 #include "hurricane/Slot.h"
1128 #include "hurricane/Initializer.h"
1129 #include "hurricane/JsonWriter.h"
1130 #include "hurricane/JsonObject.h"
Tabulation description (API)
Definition: Tabulation.h:35
Trace & indentation enabled stream.
Definition: Commons.h:1013
bool enabled() const
Definition: Commons.h:1056
int getLevel() const
Definition: Commons.h:1054
int setMinLevel(int)
Definition: Commons.h:1052
tstream & log(int level, int count=0)
Definition: Commons.h:1074
int setLevel(int)
Definition: Commons.h:1055
tstream & tabw(int level, int count)
Definition: Commons.h:1058
int setMaxLevel(int)
Definition: Commons.h:1053
int getMinLevel() const
Definition: Commons.h:1050
int getMaxLevel() const
Definition: Commons.h:1051
The namespace dedicated to Hurricane.
Definition: Generalities.dox:5
string demangle(const char *symbol)