00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042 #ifndef SCV_DATA_STRUCTURE_H
00043 #define SCV_DATA_STRUCTURE_H
00044
00045 #include "scv/scv_config.h"
00046
00047 #include <string>
00048
00049 #include "scv/scv_object_if.h"
00050 #include "scv/scv_util.h"
00051 #include "scv/scv_debug.h"
00052
00053 template<class T>
00054 struct _scv_CstructMethods {
00055 _scv_CstructMethods() {
00056 #if !defined(_USE_PADDING_ON_STRUCTS)
00057 memset(this,0,sizeof(T));
00058 #else
00059 memset(this+4,0,sizeof(T)-4);
00060 #endif
00061 }
00062 friend bool operator==(const _scv_CstructMethods<T>& a,
00063 const _scv_CstructMethods<T>& b) {
00064 #if !defined(_USE_PADDING_ON_STRUCTS)
00065 return 0==memcmp(&a,&b,sizeof(T));
00066 #else
00067 return 0==memcmp(&a+4,&b+4,sizeof(T)-4);
00068 #endif
00069 }
00070 friend bool operator<(const _scv_CstructMethods<T>& a,
00071 const _scv_CstructMethods<T>& b) {
00072 #if !defined(_USE_PADDING_ON_STRUCTS)
00073 return memcmp(&a,&b,sizeof(T))<0;
00074 #else
00075 return memcmp(&a+4,&b+4,sizeof(T)-4)<0;
00076 #endif
00077 }
00078 friend ostream& operator<<(ostream& os, const _scv_CstructMethods<T>&) {
00079 os << "< C-struct >";
00080 return os;
00081 }
00082 friend bool operator!=(const _scv_CstructMethods<T>& a,
00083 const _scv_CstructMethods<T>& b) {
00084 return !(a==b);
00085 }
00086 friend bool operator>(const _scv_CstructMethods<T>& a,
00087 const _scv_CstructMethods<T>& b) {
00088 return b<a;
00089 }
00090 friend bool operator<=(const _scv_CstructMethods<T>& a,
00091 const _scv_CstructMethods<T>& b) {
00092 return a<b || a==b;
00093 }
00094 friend bool operator>=(const _scv_CstructMethods<T>& a,
00095 const _scv_CstructMethods<T>& b) {
00096 return a>b || a==b;
00097 }
00098 };
00099
00100 class _scv_data_structure : public scv_object_if {
00101 public:
00102
00103
00104
00105
00106 virtual ~_scv_data_structure() {};
00107
00108
00109
00110
00111 const char *get_name() const { return _name.c_str(); }
00112
00113 virtual const char *kind() const { return _kind; }
00114
00115
00116
00117
00118 virtual void print(ostream& o, int details, int indent) const {};
00119
00120 virtual void show(int details=0, int indent=0) const {
00121 print(scv_out, details, indent);
00122 }
00123
00124 const char *nameP() const { return _name.c_str(); }
00125
00126 static int get_debug() {return _debug;}
00127
00128 static void set_debug(int debug) {
00129 scv_debug::set_facility_level(scv_debug::DATA_STRUCTURES, debug);
00130 _debug = debug;
00131 }
00132
00133
00134
00135
00136
00137 _scv_data_structure(const char *name = "<anonymous>") : _name(name) {};
00138 string _name;
00139 static int _debug;
00140 static const char *_kind;
00141
00142 static void set_class_debug(int debug) { _debug = debug; }
00143 };
00144
00145 #endif // SCV_DATA_STRUCTURE_H