Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members  

_scv_data_structure.h

Go to the documentation of this file.
00001 //  -*- C++ -*- <this line is for emacs to recognize it as C++ code>
00002 /*****************************************************************************
00003 
00004   The following code is derived, directly or indirectly, from the SystemC
00005   source code Copyright (c) 1996-2002 by all Contributors.
00006   All Rights reserved.
00007 
00008   The contents of this file are subject to the restrictions and limitations
00009   set forth in the SystemC Open Source License Version 2.3 (the "License");
00010   You may not use this file except in compliance with such restrictions and
00011   limitations. You may obtain instructions on how to receive a copy of the
00012   License at http://www.systemc.org/. Software distributed by Contributors
00013   under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF
00014   ANY KIND, either express or implied. See the License for the specific
00015   language governing rights and limitations under the License.
00016 
00017  *****************************************************************************/
00018 
00019 /*****************************************************************************
00020 
00021   _scv_data_structure.h -- 
00022   The base class of any data structure, specifying the interface
00023   common to them.
00024 
00025   Original Authors (Cadence Design Systems, Inc):
00026   Norris Ip, Dean Shea, John Rose, Jasvinder Singh, William Paulsen,
00027   John Pierce, Rachida Kebichi, Ted Elkind, David Bailey
00028   2002-09-23
00029 
00030  *****************************************************************************/
00031 
00032 /*****************************************************************************
00033 
00034   MODIFICATION LOG - modifiers, enter your name, affiliation, date and
00035   changes you are making here.
00036 
00037       Name, Affiliation, Date:
00038   Description of Modification:
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   // virtual destructor
00105   //
00106   virtual ~_scv_data_structure() {};
00107 
00108   //
00109   // return the instance name of the data structure 
00110   //
00111   const char *get_name() const { return _name.c_str(); }
00112 
00113   virtual const char *kind() const { return _kind; }
00114 
00115   // 
00116   // print current values on output stream or on current screen
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 //protected:
00134   //
00135   // constructor (all data structures have optional name)
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

Generated on Fri Jan 14 08:28:55 2005 for SystemC2.1beta11(excludingMSLib)(IncludingSCV)\nProvidedby:www.openverificationfoundation.org by doxygen1.2.18