Program Listing for File StatisticsCommon.hpp
↰ Return to documentation for file (/tmp/ws/src/fastrtps/include/fastdds/statistics/rtps/StatisticsCommon.hpp
)
// Copyright 2021 Proyectos y Sistemas de Mantenimiento SL (eProsima).
//
// 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.
#ifndef _FASTDDS_STATISTICS_RTPS_STATISTICSCOMMON_HPP_
#define _FASTDDS_STATISTICS_RTPS_STATISTICSCOMMON_HPP_
#include <memory>
#include <type_traits>
#include <fastdds/rtps/common/Guid.h>
#include <fastdds/rtps/common/SampleIdentity.h>
#include <fastdds/rtps/common/Time_t.h>
#include <fastdds/statistics/IListeners.hpp>
#include <fastrtps/utils/TimedMutex.hpp>
namespace eprosima {
namespace fastrtps {
namespace rtps {
class RTPSMessageGroup;
} // rtps
} // fastrtps
namespace fastdds {
namespace statistics {
#ifdef FASTDDS_STATISTICS
// Members are private details
struct StatisticsAncillary;
class StatisticsListenersImpl
{
std::unique_ptr<StatisticsAncillary> members_;
protected:
template<class A>
void init_statistics()
{
static_assert(
std::is_base_of<StatisticsAncillary, A>::value,
"Auxiliary structure must derive from StatisticsAncillary");
if (!members_)
{
members_.reset(new A);
}
}
StatisticsAncillary* get_aux_members() const;
bool add_statistics_listener_impl(
std::shared_ptr<fastdds::statistics::IListener> listener);
bool remove_statistics_listener_impl(
std::shared_ptr<fastdds::statistics::IListener> listener);
void set_enabled_statistics_writers_mask_impl(
uint32_t enabled_writers);
bool are_statistics_writers_enabled(
uint32_t checked_enabled_writers);
template<class Function>
Function for_each_listener(
Function f);
virtual fastrtps::RecursiveTimedMutex& get_statistics_mutex() = 0;
virtual const fastrtps::rtps::GUID_t& get_guid() const = 0;
};
// Members are private details
struct StatisticsWriterAncillary;
class StatisticsWriterImpl
: protected StatisticsListenersImpl
{
StatisticsWriterAncillary* get_members() const;
fastrtps::RecursiveTimedMutex& get_statistics_mutex() final;
const fastrtps::rtps::GUID_t& get_guid() const final;
protected:
StatisticsWriterImpl();
// TODO: methods for listeners callbacks
void on_sample_datas(
const fastrtps::rtps::SampleIdentity& sample_identity,
size_t num_sent_submessages);
void on_heartbeat(
uint32_t count);
void on_data_generated(
size_t num_destinations);
void on_data_sent();
void on_publish_throughput(
uint32_t payload);
void on_gap();
/*
* @brief Report that several changes are marked for redelivery
* @param number of changes to redeliver
*/
void on_resent_data(
uint32_t to_send);
};
// Members are private details
struct StatisticsReaderAncillary;
class StatisticsReaderImpl
: protected StatisticsListenersImpl
{
friend class fastrtps::rtps::RTPSMessageGroup;
StatisticsReaderAncillary* get_members() const;
fastrtps::RecursiveTimedMutex& get_statistics_mutex() final;
const fastrtps::rtps::GUID_t& get_guid() const final;
protected:
StatisticsReaderImpl();
// TODO: methods for listeners callbacks
void on_data_notify(
const fastrtps::rtps::GUID_t& writer_guid,
const fastrtps::rtps::Time_t& source_timestamp);
void on_acknack(
int32_t count);
void on_nackfrag(
int32_t count);
void on_subscribe_throughput(
uint32_t payload);
};
#else // when FASTDDS_STATISTICS is not defined a dummy implementation is used
class StatisticsWriterImpl
{
protected:
// TODO: methods for listeners callbacks
inline void on_sample_datas(
const fastrtps::rtps::SampleIdentity&,
size_t)
{
}
inline void on_heartbeat(
uint32_t)
{
}
inline void on_data_generated(
size_t)
{
}
inline void on_data_sent()
{
}
inline void on_publish_throughput(
uint32_t)
{
}
inline void on_gap()
{
}
/*
* @brief Report that several changes are marked for redelivery
* Parameter: number of changes to redeliver
*/
inline void on_resent_data(
uint32_t)
{
}
};
class StatisticsReaderImpl
{
friend class fastrtps::rtps::RTPSMessageGroup;
protected:
// TODO: methods for listeners callbacks
inline void on_data_notify(
const fastrtps::rtps::GUID_t&,
const fastrtps::rtps::Time_t&)
{
}
inline void on_acknack(
int32_t)
{
}
inline void on_nackfrag(
int32_t)
{
}
inline void on_subscribe_throughput(
uint32_t)
{
}
};
#endif // FASTDDS_STATISTICS
} // namespace statistics
} // namespace fastdds
} // namespace eprosima
#endif // _FASTDDS_STATISTICS_RTPS_STATISTICSCOMMON_HPP_