Skip to content

iceoryx_posh/internal/popo/base_server.hpp🔗

Namespaces🔗

Name
iox
iox::popo

Classes🔗

Name
class iox::popo::BaseServer
The BaseServer class contains the common implementation for the different server.

Source code🔗

// Copyright (c) 2020 by Robert Bosch GmbH. All rights reserved.
// Copyright (c) 2020 - 2022 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_BASE_SERVER_HPP
#define IOX_POSH_POPO_BASE_SERVER_HPP

#include "iceoryx_hoofs/cxx/expected.hpp"
#include "iceoryx_posh/capro/service_description.hpp"
#include "iceoryx_posh/internal/popo/ports/server_port_user.hpp"
#include "iceoryx_posh/popo/server_options.hpp"
#include "iceoryx_posh/popo/trigger_handle.hpp"
#include "iceoryx_posh/runtime/posh_runtime.hpp"

namespace iox
{
namespace popo
{
using uid_t = UniquePortId;

template <typename PortT = ServerPortUser, typename TriggerHandleT = TriggerHandle>
class BaseServer
{
  public:
    virtual ~BaseServer() noexcept;

    BaseServer(const BaseServer& other) = delete;
    BaseServer& operator=(const BaseServer&) = delete;
    BaseServer(BaseServer&& rhs) = delete;
    BaseServer& operator=(BaseServer&& rhs) = delete;

    uid_t getUid() const noexcept;

    const capro::ServiceDescription& getServiceDescription() const noexcept;

    void offer() noexcept;

    void stopOffer() noexcept;

    bool isOffered() const noexcept;

    bool hasClients() const noexcept;

    bool hasRequests() const noexcept;

    bool hasMissedRequests() noexcept;

    void releaseQueuedRequests() noexcept;

    friend class NotificationAttorney;

  protected:
    using SelfType = BaseServer<PortT, TriggerHandleT>;
    using PortType = PortT;

    BaseServer(const capro::ServiceDescription& service, const ServerOptions& serverOptions) noexcept;

    void invalidateTrigger(const uint64_t uniqueTriggerId) noexcept;

    void enableState(TriggerHandleT&& triggerHandle, const ServerState serverState) noexcept;

    WaitSetIsConditionSatisfiedCallback
    getCallbackForIsStateConditionSatisfied(const ServerState serverState) const noexcept;

    void disableState(const ServerState serverState) noexcept;

    void enableEvent(TriggerHandleT&& triggerHandle, const ServerEvent serverEvent) noexcept;

    void disableEvent(const ServerEvent serverEvent) noexcept;

    const PortT& port() const noexcept;

    PortT& port() noexcept;

    PortT m_port;             // NOLINT(cppcoreguidelines-non-private-member-variables-in-classes)
    TriggerHandleT m_trigger; // NOLINT(cppcoreguidelines-non-private-member-variables-in-classes)
};

} // namespace popo
} // namespace iox

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

#endif // IOX_POSH_POPO_BASE_SERVER_HPP

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