libdrmconf  0.10.4
A library to program DMR radios.
tyt_callsigndb.hh
1 #ifndef TYTCALLSIGNDB_HH
2 #define TYTCALLSIGNDB_HH
3 
4 #include "codeplug.hh"
5 #include "callsigndb.hh"
6 #include "userdatabase.hh"
7 
20 class TyTCallsignDB : public CallsignDB
21 {
22  Q_OBJECT
23 
24 public:
31  {
32  public:
38  class Entry: public Codeplug::Element
39  {
40  protected:
42  Entry(uint8_t *ptr, size_t size);
43 
44  public:
46  explicit Entry(uint8_t *ptr);
48  virtual ~Entry();
49 
50  void clear();
51 
53  virtual void set(unsigned id, unsigned index);
54  };
55 
56  protected:
58  IndexElement(uint8_t *ptr, size_t size);
59 
60  public:
62  explicit IndexElement(uint8_t *ptr);
64  virtual ~IndexElement();
65 
66  void clear();
67 
69  virtual void setNumEntries(unsigned n);
71  virtual void setIndexEntry(unsigned n, unsigned id, unsigned index);
72  };
73 
81  {
82  protected:
84  EntryElement(uint8_t *ptr, size_t size);
85  public:
87  explicit EntryElement(uint8_t *ptr);
89  virtual ~EntryElement();
90 
91  void clear();
92 
94  virtual void set(const UserDatabase::User &user);
95  };
96 
97 protected:
99  explicit TyTCallsignDB(QObject *parent=nullptr);
100 
101 public:
103  virtual ~TyTCallsignDB();
104 
105  bool encode(UserDatabase *db, const Selection &selection,const ErrorStack &err=ErrorStack());
106 
107 protected:
109  virtual void allocate(unsigned n);
110 
112  virtual void clearIndex();
114  virtual void setNumEntries(unsigned n);
116  virtual void setIndexEntry(unsigned n, unsigned id, unsigned index);
118  virtual void setEntry(unsigned n, const UserDatabase::User &user);
119 };
120 
121 #endif // TYTCALLSIGNDB_HH
Controls the selection of callsigns from the UserDatabase to be encoded into the callsign db.
Definition: callsigndb.hh:20
Abstract base class of all callsign database implementations.
Definition: callsigndb.hh:14
Represents the abstract base class of all codeplug elements.
Definition: codeplug.hh:47
uint32_t size() const
Returns the total size of the DFU file.
Definition: dfufile.cc:50
Implements a stack of error messages to provide a pretty formatted error traceback.
Definition: errorstack.hh:41
Represents an entry within the call-sign database.
Definition: tyt_callsigndb.hh:81
virtual void set(const UserDatabase::User &user)
Encodes the given user.
Definition: tyt_callsigndb.cc:115
void clear()
Abstract method to reset the element within the codeplug.
Definition: tyt_callsigndb.cc:110
virtual ~EntryElement()
Destructor.
Definition: tyt_callsigndb.cc:105
EntryElement(uint8_t *ptr, size_t size)
Hidden constructor.
Definition: tyt_callsigndb.cc:93
Represents an index entry, a pair of DMR ID and call-sign DB index.
Definition: tyt_callsigndb.hh:39
Entry(uint8_t *ptr, size_t size)
Hidden constructor.
Definition: tyt_callsigndb.cc:60
virtual void set(unsigned id, unsigned index)
Sets the index entry.
Definition: tyt_callsigndb.cc:82
void clear()
Abstract method to reset the element within the codeplug.
Definition: tyt_callsigndb.cc:77
virtual ~Entry()
Destructor.
Definition: tyt_callsigndb.cc:72
Represents a search index over the complete call-sign database.
Definition: tyt_callsigndb.hh:31
virtual ~IndexElement()
Destructor.
Definition: tyt_callsigndb.cc:32
virtual void setIndexEntry(unsigned n, unsigned id, unsigned index)
Sets the given index entry.
Definition: tyt_callsigndb.cc:52
virtual void setNumEntries(unsigned n)
Sets the number of entries in the DB.
Definition: tyt_callsigndb.cc:44
void clear()
Abstract method to reset the element within the codeplug.
Definition: tyt_callsigndb.cc:37
IndexElement(uint8_t *ptr, size_t size)
Hidden constructor.
Definition: tyt_callsigndb.cc:20
Base class for all call-sign DBs of TyT/Retevis devices.
Definition: tyt_callsigndb.hh:21
virtual void setIndexEntry(unsigned n, unsigned id, unsigned index)
Sets the given index entry.
Definition: tyt_callsigndb.cc:210
TyTCallsignDB(QObject *parent=nullptr)
Hidden constructor.
Definition: tyt_callsigndb.cc:136
virtual void clearIndex()
Clears the call-sign DB index.
Definition: tyt_callsigndb.cc:200
virtual void allocate(unsigned n)
Allocates required space for index and n call-signs.
Definition: tyt_callsigndb.cc:189
bool encode(UserDatabase *db, const Selection &selection, const ErrorStack &err=ErrorStack())
Encodes the given user db into the device specific callsign db.
Definition: tyt_callsigndb.cc:148
virtual ~TyTCallsignDB()
Destructor.
Definition: tyt_callsigndb.cc:143
virtual void setNumEntries(unsigned n)
Sets the number of entries in the DB.
Definition: tyt_callsigndb.cc:205
virtual void setEntry(unsigned n, const UserDatabase::User &user)
Sets a given call-sign entry.
Definition: tyt_callsigndb.cc:215
Represents the user information within the UserDatabase.
Definition: userdatabase.hh:28
Auto-updating DMR user database.
Definition: userdatabase.hh:23