Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove ParameterList_t [4370] #379

Merged
61 changes: 22 additions & 39 deletions include/fastrtps/qos/ParameterList.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,39 +25,13 @@
#include "../rtps/messages/CDRMessage.h"
#include "../rtps/common/CacheChange.h"

#include <functional>

namespace eprosima {
namespace fastrtps {

/**
* ParameterList_t class, used to store multiple parameters as a vector of pointers to the base class.
* @ingroup PARAMETER_MODULE
*/
class ParameterList_t
{
public:

ParameterList_t() {}

ParameterList_t(ParameterList_t&& plist) : m_parameters(std::move(plist.m_parameters)) {}

virtual ~ParameterList_t()
{
for(std::vector<Parameter_t*>::iterator it = m_parameters.begin();
it!=m_parameters.end();++it)
delete(*it);
m_parameters.clear();
}

//! Vector of the pointers to the parameters.
std::vector<Parameter_t*> m_parameters;

private:

ParameterList_t(const ParameterList_t& plist) = delete;
};

/**
* ParameterList class has static methods to update or read a ParameterList_t
* ParameterList class has static methods to update or read a list of Parameter_t
* @ingroup PARAMETER_MODULE
*/

Expand All @@ -66,22 +40,31 @@ class ParameterList
public:

/**
* Update the CDRMessage of a parameterList.
* Write parameterList encapsulation to the CDRMessage.
* @param msg Pointer to the message (the pos should be correct, otherwise the behaviour is undefined).
* @param plist Pointer to the parameterList.
* @return True if correct.
*/
static bool writeParameterListToCDRMsg(rtps::CDRMessage_t* msg, ParameterList_t* plist, bool use_encapsulation);
static bool writeEncapsulationToCDRMsg(rtps::CDRMessage_t* msg);

/**
* Read a parameterList from a CDRMessage
* Update the information of a cache change parsing the inline qos from a CDRMessage
* @param[inout] change Reference to the cache change to be updated.
* @param[in] msg Pointer to the message (the pos should be correct, otherwise the behaviour is undefined).
* @param[out] plist Pointer to the parameter list.
* @param[out] change Pointer to the cache change.
* @return Number of bytes of the parameter list.
* @param[out] qos_size Number of bytes processed.
* @return true if parsing was correct, false otherwise.
*/
static bool updateCacheChangeFromInlineQos(rtps::CacheChange_t& change, rtps::CDRMessage_t* msg, uint32_t& qos_size);

/**
* Read a parameterList from a CDRMessage
* @param[in] msg Reference to the message (the pos should be correct, otherwise the behaviour is undefined).
* @param[in] processor Function to process each of the parameters in the list.
* @param[in] use_encapsulation Wether encapsulation field should be read.
* @param[out] qos_size Number of bytes processed.
* @return true if parsing was correct, false otherwise.
*/
static int32_t readParameterListfromCDRMsg(rtps::CDRMessage_t* msg, ParameterList_t* plist, rtps::CacheChange_t* change,
bool encapsulation);
static bool readParameterListfromCDRMsg(rtps::CDRMessage_t& msg, std::function<bool(const Parameter_t*)> processor,
bool use_encapsulation, uint32_t& qos_size);

/**
* Read change instanceHandle from the KEY_HASH or another specific PID parameter of a CDRMessage
Expand All @@ -92,7 +75,7 @@ class ParameterList
static bool readInstanceHandleFromCDRMsg(rtps::CacheChange_t* change, const uint16_t pid);
};

} /* namespace */
} /* namespace fastrtps */
} /* namespace eprosima */
#endif
#endif /* PARAMLISTT_H_ */
26 changes: 26 additions & 0 deletions include/fastrtps/qos/ParameterTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,32 @@ class ParameterBool_t:public Parameter_t{

#define PARAMETER_BOOL_LENGTH 4

/**
*
*/
class ParameterStatusInfo_t :public Parameter_t
{
public:
uint8_t status;
ParameterStatusInfo_t() :status(0) {}

/**
* Constructor using a parameter PID and the parameter length
* @param pid Pid of the parameter
* @param in_length Its associated length
*/
ParameterStatusInfo_t(ParameterId_t pid, uint16_t in_length) :Parameter_t(pid, in_length), status(0) {}
ParameterStatusInfo_t(ParameterId_t pid, uint16_t in_length, uint8_t instatus) :Parameter_t(pid, in_length), status(instatus) {}
/**
* Add the parameter to a CDRMessage_t message.
* @param[in,out] msg Pointer to the message where the parameter should be added.
* @return True if the parameter was correctly added.
*/
bool addToCDRMessage(rtps::CDRMessage_t* msg) override;
};

#define PARAMETER_STATUS_INFO_LENGTH 4

/**
*
*/
Expand Down
62 changes: 44 additions & 18 deletions include/fastrtps/qos/QosPolicies.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ typedef enum DurabilityQosPolicyKind: rtps::octet{
*/
class DurabilityQosPolicy : private Parameter_t, public QosPolicy
{
friend class ParameterList;
public:
RTPS_DllAPI DurabilityQosPolicy()
: Parameter_t(PID_DURABILITY, PARAMETER_KIND_LENGTH),
Expand Down Expand Up @@ -152,6 +153,7 @@ class DurabilityQosPolicy : private Parameter_t, public QosPolicy
*/
class DeadlineQosPolicy : private Parameter_t, public QosPolicy
{
friend class ParameterList;
public:
RTPS_DllAPI DeadlineQosPolicy()
: Parameter_t(PID_DEADLINE, PARAMETER_TIME_LENGTH),
Expand Down Expand Up @@ -185,6 +187,7 @@ class DeadlineQosPolicy : private Parameter_t, public QosPolicy
* period: Default value c_TimeZero.
*/
class LatencyBudgetQosPolicy : private Parameter_t, public QosPolicy {
friend class ParameterList;
public:
RTPS_DllAPI LatencyBudgetQosPolicy()
: Parameter_t(PID_LATENCY_BUDGET,PARAMETER_TIME_LENGTH),
Expand Down Expand Up @@ -232,6 +235,7 @@ typedef enum LivelinessQosPolicyKind:rtps::octet {
*/
class LivelinessQosPolicy : private Parameter_t, public QosPolicy
{
friend class ParameterList;
public:
RTPS_DllAPI LivelinessQosPolicy()
: Parameter_t(PID_LIVELINESS,PARAMETER_KIND_LENGTH+PARAMETER_TIME_LENGTH),
Expand Down Expand Up @@ -280,6 +284,7 @@ typedef enum ReliabilityQosPolicyKind:rtps::octet {
*/
class ReliabilityQosPolicy : private Parameter_t, public QosPolicy
{
friend class ParameterList;
public:
RTPS_DllAPI ReliabilityQosPolicy()
: Parameter_t(PID_RELIABILITY,PARAMETER_KIND_LENGTH+PARAMETER_TIME_LENGTH),
Expand Down Expand Up @@ -327,6 +332,7 @@ enum OwnershipQosPolicyKind:rtps::octet {
*/
class OwnershipQosPolicy : private Parameter_t, public QosPolicy
{
friend class ParameterList;
public:
RTPS_DllAPI OwnershipQosPolicy()
: Parameter_t(PID_OWNERSHIP,PARAMETER_KIND_LENGTH),
Expand Down Expand Up @@ -371,6 +377,7 @@ enum DestinationOrderQosPolicyKind :rtps::octet{
*/
class DestinationOrderQosPolicy : private Parameter_t, public QosPolicy
{
friend class ParameterList;
public:
RTPS_DllAPI DestinationOrderQosPolicy()
: Parameter_t(PID_DESTINATION_ORDER,PARAMETER_KIND_LENGTH),
Expand Down Expand Up @@ -450,6 +457,7 @@ class UserDataQosPolicy : private Parameter_t, public QosPolicy
*/
class TimeBasedFilterQosPolicy : private Parameter_t, public QosPolicy
{
friend class ParameterList;
public:

RTPS_DllAPI TimeBasedFilterQosPolicy()
Expand Down Expand Up @@ -499,6 +507,7 @@ enum PresentationQosPolicyAccessScopeKind:rtps::octet
*/
class PresentationQosPolicy : private Parameter_t, public QosPolicy
{
friend class ParameterList;
public:
RTPS_DllAPI PresentationQosPolicy()
: Parameter_t(PID_PRESENTATION,PARAMETER_PRESENTATION_LENGTH),
Expand Down Expand Up @@ -708,6 +717,7 @@ enum HistoryQosPolicyKind:rtps::octet {
*/
class HistoryQosPolicy : private Parameter_t, public QosPolicy
{
friend class ParameterList;
public:
RTPS_DllAPI HistoryQosPolicy()
: Parameter_t(PID_HISTORY,PARAMETER_KIND_LENGTH+4),
Expand Down Expand Up @@ -745,21 +755,27 @@ class HistoryQosPolicy : private Parameter_t, public QosPolicy
* max_samples_per_instance: Default value 400.
* allocated_samples: Default value 100.
*/
class ResourceLimitsQosPolicy : private Parameter_t, public QosPolicy {
public:
int32_t max_samples;
int32_t max_instances;
int32_t max_samples_per_instance;
int32_t allocated_samples;
RTPS_DllAPI ResourceLimitsQosPolicy():Parameter_t(PID_RESOURCE_LIMITS,4+4+4),QosPolicy(false),
max_samples(5000),max_instances(10),max_samples_per_instance(400),allocated_samples(100){};
virtual RTPS_DllAPI ~ResourceLimitsQosPolicy(){};
/**
* Appends QoS to the specified CDR message.
* @param msg Message to append the QoS Policy to.
* @return True if the modified CDRMessage is valid.
*/
bool addToCDRMessage(rtps::CDRMessage_t* msg) override;
class ResourceLimitsQosPolicy : private Parameter_t, public QosPolicy
{
friend class ParameterList;
public:
int32_t max_samples;
int32_t max_instances;
int32_t max_samples_per_instance;
int32_t allocated_samples;

RTPS_DllAPI ResourceLimitsQosPolicy() :Parameter_t(PID_RESOURCE_LIMITS, 4 + 4 + 4), QosPolicy(false),
max_samples(5000), max_instances(10), max_samples_per_instance(400), allocated_samples(100)
{ }

virtual RTPS_DllAPI ~ResourceLimitsQosPolicy() { }

/**
* Appends QoS to the specified CDR message.
* @param msg Message to append the QoS Policy to.
* @return True if the modified CDRMessage is valid.
*/
bool addToCDRMessage(rtps::CDRMessage_t* msg) override;
};


Expand All @@ -776,6 +792,7 @@ class ResourceLimitsQosPolicy : private Parameter_t, public QosPolicy {
*/
class DurabilityServiceQosPolicy : private Parameter_t, public QosPolicy
{
friend class ParameterList;
public:
RTPS_DllAPI DurabilityServiceQosPolicy()
: Parameter_t(PID_DURABILITY_SERVICE,PARAMETER_TIME_LENGTH+PARAMETER_KIND_LENGTH+4+4+4+4),
Expand Down Expand Up @@ -823,6 +840,7 @@ class DurabilityServiceQosPolicy : private Parameter_t, public QosPolicy
*/
class LifespanQosPolicy : private Parameter_t, public QosPolicy
{
friend class ParameterList;
public:
RTPS_DllAPI LifespanQosPolicy()
: Parameter_t(PID_LIFESPAN,PARAMETER_TIME_LENGTH),
Expand Down Expand Up @@ -854,7 +872,9 @@ class LifespanQosPolicy : private Parameter_t, public QosPolicy
* Class OwnershipStrengthQosPolicy, to indicate the strength of the ownership.
* value: Default value 0.
*/
class OwnershipStrengthQosPolicy : private Parameter_t, public QosPolicy {
class OwnershipStrengthQosPolicy : private Parameter_t, public QosPolicy
{
friend class ParameterList;
public:
RTPS_DllAPI OwnershipStrengthQosPolicy()
: Parameter_t(PID_OWNERSHIP_STRENGTH,4),
Expand Down Expand Up @@ -889,8 +909,10 @@ class OwnershipStrengthQosPolicy : private Parameter_t, public QosPolicy {
* This QosPolicy can be defined and is transmitted to the rest of the network but is not implemented in this version.
* value: Default value 0.
*/
class TransportPriorityQosPolicy : private Parameter_t , public QosPolicy{
public:
class TransportPriorityQosPolicy : private Parameter_t , public QosPolicy
{
friend class ParameterList;
public:
uint32_t value;
RTPS_DllAPI TransportPriorityQosPolicy():Parameter_t(PID_TRANSPORT_PRIORITY,4),QosPolicy(false),value(0){};
virtual RTPS_DllAPI ~TransportPriorityQosPolicy(){};
Expand Down Expand Up @@ -935,6 +957,7 @@ typedef enum DataRepresentationId : int16_t {
*/
class DataRepresentationQosPolicy :private Parameter_t, public QosPolicy
{
friend class ParameterList;
public:
std::vector<DataRepresentationId_t> m_value;
RTPS_DllAPI DataRepresentationQosPolicy() {};
Expand All @@ -958,6 +981,7 @@ enum TypeConsistencyKind : uint32_t
*/
class TypeConsistencyEnforcementQosPolicy : private Parameter_t, public QosPolicy
{
friend class ParameterList;
public:
TypeConsistencyKind m_kind;
bool m_ignore_sequence_bounds;
Expand All @@ -981,6 +1005,7 @@ class TypeConsistencyEnforcementQosPolicy : private Parameter_t, public QosPolic
*/
class TypeIdV1 : private Parameter_t, public QosPolicy
{
friend class ParameterList;
public:
TypeIdentifier* m_type_identifier;

Expand Down Expand Up @@ -1047,6 +1072,7 @@ class TypeIdV1 : private Parameter_t, public QosPolicy
*/
class TypeObjectV1 : private Parameter_t, public QosPolicy
{
friend class ParameterList;
public:
TypeObject* m_type_object;

Expand Down
11 changes: 8 additions & 3 deletions include/fastrtps/rtps/builtin/data/ParticipantProxyData.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

#ifndef _RTPS_BUILTIN_DATA_PARTICIPANTPROXYDATA_H_
#define _RTPS_BUILTIN_DATA_PARTICIPANTPROXYDATA_H_

#ifndef DOXYGEN_SHOULD_SKIP_THIS_PUBLIC
#include <mutex>
#include "../../../qos/ParameterList.h"
Expand Down Expand Up @@ -138,29 +139,33 @@ class ParticipantProxyData
* @return True on success
*/
bool updateData(ParticipantProxyData& pdata);

/**
* Convert information to parameter list.
* Write as a parameter list on a CDRMessage_t
* @return True on success
*/
ParameterList_t AllQostoParameterList();
bool writeToCDRMessage(CDRMessage_t* msg, bool write_encapsulation);

/**
* Read the parameter list from a recevied CDRMessage_t
* @return True on success
*/
bool readFromCDRMessage(CDRMessage_t* msg, bool use_encapsulation=true);

//!Clear the data (restore to default state.)
void clear();

/**
* Copy the data from another object.
* @param pdata Object to copy the data from
*/
void copy(ParticipantProxyData& pdata);
};

}
} /* namespace rtps */
} /* namespace fastrtps */
} /* namespace eprosima */

#endif

#endif // _RTPS_BUILTIN_DATA_PARTICIPANTPROXYDATA_H_
7 changes: 4 additions & 3 deletions include/fastrtps/rtps/builtin/data/ReaderProxyData.h
Original file line number Diff line number Diff line change
Expand Up @@ -285,10 +285,11 @@ class ReaderProxyData
}

/**
* Convert the data to a parameter list to send this information as a RTPS message.
* @return Generated parameter list
* Write as a parameter list on a CDRMessage_t
* @return True on success
*/
ParameterList_t toParameterList();
bool writeToCDRMessage(CDRMessage_t* msg, bool write_encapsulation);

/**
* Read the information from a CDRMessage_t. The position of hte message must be in the beggining on the parameter list.
* @param msg Pointer to the message.
Expand Down
4 changes: 2 additions & 2 deletions include/fastrtps/rtps/builtin/data/WriterProxyData.h
Original file line number Diff line number Diff line change
Expand Up @@ -336,8 +336,8 @@ class WriterProxyData
void update(WriterProxyData* rdata);
//!Copy all information from another object.
void copy(WriterProxyData* rdata);
//!Convert the information to a parameter list to be send in a CDRMessage.
ParameterList_t toParameterList();
//!Write as a parameter list on a CDRMessage_t
bool writeToCDRMessage(CDRMessage_t* msg, bool write_encapsulation);
//!Read a parameter list from a CDRMessage_t.
RTPS_DllAPI bool readFromCDRMessage(CDRMessage_t* msg);

Expand Down
Loading