/** * 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 * */ // // Based on code from the MMDVMHost project. (https://github.com/g4klx/MMDVMHost) // Licensed under the GPLv2 License (https://opensource.org/licenses/GPL-2.0) // /* * Copyright (C) 2016 by Jonathan Naylor G4KLX * Copyright (C) 2017-2019 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(__TALKGROUP_ID_LOOKUP_H__) #define __TALKGROUP_ID_LOOKUP_H__ #include "Defines.h" #include "lookups/LookupTable.h" #include "Thread.h" #include "Mutex.h" #include #include namespace lookups { // --------------------------------------------------------------------------- // Class Declaration // Represents an individual entry in the talkgroup ID table. // --------------------------------------------------------------------------- class HOST_SW_API TalkgroupId { public: /// Initializes a new insatnce of the TalkgroupId class. TalkgroupId() : m_tgEnabled(false), m_tgSlot(0U), m_tgDefault(false) { /* stub */ } /// Initializes a new insatnce of the TalkgroupId class. /// /// /// TalkgroupId(bool tgEnabled, uint8_t tgSlot, bool tgDefault) : m_tgEnabled(tgEnabled), m_tgSlot(tgSlot), m_tgDefault(tgDefault) { /* stub */ } /// Equals operator. Copies this TalkgroupId to another TalkgroupId. TalkgroupId& operator=(const TalkgroupId& data) { if (this != &data) { m_tgEnabled = data.m_tgEnabled; m_tgSlot = data.m_tgSlot; m_tgDefault = data.m_tgDefault; } return *this; } /// Sets talkgroup values. /// Talkgroup Enabled. /// Talkgroup DMR slot. /// Talkgroup Default. void set(bool tgEnabled, uint8_t tgSlot, bool tgDefault) { m_tgEnabled = tgEnabled; m_tgSlot = tgSlot; m_tgDefault = tgDefault; } public: /// Flag indicating if the talkgroup is enabled. __READONLY_PROPERTY_PLAIN(bool, tgEnabled, tgEnabled); /// Talkgroup DMR slot. __READONLY_PROPERTY_PLAIN(uint8_t, tgSlot, tgSlot); /// Flag indicating if the talkgroup is default. __READONLY_PROPERTY_PLAIN(bool, tgDefault, tgDefault); }; // --------------------------------------------------------------------------- // Class Declaration // Implements a threading lookup table class that contains a talkgroup // ID lookup table. // --------------------------------------------------------------------------- class HOST_SW_API TalkgroupIdLookup : public LookupTable { public: /// Initializes a new instance of the TalkgroupIdLookup class. TalkgroupIdLookup(const std::string& filename, uint32_t reloadTime, bool tidAcl); /// Finalizes a instance of the TalkgroupIdLookup class. virtual ~TalkgroupIdLookup(); /// Adds a new entry to the lookup table by the specified unique ID. void addEntry(uint32_t id, unsigned char slot, bool enabled); /// Finds a table entry in this lookup table. virtual TalkgroupId find(uint32_t id); /// Flag indicating whether talkgroup ID access control is enabled or not. bool getACL(); protected: bool m_acl; /// Loads the table from the passed lookup table file. /// True, if lookup table was loaded, otherwise false. virtual bool load(); }; } // namespace lookups #endif // __TALKGROUP_ID_LOOKUP_H__