Skip to content

iceoryx_posh/popo/notification_info.hpp🔗

Namespaces🔗

Name
iox
iox::popo

Classes🔗

Name
class iox::popo::NotificationInfo
NotificationInfo holds the state of a trigger like the pointer to the triggerOrigin, the notification id and the callback.

Source code🔗

// Copyright (c) 2020, 2021 by Apex.AI Inc. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// SPDX-License-Identifier: Apache-2.0

#ifndef IOX_POSH_POPO_NOTIFICATION_INFO_HPP
#define IOX_POSH_POPO_NOTIFICATION_INFO_HPP

#include "iceoryx_hoofs/cxx/function_ref.hpp"
#include "iceoryx_hoofs/error_handling/error_handling.hpp"
#include "iceoryx_posh/internal/log/posh_logging.hpp"
#include "iceoryx_posh/popo/notification_callback.hpp"

#include <cstdint>
#include <limits>

namespace iox
{
namespace popo
{
class NotificationInfo
{
  public:
    static constexpr uint64_t INVALID_ID = std::numeric_limits<uint64_t>::max();

    NotificationInfo() noexcept = default;
    virtual ~NotificationInfo() noexcept = default;

    template <typename T, typename ContextDataType>
    NotificationInfo(T* const notificationOrigin,
                     const uint64_t notificationId,
                     const NotificationCallback<T, ContextDataType>& callback) noexcept;

    uint64_t getNotificationId() const noexcept;

    template <typename T>
    bool doesOriginateFrom(T* const notificationOrigin) const noexcept;

    template <typename T>
    T* getOrigin() const noexcept;

    bool operator()() const noexcept;

    friend class Trigger;

  protected:
    void* m_notificationOrigin = nullptr;
    void* m_userValue = nullptr;
    uint64_t m_notificationOriginTypeHash = 0U;
    uint64_t m_notificationId = INVALID_ID;

    internal::GenericCallbackPtr_t m_callbackPtr = nullptr;
    internal::TranslationCallbackPtr_t m_callback = nullptr;
};

} // namespace popo
} // namespace iox

#include "iceoryx_posh/internal/popo/notification_info.inl"

#endif

Updated on 2 April 2022 at 16:37:47 CEST