00001 /***************************************************************************** 00002 00003 The following code is derived, directly or indirectly, from the SystemC 00004 source code Copyright (c) 1996-2006 by all Contributors. 00005 All Rights reserved. 00006 00007 The contents of this file are subject to the restrictions and limitations 00008 set forth in the SystemC Open Source License Version 2.4 (the "License"); 00009 You may not use this file except in compliance with such restrictions and 00010 limitations. You may obtain instructions on how to receive a copy of the 00011 License at http://www.systemc.org/. Software distributed by Contributors 00012 under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF 00013 ANY KIND, either express or implied. See the License for the specific 00014 language governing rights and limitations under the License. 00015 00016 *****************************************************************************/ 00017 00018 /***************************************************************************** 00019 00020 sc_length_param.h - 00021 00022 Original Author: Martin Janssen, Synopsys, Inc., 2002-03-19 00023 00024 *****************************************************************************/ 00025 00026 /***************************************************************************** 00027 00028 MODIFICATION LOG - modifiers, enter your name, affiliation, date and 00029 changes you are making here. 00030 00031 Name, Affiliation, Date: 00032 Description of Modification: 00033 00034 *****************************************************************************/ 00035 00036 // $Log: sc_length_param.h,v $ 00037 // Revision 1.1.1.1 2006/12/15 20:31:36 acg 00038 // SystemC 2.2 00039 // 00040 // Revision 1.3 2006/01/13 18:49:32 acg 00041 // Added $Log command so that CVS check in comments are reproduced in the 00042 // source. 00043 // 00044 00045 #ifndef SC_LENGTH_PARAM_H 00046 #define SC_LENGTH_PARAM_H 00047 00048 00049 #include "sysc/datatypes/fx/sc_context.h" 00050 00051 00052 namespace sc_dt 00053 { 00054 00055 // classes defined in this module 00056 class sc_length_param; 00057 00058 // friend operator declarations 00059 bool operator == ( const sc_length_param&, 00060 const sc_length_param& ); 00061 bool operator != ( const sc_length_param&, 00062 const sc_length_param& ); 00063 00064 00065 // ---------------------------------------------------------------------------- 00066 // CLASS : sc_length_param 00067 // 00068 // Length parameter type. 00069 // ---------------------------------------------------------------------------- 00070 00071 class sc_length_param 00072 { 00073 public: 00074 00075 sc_length_param(); 00076 sc_length_param( int ); 00077 sc_length_param( const sc_length_param& ); 00078 explicit sc_length_param( sc_without_context ); 00079 00080 sc_length_param& operator = ( const sc_length_param& ); 00081 00082 friend bool operator == ( const sc_length_param&, 00083 const sc_length_param& ); 00084 friend bool operator != ( const sc_length_param&, 00085 const sc_length_param& ); 00086 00087 int len() const; 00088 void len( int ); 00089 00090 const std::string to_string() const; 00091 00092 void print( ::std::ostream& = ::std::cout ) const; 00093 void dump( ::std::ostream& = ::std::cout ) const; 00094 00095 private: 00096 00097 int m_len; 00098 }; 00099 00100 00101 // ---------------------------------------------------------------------------- 00102 // TYPEDEF : sc_length_context 00103 // 00104 // Context type for the length parameter type. 00105 // ---------------------------------------------------------------------------- 00106 00107 typedef sc_context<sc_length_param> sc_length_context; 00108 00109 00110 // IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII 00111 00112 inline 00113 sc_length_param::sc_length_param() 00114 { 00115 *this = sc_length_context::default_value(); 00116 } 00117 00118 inline 00119 sc_length_param::sc_length_param( int len_ ) 00120 { 00121 SC_CHECK_WL_( len_ ); 00122 m_len = len_; 00123 } 00124 00125 inline 00126 sc_length_param::sc_length_param( const sc_length_param& a ) 00127 : m_len( a.m_len ) 00128 {} 00129 00130 inline 00131 sc_length_param::sc_length_param( sc_without_context ) 00132 : m_len( SC_DEFAULT_WL_ ) 00133 {} 00134 00135 00136 inline 00137 sc_length_param& 00138 sc_length_param::operator = ( const sc_length_param& a ) 00139 { 00140 if( &a != this ) 00141 { 00142 m_len = a.m_len; 00143 } 00144 return *this; 00145 } 00146 00147 00148 inline 00149 bool 00150 operator == ( const sc_length_param& a, const sc_length_param& b ) 00151 { 00152 return ( a.m_len == b.m_len ); 00153 } 00154 00155 inline 00156 bool 00157 operator != ( const sc_length_param& a, const sc_length_param& b ) 00158 { 00159 return ( a.m_len != b.m_len ); 00160 } 00161 00162 00163 inline 00164 int 00165 sc_length_param::len() const 00166 { 00167 return m_len; 00168 } 00169 00170 inline 00171 void 00172 sc_length_param::len( int len_ ) 00173 { 00174 SC_CHECK_WL_( len_ ); 00175 m_len = len_; 00176 } 00177 00178 00179 inline 00180 ::std::ostream& 00181 operator << ( ::std::ostream& os, const sc_length_param& a ) 00182 { 00183 a.print( os ); 00184 return os; 00185 } 00186 00187 } // namespace sc_dt 00188 00189 00190 #endif 00191 00192 // Taf!