-
Notifications
You must be signed in to change notification settings - Fork 24
/
Copy pathsharedsubscribers.h
45 lines (36 loc) · 1.16 KB
/
sharedsubscribers.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
/*
This file is part of FlashMQ (https://www.flashmq.org)
Copyright (C) 2021-2023 Wiebe Cazemier
FlashMQ is free software: you can redistribute it and/or modify
it under the terms of The Open Software License 3.0 (OSL-3.0).
See LICENSE for license details.
*/
#ifndef SHAREDSUBSCRIBERS_H
#define SHAREDSUBSCRIBERS_H
#include <string>
#include <vector>
#include <unordered_map>
#include <memory>
#include "forward_declarations.h"
#include "subscription.h"
class SharedSubscribers
{
#ifdef TESTING
friend class MainTests;
#endif
std::vector<Subscription> members;
std::unordered_map<std::string, int> index;
int roundRobinCounter = 0;
std::string shareName;
public:
SharedSubscribers() noexcept;
void setName(const std::string &name);
Subscription& operator[](const std::string &clientid);
const Subscription *getNext();
const Subscription *getNext(size_t hash) const;
void erase(const std::string &clientid);
void purgeAndReIndex();
bool empty() const;
void getForSerializing(const std::string &topic, std::unordered_map<std::string, std::list<SubscriptionForSerializing>> &outputList) const;
};
#endif // SHAREDSUBSCRIBERS_H