00001 /***************************************************************************** 00002 00003 The following code is derived, directly or indirectly, from the SystemC 00004 source code Copyright (c) 1996-2014 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 (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.accellera.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.3 2011/08/24 22:05:46 acg 00038 // Torsten Maehne: initialization changes to remove warnings. 00039 // 00040 // Revision 1.2 2011/02/18 20:19:15 acg 00041 // Andy Goodrich: updating Copyright notice. 00042 // 00043 // Revision 1.1.1.1 2006/12/15 20:20:05 acg 00044 // SystemC 2.3 00045 // 00046 // Revision 1.4 2006/05/08 17:50:01 acg 00047 // Andy Goodrich: Added David Long's declarations for friend operators, 00048 // functions, and methods, to keep the Microsoft compiler happy. 00049 // 00050 // Revision 1.3 2006/01/13 18:49:32 acg 00051 // Added $Log command so that CVS check in comments are reproduced in the 00052 // source. 00053 // 00054 00055 #ifndef SC_LENGTH_PARAM_H 00056 #define SC_LENGTH_PARAM_H 00057 00058 00059 #include "sysc/datatypes/fx/sc_context.h" 00060 00061 00062 namespace sc_dt 00063 { 00064 00065 // classes defined in this module 00066 class sc_length_param; 00067 00068 // friend operator declarations 00069 bool operator == ( const sc_length_param&, 00070 const sc_length_param& ); 00071 bool operator != ( const sc_length_param&, 00072 const sc_length_param& ); 00073 00074 00075 // ---------------------------------------------------------------------------- 00076 // CLASS : sc_length_param 00077 // 00078 // Length parameter type. 00079 // ---------------------------------------------------------------------------- 00080 00081 class sc_length_param 00082 { 00083 public: 00084 00085 sc_length_param(); 00086 sc_length_param( int ); 00087 sc_length_param( const sc_length_param& ); 00088 explicit sc_length_param( sc_without_context ); 00089 00090 sc_length_param& operator = ( const sc_length_param& ); 00091 00092 friend bool operator == ( const sc_length_param&, 00093 const sc_length_param& ); 00094 friend bool operator != ( const sc_length_param&, 00095 const sc_length_param& ); 00096 00097 int len() const; 00098 void len( int ); 00099 00100 const std::string to_string() const; 00101 00102 void print( ::std::ostream& = ::std::cout ) const; 00103 void dump( ::std::ostream& = ::std::cout ) const; 00104 00105 private: 00106 00107 int m_len; 00108 }; 00109 00110 00111 // ---------------------------------------------------------------------------- 00112 // TYPEDEF : sc_length_context 00113 // 00114 // Context type for the length parameter type. 00115 // ---------------------------------------------------------------------------- 00116 00117 typedef sc_context<sc_length_param> sc_length_context; 00118 00119 00120 // IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII 00121 00122 inline 00123 sc_length_param::sc_length_param() : m_len() 00124 { 00125 *this = sc_length_context::default_value(); 00126 } 00127 00128 inline 00129 sc_length_param::sc_length_param( int len_ ) : m_len(len_) 00130 { 00131 SC_CHECK_WL_( len_ ); 00132 } 00133 00134 inline 00135 sc_length_param::sc_length_param( const sc_length_param& a ) 00136 : m_len( a.m_len ) 00137 {} 00138 00139 inline 00140 sc_length_param::sc_length_param( sc_without_context ) 00141 : m_len( SC_DEFAULT_WL_ ) 00142 {} 00143 00144 00145 inline 00146 sc_length_param& 00147 sc_length_param::operator = ( const sc_length_param& a ) 00148 { 00149 if( &a != this ) 00150 { 00151 m_len = a.m_len; 00152 } 00153 return *this; 00154 } 00155 00156 00157 inline 00158 bool 00159 operator == ( const sc_length_param& a, const sc_length_param& b ) 00160 { 00161 return ( a.m_len == b.m_len ); 00162 } 00163 00164 inline 00165 bool 00166 operator != ( const sc_length_param& a, const sc_length_param& b ) 00167 { 00168 return ( a.m_len != b.m_len ); 00169 } 00170 00171 00172 inline 00173 int 00174 sc_length_param::len() const 00175 { 00176 return m_len; 00177 } 00178 00179 inline 00180 void 00181 sc_length_param::len( int len_ ) 00182 { 00183 SC_CHECK_WL_( len_ ); 00184 m_len = len_; 00185 } 00186 00187 00188 inline 00189 ::std::ostream& 00190 operator << ( ::std::ostream& os, const sc_length_param& a ) 00191 { 00192 a.print( os ); 00193 return os; 00194 } 00195 00196 } // namespace sc_dt 00197 00198 00199 #endif 00200 00201 // Taf!