MessageQueue.h
Go to the documentation of this file.
1 /****
2  * MessageQueue.h
3  *
4  * Copyright 2019 mikee47 <mike@sillyhouse.net>
5  *
6  * This file is part of the Sming SSDP Library
7  *
8  * This library is free software: you can redistribute it and/or modify it under the terms of the
9  * GNU General Public License as published by the Free Software Foundation, version 3 or later.
10  *
11  * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
12  * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13  * See the GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License along with this library.
16  * If not, see <https://www.gnu.org/licenses/>.
17  *
18  ****/
19 
20 #pragma once
21 
22 #include "MessageSpec.h"
23 #include <Timer.h>
24 
25 namespace SSDP
26 {
32 
37 {
38 public:
40 
42  {
43  clear();
44  }
45 
46  void clear();
47 
48  unsigned count();
49 
55  {
56  this->delegate = delegate;
57  }
58 
67  void add(MessageSpec* ms, uint32_t intervalMs);
68 
76  bool contains(const MessageSpec& ms) const;
77 
82  unsigned remove(void* object);
83 
84 private:
85  void setTimer();
86 
87  Timer timer;
88  MessageDelegate delegate;
89  MessageSpec* head{nullptr};
90  bool timerSet{false};
91 };
92 
93 } // namespace SSDP
Queue of objects managed by a single timer.
Definition: MessageQueue.h:37
~MessageQueue()
Definition: MessageQueue.h:41
unsigned remove(void *object)
Remove any messages for this object.
void add(MessageSpec *ms, uint32_t intervalMs)
Schedule a message to start after the given interval has elapsed.
void setCallback(MessageDelegate delegate)
Set a callback to handle sending a message @Param delegate.
Definition: MessageQueue.h:54
MessageQueue(MessageDelegate delegate)
bool contains(const MessageSpec &ms) const
Determine if a matching message specification is already queued.
Defines the information used to create an outgoing message.
Definition: MessageSpec.h:75
Callback timer class.
Definition: Timer.h:263
Definition: SSDP/src/include/Network/SSDP/Message.h:32