Hurricane VLSI Database


Interval.h
1 // -*- C++ -*-
2 //
3 // Copyright (c) BULL S.A. 2000-2023, All Rights Reserved
4 //
5 // This file is part of Hurricane.
6 //
7 // Hurricane is free software: you can redistribute it and/or modify
8 // it under the terms of the GNU Lesser General Public License as
9 // published by the Free Software Foundation, either version 3 of the
10 // License, or (at your option) any later version.
11 //
12 // Hurricane is distributed in the hope that it will be useful, but
13 // WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN-
14 // TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the Lesser GNU
15 // General Public License for more details.
16 //
17 // You should have received a copy of the Lesser GNU General Public
18 // License along with Hurricane. If not, see
19 // <http://www.gnu.org/licenses/>.
20 //
21 // +-----------------------------------------------------------------+
22 // | H U R R I C A N E |
23 // | V L S I B a c k e n d D a t a - B a s e |
24 // | |
25 // | Author : Rémy Escassut |
26 // | E-mail : Jean-Paul.Chaput@lip6.fr |
27 // | =============================================================== |
28 // | C++ Header : "./hurricane/Interval.h" |
29 // +-----------------------------------------------------------------+
30 
31 
32 #pragma once
33 #include "hurricane/DbU.h"
34 
35 namespace Hurricane {
36 
37 
38 // -------------------------------------------------------------------
39 // Class : "Hurricane::Interval".
40 
41 
42  class Interval {
43  public:
44  class CompareByMin {
45  public:
46  inline bool operator() ( const Interval& rhs, const Interval& lhs ) const;
47  inline bool operator() ( const Interval* rhs, const Interval* lhs ) const;
48  };
49  class CompareByMinMax {
50  public:
51  inline bool operator() ( const Interval& rhs, const Interval& lhs ) const;
52  inline bool operator() ( const Interval* rhs, const Interval* lhs ) const;
53  };
54  public:
55  Interval ( bool makeEmpty=true );
56  Interval ( const DbU::Unit& );
57  Interval ( const DbU::Unit& v1, const DbU::Unit& v2 );
58  Interval ( const Interval& );
59  public:
61  bool operator== ( const Interval& ) const;
62  bool operator!= ( const Interval& ) const;
63  public:
64  inline const DbU::Unit& getVMin () const;
65  inline const DbU::Unit& getVMax () const;
66  inline DbU::Unit& getVMin ();
67  inline DbU::Unit& getVMax ();
68  inline DbU::Unit getCenter () const;
69  inline DbU::Unit getSize () const;
70  inline DbU::Unit getHalfSize () const;
71  Interval getUnion ( const Interval& ) const;
72  Interval getIntersection ( const Interval& ) const;
73  inline bool isEmpty () const;
74  inline bool isFull () const;
75  inline bool isPonctual () const;
76  bool contains ( const DbU::Unit& ) const;
77  bool contains ( const Interval& ) const;
78  bool intersect ( const Interval& , bool strict=false ) const;
79  bool inferior ( const Interval& , bool strict=true ) const;
80  bool superior ( const Interval& , bool strict=true ) const;
81  bool isConstrainedBy ( const Interval& ) const;
82  public:
84  Interval& shrinkVMin ( const DbU::Unit& vMin );
85  Interval& shrinkVMax ( const DbU::Unit& vMax );
86  Interval& inflate ( const DbU::Unit& dv );
87  Interval& inflate ( const DbU::Unit& dvMin, const DbU::Unit& dvMax );
88  Interval& merge ( const DbU::Unit& );
89  Interval& merge ( const Interval& );
90  Interval& intersection ( const DbU::Unit& vMin, const DbU::Unit& vMax );
93  public:
94  inline string _getTypeName () const;
95  string _getString () const;
96  Record* _getRecord () const;
97  private:
98  DbU::Unit _vMin;
99  DbU::Unit _vMax;
100  };
101 
102 
103  inline const DbU::Unit& Interval::getVMin () const {return _vMin;};
104  inline const DbU::Unit& Interval::getVMax () const {return _vMax;};
105  inline DbU::Unit& Interval::getVMin () {return _vMin;};
106  inline DbU::Unit& Interval::getVMax () {return _vMax;};
107  inline DbU::Unit Interval::getCenter () const {return ((_vMin + _vMax) / 2);};
108  inline DbU::Unit Interval::getHalfSize () const {return (getSize() / 2);};
109  inline bool Interval::isEmpty () const { return (_vMax < _vMin);};
110  inline bool Interval::isFull () const { return (_vMin == DbU::Min) and (_vMax == DbU::Max); };
111  inline bool Interval::isPonctual () const { return (_vMax == _vMin);};
112  inline string Interval::_getTypeName () const { return _TName("Interval"); };
113 
114  inline DbU::Unit Interval::getSize () const
115  {
116  if (isEmpty()) return 0;
117  if (isFull ()) return DbU::Max;
118  return _vMax - _vMin;
119  }
120 
121 
122  inline bool Interval::CompareByMin::operator() ( const Interval& lhs, const Interval& rhs ) const
123  { return lhs.getVMin() < rhs.getVMin(); }
124 
125 
126  inline bool Interval::CompareByMin::operator() ( const Interval* lhs, const Interval* rhs ) const
127  { return lhs->getVMin() < rhs->getVMin(); }
128 
129 
130  inline bool Interval::CompareByMinMax::operator() ( const Interval& lhs, const Interval& rhs ) const
131  {
132  if (lhs.getVMin() != rhs.getVMin()) return lhs.getVMin() < rhs.getVMin();
133  return lhs.getVMax() < rhs.getVMax();
134  }
135 
136 
137  inline bool Interval::CompareByMinMax::operator() ( const Interval* lhs, const Interval* rhs ) const
138  {
139  if (lhs->getVMin() != rhs->getVMin()) return lhs->getVMin() < rhs->getVMin();
140  return lhs->getVMax() < rhs->getVMax();
141  }
142 
143 
144 } // Hurricane namespace.
145 
146 
147 inline void jsonWrite ( JsonWriter* w, const std::string& key, const Hurricane::Interval* interval )
148 {
149  w->key( key );
150  w->startArray();
151  w->write( &interval->getVMin() );
152  w->write( &interval->getVMax() );
153  w->endArray();
154 }
155 
156 
157 INSPECTOR_PR_SUPPORT(Hurricane::Interval);
std::int64_t Unit
Definition: DbU.h:67
Interval description (API)
Definition: Interval.h:42
Interval(bool makeEmpty=true)
Interval & intersection(const DbU::Unit &vMin, const DbU::Unit &vMax)
Interval & inflate(const DbU::Unit &dv)
bool operator==(const Interval &) const
Interval & makeEmpty()
Interval(const Interval &)
bool operator!=(const Interval &) const
const DbU::Unit & getVMax() const
Definition: Interval.h:104
Interval & operator=(const Interval &)
Interval(const DbU::Unit &v1, const DbU::Unit &v2)
bool isEmpty() const
Definition: Interval.h:109
DbU::Unit getSize() const
Definition: Interval.h:114
DbU::Unit getCenter() const
Definition: Interval.h:107
const DbU::Unit & getVMin() const
Definition: Interval.h:103
Interval getIntersection(const Interval &) const
bool contains(const DbU::Unit &) const
Interval & merge(const Interval &)
Interval & merge(const DbU::Unit &)
DbU::Unit getHalfSize() const
Definition: Interval.h:108
Interval & inflate(const DbU::Unit &dvMin, const DbU::Unit &dvMax)
Interval getUnion(const Interval &) const
Interval(const DbU::Unit &)
Interval & translate(const DbU::Unit &)
bool isPonctual() const
Definition: Interval.h:111
Interval & intersection(const Interval &)
bool intersect(const Interval &, bool strict=false) const
bool contains(const Interval &) const
Contains Almost Everything.
Definition: BasicLayer.h:39


Generated by doxygen 1.9.1 on Wed Nov 20 2024 Return to top of page
Hurricane VLSI Database Copyright © 2000-2020 Bull S.A. All rights reserved