Program Listing for File ecal_subscriber.h¶
↰ Return to documentation for file (ecal/core/include/ecal/ecal_subscriber.h
)
/* ========================= eCAL LICENSE =================================
*
* Copyright (C) 2016 - 2019 Continental Corporation
*
* 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.
*
* ========================= eCAL LICENSE =================================
*/
#pragma once
#include <ecal/ecal_os.h>
#include <ecal/ecal_callback.h>
#include <ecal/ecal_qos.h>
#include <set>
#include <string>
namespace eCAL
{
class CDataReader;
class ECAL_API CSubscriber
{
public:
CSubscriber();
CSubscriber(const std::string& topic_name_, const std::string& topic_type_ = "", const std::string& topic_desc_ = "");
virtual ~CSubscriber();
CSubscriber(const CSubscriber&) = delete;
CSubscriber& operator=(const CSubscriber&) = delete;
CSubscriber(CSubscriber&& rhs) noexcept;
CSubscriber& operator=(CSubscriber&& rhs) noexcept;
bool Create(const std::string& topic_name_, const std::string& topic_type_ = "", const std::string& topic_desc_ = "");
bool Destroy();
bool SetQOS(const QOS::SReaderQOS& qos_);
QOS::SReaderQOS GetQOS();
bool SetID(const std::set<long long>& id_set_);
bool SetAttribute(const std::string& attr_name_, const std::string& attr_value_);
bool ClearAttribute(const std::string& attr_name_);
[[deprecated]]
size_t Receive(std::string& buf_, long long* time_ = nullptr, int rcv_timeout_ = 0) const;
bool ReceiveBuffer(std::string& buf_, long long* time_ = nullptr, int rcv_timeout_ = 0) const;
bool AddReceiveCallback(ReceiveCallbackT callback_);
bool RemReceiveCallback();
bool AddEventCallback(eCAL_Subscriber_Event type_, SubEventCallbackT callback_);
bool RemEventCallback(eCAL_Subscriber_Event type_);
bool IsCreated() const {return(m_created);}
size_t GetPublisherCount() const;
std::string GetTopicName() const;
std::string GetTypeName() const;
std::string GetDescription() const;
bool SetTimeout(int timeout_);
std::string Dump(const std::string& indent_ = "") const;
protected:
void InitializeQOS();
// class members
CDataReader* m_datareader;
struct ECAL_API QOS::SReaderQOS m_qos;
bool m_created;
bool m_initialized;
};
};