opm-common
Loading...
Searching...
No Matches
Opm::MessageLimiter Class Reference

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). More...

Public Member Functions

 MessageLimiter ()=default
 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< std::int64_t, int > &category_limits)
int tagMessageLimit () const
 The tag message limit (same for all tags).
Response handleMessageLimits (const std::string &tag, const std::int64_t messageMask) const
 If (tag count == tag limit + 1) for the passed tag, respond JustOverTagLimit.
int categoryMessageCount (const std::int64_t category) const
 Retrieve message count for specific category.

Detailed Description

Handles limiting the number of messages with the same tag.

Member Enumeration Documentation

◆ Response

enum class Opm::MessageLimiter::Response
strong

Used for handleMessageLimits() return type (see that function).

Enumerator
PrintMessage 

Message should be printed. Not affected by any limit.

JustOverTagLimit 

Message has reached the current limit for this tag.

JustOverCategoryLimit 

Message has reached the current limit for this category.

OverTagLimit 

Message is over the current limit for this tag.

OverCategoryLimit 

Message is over the current limit of this category.

Constructor & Destructor Documentation

◆ MessageLimiter()

Opm::MessageLimiter::MessageLimiter ( const int tag_limit)
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.

Member Function Documentation

◆ categoryMessageCount()

int Opm::MessageLimiter::categoryMessageCount ( const std::int64_t category) const
inline

Retrieve message count for specific category.

Mostly provided for unit testing.

Parameters
[in]categoryMessage category.
Returns
Current message counts for category.

◆ handleMessageLimits()

Response Opm::MessageLimiter::handleMessageLimits ( const std::string & tag,
const std::int64_t messageMask ) const
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.


The documentation for this class was generated from the following file: