/** * Digital Voice Modem - Host Software * GPLv2 Open Source. Use is subject to license terms. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * @package DVM / Host Software * */ /* * Copyright (C) 2022 by Bryan Biedenkapp N2PLL * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #if !defined(__AFFILIATION_LOOKUP_H__) #define __AFFILIATION_LOOKUP_H__ #include "Defines.h" #include "Timer.h" #include #include #include #include namespace lookups { // --------------------------------------------------------------------------- // Class Declaration // Implements a lookup table class that contains subscriber registration // and group affiliation information. // --------------------------------------------------------------------------- class HOST_SW_API AffiliationLookup { public: /// Initializes a new instance of the AffiliationLookup class. AffiliationLookup(const char* name, bool verbose); /// Finalizes a instance of the AffiliationLookup class. virtual ~AffiliationLookup(); /// Gets the count of unit registrations. uint8_t unitRegSize() const { return m_unitRegTable.size(); } /// Gets the unit registration table. std::vector unitRegTable() const { return m_unitRegTable; } /// Helper to register a source ID. virtual void unitReg(uint32_t srcId); /// Helper to deregister a source ID. virtual bool unitDereg(uint32_t srcId); /// Helper to determine if the source ID has unit registered. virtual bool isUnitReg(uint32_t srcId) const; /// Gets the count of affiliations. uint8_t grpAffSize() const { return m_grpAffTable.size(); } /// Gets the group affiliation table. std::unordered_map grpAffTable() const { return m_grpAffTable; } /// Helper to group affiliate a source ID. virtual void groupAff(uint32_t srcId, uint32_t dstId); /// Helper to group unaffiliate a source ID. virtual bool groupUnaff(uint32_t srcId); /// Helper to determine if the source ID has affiliated to the group destination ID. virtual bool isGroupAff(uint32_t srcId, uint32_t dstId) const; /// Helper to release group affiliations. virtual std::vector clearGroupAff(uint32_t dstId, bool releaseAll); /// Gets the count of grants. uint8_t grantSize() const { return m_grantChTable.size(); } /// Gets the grant table. std::unordered_map grantTable() const { return m_grantChTable; } /// Helper to grant a channel. virtual bool grantCh(uint32_t dstId, uint32_t grantTimeout); /// Helper to start the destination ID grant timer. virtual void touchGrant(uint32_t dstId); /// Helper to release the channel grant for the destination ID. virtual bool releaseGrant(uint32_t dstId, bool releaseAll); /// Helper to determine if the channel number is busy. virtual bool isChBusy(uint32_t chNo) const; /// Helper to determine if the destination ID is already granted. virtual bool isGranted(uint32_t dstId) const; /// Helper to get the channel granted for the given destination ID. virtual uint32_t getGrantedCh(uint32_t dstId); /// Helper to add a RF channel. void addRFCh(uint32_t chNo) { m_rfChTable.push_back(chNo); } /// Helper to remove a RF channel. void removeRFCh(uint32_t chNo) { m_rfChTable.push_back(chNo); } /// Gets the count of RF channels. uint8_t getRFChCnt() const { return m_rfChTable.size(); } /// Helper to determine if there are any RF channels available.. bool isRFChAvailable() const { return !m_rfChTable.empty(); } /// Gets the count of granted RF channels. uint8_t getGrantedRFChCnt() const { return m_rfGrantChCnt; } /// Updates the processor by the passed number of milliseconds. void clock(uint32_t ms); protected: std::vector m_rfChTable; uint8_t m_rfGrantChCnt; std::vector m_unitRegTable; std::unordered_map m_grpAffTable; std::unordered_map m_grantChTable; std::unordered_map m_grantTimers; const char *m_name; bool m_verbose; }; } // namespace lookups #endif // __AFFILIATION_LOOKUP_H__