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 // Generator Code Begin Cpp
34 #include "dbGroupItr.h"
35
36 #include "dbGroup.h"
37 #include "dbTable.h"
38 // User Code Begin Includes
39 #include "dbModule.h"
40 // User Code End Includes
41
42 namespace odb {
43
44 ////////////////////////////////////////////////////////////////////
45 //
46 // dbGroupItr - Methods
47 //
48 ////////////////////////////////////////////////////////////////////
49
reversible()50 bool dbGroupItr::reversible()
51 {
52 return true;
53 }
54
orderReversed()55 bool dbGroupItr::orderReversed()
56 {
57 return true;
58 }
59
reverse(dbObject * parent)60 void dbGroupItr::reverse(dbObject* parent)
61 {
62 // User Code Begin reverse
63 _dbGroup* _parent = (_dbGroup*) parent;
64 uint id = _parent->_groups;
65 uint list = 0;
66
67 while (id != 0) {
68 _dbGroup* _child = _group_tbl->getPtr(id);
69 uint n = _child->_group_next;
70 _child->_group_next = list;
71 list = id;
72 id = n;
73 }
74 _parent->_groups = list;
75 // User Code End reverse
76 }
77
sequential()78 uint dbGroupItr::sequential()
79 {
80 return 0;
81 }
82
size(dbObject * parent)83 uint dbGroupItr::size(dbObject* parent)
84 {
85 uint id;
86 uint cnt = 0;
87
88 for (id = dbGroupItr::begin(parent); id != dbGroupItr::end(parent);
89 id = dbGroupItr::next(id))
90 ++cnt;
91
92 return cnt;
93 }
94
begin(dbObject * parent)95 uint dbGroupItr::begin(dbObject* parent)
96 {
97 // User Code Begin begin
98 _dbGroup* _parent = (_dbGroup*) parent;
99 return _parent->_groups;
100 // User Code End begin
101 }
102
end(dbObject *)103 uint dbGroupItr::end(dbObject* /* unused: parent */)
104 {
105 return 0;
106 }
107
next(uint id,...)108 uint dbGroupItr::next(uint id, ...)
109 {
110 // User Code Begin next
111 _dbGroup* _child = _group_tbl->getPtr(id);
112 return _child->_group_next;
113 // User Code End next
114 }
115
getObject(uint id,...)116 dbObject* dbGroupItr::getObject(uint id, ...)
117 {
118 return _group_tbl->getPtr(id);
119 }
120 // User Code Begin Methods
121 // User Code End Methods
122 } // namespace odb
123 // Generator Code End Cpp