Commit 8869780d authored by Simon Spannagel's avatar Simon Spannagel
Browse files

Messaging: add new flag UNNAMED_ONLY to receive only messages without explicit name

parent 6c70aaae
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -517,6 +517,8 @@ Flags can be added to the bind and listening methods which enable a particular b
    It can only be used for variables bound to a single message.
    \item \parameter{IGNORE_NAME}: If this flag is specified, the name of the dispatched message is not considered.
    Thus, the \parameter{input} parameter is ignored and forced to the value \texttt{*}.
    \item \parameter{UNNAMED_ONLY}: If this flag is specified, the module will only receive messages without explicit name.
    The \parameter{input} parameter is ignored and forced to the value \texttt{?} and all named messages are discarded. It should be noted that \parameter{IGNORE_NAME} takes precedence over this parameter.
\end{itemize}

\subsection{Persistency}
+7 −0
Original line number Diff line number Diff line
@@ -98,6 +98,8 @@ void Messenger::add_delegate(const std::type_info& message_type,
    std::string message_name;
    if((delegate->getFlags() & MsgFlags::IGNORE_NAME) != MsgFlags::NONE) {
        message_name = "*";
    } else if((delegate->getFlags() & MsgFlags::UNNAMED_ONLY) != MsgFlags::NONE) {
        message_name = "?";
    } else {
        message_name = module->get_configuration().get<std::string>("input");
    }
@@ -153,6 +155,11 @@ void LocalMessenger::dispatchMessage(Module* source, std::shared_ptr<BaseMessage
    // Send to generic listeners
    send = dispatchMessage(source, message, name, "*") || send;

    // Send to listeners of unnamed messages
    if(name.empty()) {
        send = dispatchMessage(source, message, name, "?") || send;
    }

    // Display a TRACE log message if the message is send to no receiver
    if(!send) {
        const BaseMessage* inst = message.get();
+2 −1
Original line number Diff line number Diff line
@@ -53,7 +53,8 @@ namespace allpix {
        NONE = 0,                   ///< No enabled flags
        REQUIRED = (1 << 0),        ///< Require a message before running a module
        ALLOW_OVERWRITE = (1 << 1), ///< Allow overwriting a previous message
        IGNORE_NAME = (1 << 2)      ///< Listen to all ignoring message name (equal to * as a input configuration parameter)
        IGNORE_NAME = (1 << 2),     ///< Listen to all ignoring message name (equal to * as a input configuration parameter)
        UNNAMED_ONLY = (1 << 3)     ///< Listen to all messages without explicit name (equal to ? as configuration parameter)
    };
    /**
     * @ingroup Delegates