# Hurricane VLSI Database

Interval.h
1 // -*- C++ -*-
2 //
3 // Copyright (c) BULL S.A. 2000-2018, 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 #ifndef HURRICANE_INTERVAL_H
33 #define HURRICANE_INTERVAL_H
34
35 #include "hurricane/DbU.h"
36
37 namespace Hurricane {
38
39
40 // -------------------------------------------------------------------
41 // Class : "Hurricane::Interval".
42
43
44 class Interval {
45 public:
46 class CompareByMin {
47 public:
48 inline bool operator() ( const Interval& rhs, const Interval& lhs ) const;
49 inline bool operator() ( const Interval* rhs, const Interval* lhs ) const;
50 };
51 public:
52 Interval ( bool makeEmpty=true );
53 Interval ( const DbU::Unit& );
54 Interval ( const DbU::Unit& v1, const DbU::Unit& v2 );
55 Interval ( const Interval& );
56 public:
57 Interval& operator= ( const Interval& );
58 bool operator== ( const Interval& ) const;
59 bool operator!= ( const Interval& ) const;
60 public:
61 inline const DbU::Unit& getVMin () const;
62 inline const DbU::Unit& getVMax () const;
63 inline DbU::Unit& getVMin ();
64 inline DbU::Unit& getVMax ();
65 inline DbU::Unit getCenter () const;
66 inline DbU::Unit getSize () const;
67 inline DbU::Unit getHalfSize () const;
68 Interval getUnion ( const Interval& ) const;
69 Interval getIntersection ( const Interval& ) const;
70 inline bool isEmpty () const;
71 inline bool isFull () const;
72 inline bool isPonctual () const;
73 bool contains ( const DbU::Unit& ) const;
74 bool contains ( const Interval& ) const;
75 bool intersect ( const Interval& , bool strict=false ) const;
76 bool inferior ( const Interval& , bool strict=true ) const;
77 bool superior ( const Interval& , bool strict=true ) const;
78 bool isConstrainedBy ( const Interval& ) const;
79 public:
80 Interval& makeEmpty ();
81 Interval& shrinkVMin ( const DbU::Unit& vMin );
82 Interval& shrinkVMax ( const DbU::Unit& vMax );
83 Interval& inflate ( const DbU::Unit& dv );
84 Interval& inflate ( const DbU::Unit& dvMin, const DbU::Unit& dvMax );
85 Interval& merge ( const DbU::Unit& );
86 Interval& merge ( const Interval& );
87 Interval& intersection ( const DbU::Unit& vMin, const DbU::Unit& vMax );
88 Interval& intersection ( const Interval& );
89 Interval& translate ( const DbU::Unit& );
90 public:
91 inline string _getTypeName () const;
92 string _getString () const;
93 Record* _getRecord () const;
94 private:
95 DbU::Unit _vMin;
96 DbU::Unit _vMax;
97 };
98
99
100 inline const DbU::Unit& Interval::getVMin () const {return _vMin;};
101 inline const DbU::Unit& Interval::getVMax () const {return _vMax;};
102 inline DbU::Unit& Interval::getVMin () {return _vMin;};
103 inline DbU::Unit& Interval::getVMax () {return _vMax;};
104 inline DbU::Unit Interval::getCenter () const {return ((_vMin + _vMax) / 2);};
105 inline DbU::Unit Interval::getHalfSize () const {return (getSize() / 2);};
106 inline bool Interval::isEmpty () const { return (_vMax < _vMin);};
107 inline bool Interval::isFull () const { return (_vMin == DbU::Min) and (_vMax == DbU::Max); };
108 inline bool Interval::isPonctual () const { return (_vMax == _vMin);};
109 inline string Interval::_getTypeName () const { return _TName("Interval"); };
110
111 inline DbU::Unit Interval::getSize () const
112 {
113 if (isEmpty()) return 0;
114 if (isFull ()) return DbU::Max;
115 return _vMax - _vMin;
116 }
117
118
119 inline bool Interval::CompareByMin::operator() ( const Interval& lhs, const Interval& rhs ) const
120 { return lhs.getVMin() < rhs.getVMin(); }
121
122
123 inline bool Interval::CompareByMin::operator() ( const Interval* lhs, const Interval* rhs ) const
124 { return lhs->getVMin() < rhs->getVMin(); }
125
126
127 } // Hurricane namespace.
128
129
130 inline void jsonWrite ( JsonWriter* w, const std::string& key, const Hurricane::Interval* interval )
131 {
132 w->key( key );
133 w->startArray();
134 w->write( &interval->getVMin() );
135 w->write( &interval->getVMax() );
136 w->endArray();
137 }
138
139 INSPECTOR_PR_SUPPORT(Hurricane::Interval);
140
141
142 #endif // HURRICANE_INTERVAL_H
Hurricane::Interval::getVMax
const DbU::Unit & getVMax() const
Definition: Interval.h:101
Hurricane::Interval::getIntersection
Interval getIntersection(const Interval &) const
Hurricane::Interval::getVMin
const DbU::Unit & getVMin() const
Definition: Interval.h:100
Hurricane::Interval::merge
Interval & merge(const DbU::Unit &)
Hurricane::Interval::isPonctual
bool isPonctual() const
Definition: Interval.h:108
Hurricane::DbU::Unit
std::int64_t Unit
Definition: DbU.h:70
Hurricane::Interval
Interval description (API)
Definition: Interval.h:44
Hurricane::Interval::makeEmpty
Interval & makeEmpty()
Hurricane::Interval::isEmpty
bool isEmpty() const
Definition: Interval.h:106
Hurricane::Interval::Interval
Interval(bool makeEmpty=true)
Hurricane::Interval::getSize
DbU::Unit getSize() const
Definition: Interval.h:111
Hurricane::Interval::operator!=
bool operator!=(const Interval &) const
Hurricane::Interval::getCenter
DbU::Unit getCenter() const
Definition: Interval.h:104
Hurricane::Interval::contains
bool contains(const DbU::Unit &) const
Hurricane::Interval::getUnion
Interval getUnion(const Interval &) const
Hurricane
The namespace dedicated to Hurricane.
Definition: Generalities.dox:5
Hurricane::Interval::getHalfSize
DbU::Unit getHalfSize() const
Definition: Interval.h:105
Hurricane::Interval::inflate
Interval & inflate(const DbU::Unit &dv)
Hurricane::Interval::operator=
Interval & operator=(const Interval &)
Hurricane::Interval::translate
Interval & translate(const DbU::Unit &)
Hurricane::Interval::intersect
bool intersect(const Interval &, bool strict=false) const
Hurricane::Interval::operator==
bool operator==(const Interval &) const
Hurricane::Interval::intersection
Interval & intersection(const DbU::Unit &vMin, const DbU::Unit &vMax)

Generated by doxygen 1.8.14 on Tue Jul 21 2020 | Return to top of page

Hurricane VLSI Database | Copyright © 2000-2016 Bull S.A. All rights reserved