1 ///////////////////////////////////////////////////////////////////////////////
2 // BSD 3-Clause License
3 //
4 // Copyright (c) 2019, Nefelus Inc
5 // All rights reserved.
6 //
7 // Redistribution and use in source and binary forms, with or without
8 // modification, are permitted provided that the following conditions are met:
9 //
10 // * Redistributions of source code must retain the above copyright notice, this
11 //   list of conditions and the following disclaimer.
12 //
13 // * Redistributions in binary form must reproduce the above copyright notice,
14 //   this list of conditions and the following disclaimer in the documentation
15 //   and/or other materials provided with the distribution.
16 //
17 // * Neither the name of the copyright holder nor the names of its
18 //   contributors may be used to endorse or promote products derived from
19 //   this software without specific prior written permission.
20 //
21 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22 // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
25 // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26 // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27 // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28 // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29 // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30 // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31 // POSSIBILITY OF SUCH DAMAGE.
32 
33 #pragma once
34 
35 #include "dbCore.h"
36 #include "dbId.h"
37 #include "dbTypes.h"
38 #include "odb.h"
39 
40 namespace odb {
41 
42 class _dbDatabase;
43 class _dbTechSameNet;
44 class _dbTechNonDefaultRule;
45 class _dbTechLayer;
46 class dbIStream;
47 class dbOStream;
48 class dbDiff;
49 
50 struct _dbTechSameNetRuleFlags
51 {
52   uint _stack : 1;
53   uint _spare_bits : 31;
54 };
55 
56 class _dbTechSameNetRule : public _dbObject
57 {
58  public:
59   // PERSISTANT-MEMBERS
60   _dbTechSameNetRuleFlags _flags;
61   uint _spacing;
62   dbId<_dbTechLayer> _layer_1;
63   dbId<_dbTechLayer> _layer_2;
64 
65   _dbTechSameNetRule(_dbDatabase*, const _dbTechSameNetRule& r);
66   _dbTechSameNetRule(_dbDatabase*);
67   ~_dbTechSameNetRule();
68 
69   bool operator==(const _dbTechSameNetRule& rhs) const;
70   bool operator!=(const _dbTechSameNetRule& rhs) const
71   {
72     return !operator==(rhs);
73   }
74   void differences(dbDiff& diff,
75                    const char* field,
76                    const _dbTechSameNetRule& rhs) const;
77   void out(dbDiff& diff, char side, const char* field) const;
78 };
79 
_dbTechSameNetRule(_dbDatabase *,const _dbTechSameNetRule & r)80 inline _dbTechSameNetRule::_dbTechSameNetRule(_dbDatabase*,
81                                               const _dbTechSameNetRule& r)
82     : _flags(r._flags),
83       _spacing(r._spacing),
84       _layer_1(r._layer_1),
85       _layer_2(r._layer_2)
86 {
87 }
88 
_dbTechSameNetRule(_dbDatabase *)89 inline _dbTechSameNetRule::_dbTechSameNetRule(_dbDatabase*)
90 {
91   _flags._stack = 0;
92   _flags._spare_bits = 0;
93   _spacing = 0;
94 }
95 
~_dbTechSameNetRule()96 inline _dbTechSameNetRule::~_dbTechSameNetRule()
97 {
98 }
99 
100 inline dbOStream& operator<<(dbOStream& stream, const _dbTechSameNetRule& rule)
101 {
102   uint* bit_field = (uint*) &rule._flags;
103   stream << *bit_field;
104   stream << rule._spacing;
105   stream << rule._layer_1;
106   stream << rule._layer_2;
107   return stream;
108 }
109 
110 inline dbIStream& operator>>(dbIStream& stream, _dbTechSameNetRule& rule)
111 {
112   uint* bit_field = (uint*) &rule._flags;
113   stream >> *bit_field;
114   stream >> rule._spacing;
115   stream >> rule._layer_1;
116   stream >> rule._layer_2;
117   return stream;
118 }
119 
120 }  // namespace odb
121