My Project
|
Handles limiting the number of messages with the same tag. More...
#include <MessageLimiter.hpp>
Public Types | |
enum | { NoLimit = -1 } |
Used to indicate no message number limit. | |
enum class | Response { PrintMessage , JustOverTagLimit , JustOverCategoryLimit , OverTagLimit , OverCategoryLimit } |
Used for handleMessageLimits() return type (see that function). | |
Public Member Functions | |
MessageLimiter () | |
Default constructor, no limit to the number of messages. | |
MessageLimiter (const int tag_limit) | |
Construct with given limit to number of messages with the same tag. | |
MessageLimiter (const int tag_limit, const std::map< int64_t, int > &category_limits) | |
int | tagMessageLimit () const |
The tag message limit (same for all tags). | |
const std::map< int64_t, int > & | categoryMessageLimits () const |
The category message limits. | |
const std::map< int64_t, int > & | categoryMessageCounts () const |
The category message counts. | |
Response | handleMessageLimits (const std::string &tag, const int64_t messageMask) |
If (tag count == tag limit + 1) for the passed tag, respond JustOverTagLimit. | |
Handles limiting the number of messages with the same tag.
|
inlineexplicit |
Construct with given limit to number of messages with the same tag.
Negative limits (including NoLimit) are interpreted as NoLimit, but the default constructor is the preferred way to obtain that behaviour.
|
inline |
If (tag count == tag limit + 1) for the passed tag, respond JustOverTagLimit.
If (tag count > tag limit + 1), respond OverTagLimit. If a tag is empty, there is no tag message limit or for that tag (tag count <= tag limit), consider the category limits: If (category count == category limit + 1) for the passed messageMask, respond JustOverCategoryLimit. If (category count > category limit + 1), respond OverCategoryLimit. If (category count <= category limit), or there is no limit for that category, respond PrintMessage.