mirror of
https://github.com/anope/anope.git
synced 2026-06-12 19:14:47 +02:00
Add a typedef for the serializable id.
This commit is contained in:
+3
-2
@@ -110,10 +110,11 @@ protected:
|
||||
Serializable &operator=(const Serializable &);
|
||||
|
||||
public:
|
||||
using Id = uint64_t;
|
||||
virtual ~Serializable();
|
||||
|
||||
/* Unique ID (per type, not globally) for this object */
|
||||
uint64_t id = 0;
|
||||
Id id = 0;
|
||||
|
||||
/* Only used by redis, to ignore updates */
|
||||
unsigned short redis_ignore = 0;
|
||||
@@ -175,7 +176,7 @@ protected:
|
||||
|
||||
public:
|
||||
/* Map of Serializable objects of this type keyed by their object id. */
|
||||
std::map<uint64_t, Serializable *> objects;
|
||||
std::map<Serializable::Id, Serializable *> objects;
|
||||
|
||||
/** Destroys a serializable type. */
|
||||
~Type();
|
||||
|
||||
@@ -41,7 +41,7 @@ class LoadData final
|
||||
{
|
||||
public:
|
||||
std::fstream *fs;
|
||||
uint64_t id = 0;
|
||||
Serializable::Id id = 0;
|
||||
std::map<Anope::string, Anope::string> data;
|
||||
std::stringstream ss;
|
||||
bool read = false;
|
||||
@@ -59,7 +59,7 @@ public:
|
||||
{
|
||||
if (token.find("ID ") == 0)
|
||||
{
|
||||
this->id = Anope::Convert<uint64_t>(token.substr(3), 0);
|
||||
this->id = Anope::Convert<Serializable::Id>(token.substr(3), 0);
|
||||
continue;
|
||||
}
|
||||
else if (token.find("DATA ") != 0)
|
||||
|
||||
@@ -41,7 +41,7 @@ class Data final
|
||||
{
|
||||
public:
|
||||
// If non-zero then the id of the database entry.
|
||||
uint64_t id = 0;
|
||||
Serializable::Id id = 0;
|
||||
|
||||
// Data in this database entry.
|
||||
Anope::map<std::stringstream> data;
|
||||
|
||||
@@ -492,7 +492,7 @@ void SubscriptionListener::OnResult(const Reply &r)
|
||||
if (s_type == NULL)
|
||||
return;
|
||||
|
||||
auto oid = Anope::TryConvert<uint64_t>(id);
|
||||
auto oid = Anope::TryConvert<Serializable::Id>(id);
|
||||
if (!oid.has_value())
|
||||
return;
|
||||
|
||||
|
||||
@@ -255,7 +255,7 @@ public:
|
||||
Serializable *obj = sb->Unserialize(NULL, data);
|
||||
if (obj)
|
||||
{
|
||||
auto oid = Anope::TryConvert<unsigned int>(res.Get(j, "id"));
|
||||
auto oid = Anope::TryConvert<Serializable::Id>(res.Get(j, "id"));
|
||||
if (oid.has_value())
|
||||
obj->id = oid.value();
|
||||
else
|
||||
|
||||
@@ -190,7 +190,7 @@ public:
|
||||
|
||||
|
||||
|
||||
auto oid = Anope::TryConvert<unsigned int>(res.Get(i, "id"));
|
||||
auto oid = Anope::TryConvert<Serializable::Id>(res.Get(i, "id"));
|
||||
if (!oid.has_value())
|
||||
{
|
||||
Log(LOG_DEBUG) << "Unable to convert id from " << obj->GetName();
|
||||
@@ -201,7 +201,7 @@ public:
|
||||
if (res.Get(i, "timestamp").empty())
|
||||
{
|
||||
clear_null = true;
|
||||
std::map<uint64_t, Serializable *>::iterator it = obj->objects.find(id);
|
||||
auto it = obj->objects.find(id);
|
||||
if (it != obj->objects.end())
|
||||
delete it->second; // This also removes this object from the map
|
||||
}
|
||||
@@ -213,7 +213,7 @@ public:
|
||||
data[key] << value;
|
||||
|
||||
Serializable *s = NULL;
|
||||
std::map<uint64_t, Serializable *>::iterator it = obj->objects.find(id);
|
||||
auto it = obj->objects.find(id);
|
||||
if (it != obj->objects.end())
|
||||
s = it->second;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user