Skip to content

Commit

Permalink
Add missing port iterator files. Signed-off-by: Andy Fox <andy@rushc.…
Browse files Browse the repository at this point in the history
…com>

Signed-off-by: andyfox-rushc <[email protected]>
  • Loading branch information
andyfox-rushc committed Aug 4, 2024
1 parent f7fa1c9 commit f34ef08
Show file tree
Hide file tree
Showing 2 changed files with 189 additions and 0 deletions.
118 changes: 118 additions & 0 deletions src/odb/src/db/dbModulePortItr.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
///////////////////////////////////////////////////////////////////////////////
// BSD 3-Clause License
//
// Copyright (c) 2019, Nefelus Inc
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// * Redistributions of source code must retain the above copyright notice, this
// list of conditions and the following disclaimer.
//
// * Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
// * Neither the name of the copyright holder nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.

// Generator Code Begin Cpp
#include "dbModulePortItr.h"

#include "dbBlock.h"
#include "dbBusPort.h"
#include "dbModBTerm.h"
#include "dbModule.h"
#include "dbTable.h"

namespace odb {

////////////////////////////////////////////////////////////////////
//
// dbModulePortItr - Methods
//
////////////////////////////////////////////////////////////////////

bool dbModulePortItr::reversible()
{
return true;
}

bool dbModulePortItr::orderReversed()
{
return true;
}

void dbModulePortItr::reverse(dbObject* parent)
{
}

uint dbModulePortItr::sequential()
{
return 0;
}

uint dbModulePortItr::size(dbObject* parent)
{
uint id;
uint cnt = 0;

for (id = dbModulePortItr::begin(parent); id != dbModulePortItr::end(parent);
id = dbModulePortItr::next(id)) {
++cnt;
}

return cnt;
}

uint dbModulePortItr::begin(dbObject* parent)
{
// User Code Begin begin
_dbModule* _module = (_dbModule*) parent;
return _module->_modbterms;
// User Code End begin
}

uint dbModulePortItr::end(dbObject* /* unused: parent */)
{
return 0;
}

uint dbModulePortItr::next(uint id, ...)
{
// User Code Begin next
_dbModBTerm* modbterm = _modbterm_tbl->getPtr(id);
if (modbterm->_busPort != 0) {
_dbBlock* block = (_dbBlock*) modbterm->getOwner();
_dbBusPort* bus_port = block->_busport_tbl->getPtr(modbterm->_busPort);
if (bus_port) {
modbterm = _modbterm_tbl->getPtr(bus_port->_last);
}
}
if (modbterm) {
return modbterm->_next_entry;
}
return 0;
// User Code End next
}

dbObject* dbModulePortItr::getObject(uint id, ...)
{
return _modbterm_tbl->getPtr(id);
}
} // namespace odb
// Generator Code End Cpp
71 changes: 71 additions & 0 deletions src/odb/src/db/dbModulePortItr.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
///////////////////////////////////////////////////////////////////////////////
// BSD 3-Clause License
//
// Copyright (c) 2020, The Regents of the University of California
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// * Redistributions of source code must retain the above copyright notice, this
// list of conditions and the following disclaimer.
//
// * Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
// * Neither the name of the copyright holder nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.

// Generator Code Begin Header
#pragma once

#include "odb/dbIterator.h"
#include "odb/odb.h"

namespace odb {
class _dbModBTerm;

template <class T>
class dbTable;

class dbModulePortItr : public dbIterator
{
public:
dbModulePortItr(dbTable<_dbModBTerm>* modbterm_tbl)
{
_modbterm_tbl = modbterm_tbl;
}

bool reversible() override;
bool orderReversed() override;
void reverse(dbObject* parent) override;
uint sequential() override;
uint size(dbObject* parent) override;
uint begin(dbObject* parent) override;
uint end(dbObject* parent) override;
uint next(uint id, ...) override;
dbObject* getObject(uint id, ...) override;

private:
dbTable<_dbModBTerm>* _modbterm_tbl;
// User Code Begin Fields
dbModulePortItr* _port_iter = nullptr;
// User Code End Fields
};

} // namespace odb
// Generator Code End Header

0 comments on commit f34ef08

Please sign in to comment.