sc_length_param.h revision 12027:1eb7dc7aa10b
1/***************************************************************************** 2 3 Licensed to Accellera Systems Initiative Inc. (Accellera) under one or 4 more contributor license agreements. See the NOTICE file distributed 5 with this work for additional information regarding copyright ownership. 6 Accellera licenses this file to you under the Apache License, Version 2.0 7 (the "License"); you may not use this file except in compliance with the 8 License. You may obtain a copy of the License at 9 10 http://www.apache.org/licenses/LICENSE-2.0 11 12 Unless required by applicable law or agreed to in writing, software 13 distributed under the License is distributed on an "AS IS" BASIS, 14 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 15 implied. See the License for the specific language governing 16 permissions and limitations under the License. 17 18 *****************************************************************************/ 19 20/***************************************************************************** 21 22 sc_length_param.h - 23 24 Original Author: Martin Janssen, Synopsys, Inc., 2002-03-19 25 26 *****************************************************************************/ 27 28/***************************************************************************** 29 30 MODIFICATION LOG - modifiers, enter your name, affiliation, date and 31 changes you are making here. 32 33 Name, Affiliation, Date: 34 Description of Modification: 35 36 *****************************************************************************/ 37 38// $Log: sc_length_param.h,v $ 39// Revision 1.3 2011/08/24 22:05:46 acg 40// Torsten Maehne: initialization changes to remove warnings. 41// 42// Revision 1.2 2011/02/18 20:19:15 acg 43// Andy Goodrich: updating Copyright notice. 44// 45// Revision 1.1.1.1 2006/12/15 20:20:05 acg 46// SystemC 2.3 47// 48// Revision 1.4 2006/05/08 17:50:01 acg 49// Andy Goodrich: Added David Long's declarations for friend operators, 50// functions, and methods, to keep the Microsoft compiler happy. 51// 52// Revision 1.3 2006/01/13 18:49:32 acg 53// Added $Log command so that CVS check in comments are reproduced in the 54// source. 55// 56 57#ifndef SC_LENGTH_PARAM_H 58#define SC_LENGTH_PARAM_H 59 60 61#include "sysc/datatypes/fx/sc_context.h" 62 63 64namespace sc_dt 65{ 66 67// classes defined in this module 68class sc_length_param; 69 70// friend operator declarations 71 bool operator == ( const sc_length_param&, 72 const sc_length_param& ); 73 bool operator != ( const sc_length_param&, 74 const sc_length_param& ); 75 76 77// ---------------------------------------------------------------------------- 78// CLASS : sc_length_param 79// 80// Length parameter type. 81// ---------------------------------------------------------------------------- 82 83class sc_length_param 84{ 85public: 86 87 sc_length_param(); 88 sc_length_param( int ); 89 sc_length_param( const sc_length_param& ); 90 explicit sc_length_param( sc_without_context ); 91 92 sc_length_param& operator = ( const sc_length_param& ); 93 94 friend bool operator == ( const sc_length_param&, 95 const sc_length_param& ); 96 friend bool operator != ( const sc_length_param&, 97 const sc_length_param& ); 98 99 int len() const; 100 void len( int ); 101 102 const std::string to_string() const; 103 104 void print( ::std::ostream& = ::std::cout ) const; 105 void dump( ::std::ostream& = ::std::cout ) const; 106 107private: 108 109 int m_len; 110}; 111 112 113// ---------------------------------------------------------------------------- 114// TYPEDEF : sc_length_context 115// 116// Context type for the length parameter type. 117// ---------------------------------------------------------------------------- 118 119typedef sc_context<sc_length_param> sc_length_context; 120 121 122// IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII 123 124inline 125sc_length_param::sc_length_param() : m_len() 126{ 127 *this = sc_length_context::default_value(); 128} 129 130inline 131sc_length_param::sc_length_param( int len_ ) : m_len(len_) 132{ 133 SC_CHECK_WL_( len_ ); 134} 135 136inline 137sc_length_param::sc_length_param( const sc_length_param& a ) 138 : m_len( a.m_len ) 139{} 140 141inline 142sc_length_param::sc_length_param( sc_without_context ) 143 : m_len( SC_DEFAULT_WL_ ) 144{} 145 146 147inline 148sc_length_param& 149sc_length_param::operator = ( const sc_length_param& a ) 150{ 151 if( &a != this ) 152 { 153 m_len = a.m_len; 154 } 155 return *this; 156} 157 158 159inline 160bool 161operator == ( const sc_length_param& a, const sc_length_param& b ) 162{ 163 return ( a.m_len == b.m_len ); 164} 165 166inline 167bool 168operator != ( const sc_length_param& a, const sc_length_param& b ) 169{ 170 return ( a.m_len != b.m_len ); 171} 172 173 174inline 175int 176sc_length_param::len() const 177{ 178 return m_len; 179} 180 181inline 182void 183sc_length_param::len( int len_ ) 184{ 185 SC_CHECK_WL_( len_ ); 186 m_len = len_; 187} 188 189 190inline 191::std::ostream& 192operator << ( ::std::ostream& os, const sc_length_param& a ) 193{ 194 a.print( os ); 195 return os; 196} 197 198} // namespace sc_dt 199 200 201#endif 202 203// Taf! 204