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 __SYSTEMC_EXT_DT_INT_SC_LENGTH_PARAM_HH__
58#define __SYSTEMC_EXT_DT_INT_SC_LENGTH_PARAM_HH__
59
60#include <iostream>
61
62#include "../fx/sc_context.hh"
63#include "../fx/sc_fxdefs.hh"
64
65namespace sc_dt
66{
67
68// classes defined in this module
69class sc_length_param;
70
71// friend operator declarations
72bool operator == (const sc_length_param &, const sc_length_param &);
73bool operator != (const sc_length_param &, const sc_length_param &);
74
75
76// ----------------------------------------------------------------------------
77//  CLASS : sc_length_param
78//
79//  Length parameter type.
80// ----------------------------------------------------------------------------
81
82class sc_length_param
83{
84  public:
85    sc_length_param();
86    sc_length_param(int);
87    sc_length_param(const sc_length_param &);
88    explicit sc_length_param(sc_without_context);
89
90    sc_length_param &operator = (const sc_length_param &);
91
92    friend bool operator == (const sc_length_param &, const sc_length_param &);
93    friend bool operator != (const sc_length_param &, const sc_length_param &);
94
95    int len() const;
96    void len(int);
97
98    const std::string to_string() const;
99
100    void print(::std::ostream & =::std::cout) const;
101    void dump(::std::ostream & =::std::cout) const;
102
103  private:
104    int m_len;
105};
106
107} // namespace sc_dt
108
109// ----------------------------------------------------------------------------
110//  TYPEDEF : sc_length_context
111//
112//  Context type for the length parameter type.
113// ----------------------------------------------------------------------------
114
115namespace sc_dt
116{
117
118extern template class sc_global<sc_length_param>;
119extern template class sc_context<sc_length_param>;
120
121typedef sc_context<sc_length_param> sc_length_context;
122
123
124// IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII
125
126inline sc_length_param::sc_length_param() : m_len()
127{
128    *this = sc_length_context::default_value();
129}
130
131inline sc_length_param::sc_length_param(int len_) : m_len(len_)
132{
133    SC_CHECK_WL_(len_);
134}
135
136inline sc_length_param::sc_length_param(const sc_length_param &a) :
137        m_len(a.m_len)
138{}
139
140inline sc_length_param::sc_length_param(sc_without_context) :
141        m_len(SC_DEFAULT_WL_)
142{}
143
144
145inline sc_length_param &
146sc_length_param::operator = (const sc_length_param &a)
147{
148    if (&a != this) {
149        m_len = a.m_len;
150    }
151    return *this;
152}
153
154
155inline bool
156operator == (const sc_length_param &a, const sc_length_param &b)
157{
158    return (a.m_len == b.m_len);
159}
160
161inline bool
162operator != (const sc_length_param &a, const sc_length_param &b)
163{
164    return (a.m_len != b.m_len);
165}
166
167
168inline int
169sc_length_param::len() const
170{
171    return m_len;
172}
173
174inline void
175sc_length_param::len(int len_)
176{
177    SC_CHECK_WL_(len_);
178    m_len = len_;
179}
180
181
182inline ::std::ostream &
183operator << (::std::ostream &os, const sc_length_param &a)
184{
185    a.print(os);
186    return os;
187}
188
189} // namespace sc_dt
190
191
192#endif // __SYSTEMC_EXT_DT_INT_SC_LENGTH_PARAM_HH__
193