1 /* Authors: Lutong Wang and Bangqi Xu */
2 /*
3  * Copyright (c) 2019, The Regents of the University of California
4  * All rights reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions are met:
8  *     * Redistributions of source code must retain the above copyright
9  *       notice, this list of conditions and the following disclaimer.
10  *     * Redistributions in binary form must reproduce the above copyright
11  *       notice, this list of conditions and the following disclaimer in the
12  *       documentation and/or other materials provided with the distribution.
13  *     * Neither the name of the University nor the
14  *       names of its contributors may be used to endorse or promote products
15  *       derived from this software without specific prior written permission.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20  * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS BE LIABLE FOR ANY DIRECT,
21  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
24  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
26  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27  */
28 
29 #ifndef _FR_GUIDE_H_
30 #define _FR_GUIDE_H_
31 
32 #include "db/obj/frFig.h"
33 #include "frBaseTypes.h"
34 
35 namespace fr {
36 class frNet;
37 class frGuide : public frConnFig
38 {
39  public:
frGuide()40   frGuide()
41       : frConnFig(),
42         begin_(),
43         end_(),
44         beginLayer_(0),
45         endLayer_(0),
46         routeObj_(),
47         net_(nullptr)
48   {
49   }
frGuide(const frGuide & in)50   frGuide(const frGuide& in)
51       : frConnFig(),
52         begin_(in.begin_),
53         end_(in.end_),
54         beginLayer_(in.beginLayer_),
55         endLayer_(in.endLayer_),
56         routeObj_(),
57         net_(nullptr)
58   {
59   }
60   // getters
getPoints(frPoint & beginIn,frPoint & endIn)61   void getPoints(frPoint& beginIn, frPoint& endIn) const
62   {
63     beginIn.set(begin_);
64     endIn.set(end_);
65   }
66 
getBeginPoint()67   const frPoint& getBeginPoint() const { return begin_; }
getEndPoint()68   const frPoint& getEndPoint() const { return end_; }
69 
getBeginLayerNum()70   frLayerNum getBeginLayerNum() const { return beginLayer_; }
getEndLayerNum()71   frLayerNum getEndLayerNum() const { return endLayer_; }
hasRoutes()72   bool hasRoutes() const { return routeObj_.empty() ? false : true; }
getRoutes()73   const std::vector<std::unique_ptr<frConnFig>>& getRoutes() const
74   {
75     return routeObj_;
76   }
77   // setters
setPoints(const frPoint & beginIn,const frPoint & endIn)78   void setPoints(const frPoint& beginIn, const frPoint& endIn)
79   {
80     begin_.set(beginIn);
81     end_.set(endIn);
82   }
setBeginLayerNum(frLayerNum numIn)83   void setBeginLayerNum(frLayerNum numIn) { beginLayer_ = numIn; }
setEndLayerNum(frLayerNum numIn)84   void setEndLayerNum(frLayerNum numIn) { endLayer_ = numIn; }
addRoute(std::unique_ptr<frConnFig> cfgIn)85   void addRoute(std::unique_ptr<frConnFig> cfgIn)
86   {
87     routeObj_.push_back(std::move(cfgIn));
88   }
setRoutes(std::vector<std::unique_ptr<frConnFig>> & routesIn)89   void setRoutes(std::vector<std::unique_ptr<frConnFig>>& routesIn)
90   {
91     routeObj_ = std::move(routesIn);
92   }
93   // others
typeId()94   frBlockObjectEnum typeId() const override { return frcGuide; }
95 
96   /* from frConnFig
97    * hasNet
98    * getNet
99    * addToNet
100    * removeFromNet
101    */
hasNet()102   bool hasNet() const override { return (net_); }
getNet()103   frNet* getNet() const override { return net_; }
addToNet(frNet * in)104   void addToNet(frNet* in) override { net_ = in; }
removeFromNet()105   void removeFromNet() override { net_ = nullptr; }
106 
107   /* from frFig
108    * getBBox
109    * move, in .cpp
110    * overlaps, incomplete
111    */
112   // needs to be updated
getBBox(frBox & boxIn)113   void getBBox(frBox& boxIn) const override { boxIn.set(begin_, end_); }
move(const frTransform & xform)114   void move(const frTransform& xform) override { ; }
overlaps(const frBox & box)115   bool overlaps(const frBox& box) const override { return false; }
116 
117  protected:
118   frPoint begin_;
119   frPoint end_;
120   frLayerNum beginLayer_;
121   frLayerNum endLayer_;
122   std::vector<std::unique_ptr<frConnFig>> routeObj_;
123   frNet* net_;
124 };
125 }  // namespace fr
126 
127 #endif
128