repo_id stringlengths 19 138 | file_path stringlengths 32 200 | content stringlengths 1 12.9M | __index_level_0__ int64 0 0 |
|---|---|---|---|
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/include/fastrtps/rtps/builtin | apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/include/fastrtps/rtps/builtin/data/ReaderProxyData.h | // Copyright 2016 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.
/**
* @file ReaderProxyData.h
*
*/
#ifndef READERPROXYDATA_H_
#define READERPROXYDATA_H_
#ifndef DOXYGEN_SHOULD_SKIP_THIS_PUBLIC
#include "../../../attributes/TopicAttributes.h"
#include "../../../qos/ParameterList.h"
#include "../../../qos/ReaderQos.h"
#include "../../attributes/WriterAttributes.h"
using namespace eprosima::fastrtps;
namespace eprosima {
namespace fastrtps{
namespace rtps {
struct CDRMessage_t;
/**
* Class ReaderProxyData, used to represent all the information on a Reader (both local and remote) with the purpose of
* implementing the discovery.
* *@ingroup BUILTIN_MODULE
*/
class ReaderProxyData
{
public:
ReaderProxyData();
virtual ~ReaderProxyData();
/**
* Convert the data to a parameter list to send this information as a RTPS message.
* @return true if correct.
*/
bool toParameterList();
/**
* 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.
* @return true on success
*/
bool readFromCDRMessage(CDRMessage_t* msg);
//!GUID
GUID_t m_guid;
//!
bool m_expectsInlineQos;
//!Unicast locator list
LocatorList_t m_unicastLocatorList;
//!Multicast locator list
LocatorList_t m_multicastLocatorList;
//!GUID_t of the Reader converted to InstanceHandle_t
InstanceHandle_t m_key;
//!GUID_t of the participant converted to InstanceHandle
InstanceHandle_t m_RTPSParticipantKey;
//!Type name
std::string m_typeName;
//!Topic name
std::string m_topicName;
//!User defined ID
uint16_t m_userDefinedId;
//!Reader Qos
ReaderQos m_qos;
//!Field to indicate if the Reader is Alive.
bool m_isAlive;
//!Topic kind
TopicKind_t m_topicKind;
//!Parameter list
ParameterList_t m_parameterList;
/**
* Clear (put to default) the information.
*/
void clear();
/**
* Update the information (only certain fields can be updated).
* @param rdata Poitner to the object from which we are going to update.
*/
void update(ReaderProxyData* rdata);
/**
* Copy ALL the information from another object.
* @param rdata Pointer to the object from where the information must be copied.
*/
void copy(ReaderProxyData* rdata);
/**
* Convert the ProxyData information to RemoteReaderAttributes object.
* @return Reference to the RemoteReaderAttributes object.
*/
RemoteReaderAttributes& toRemoteReaderAttributes();
//!Remote Attributes associated with this proxy data.
RemoteReaderAttributes m_remoteAtt;
};
}
} /* namespace rtps */
} /* namespace eprosima */
#endif
#endif /* READERPROXYDATA_H_ */
| 0 |
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/include/fastrtps/rtps/builtin | apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/include/fastrtps/rtps/builtin/data/WriterProxyData.h | // Copyright 2016 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.
/**
* @file WriterProxyData.h
*
*/
#ifndef WRITERPROXYDATA_H_
#define WRITERPROXYDATA_H_
#ifndef DOXYGEN_SHOULD_SKIP_THIS_PUBLIC
#include "../../../attributes/TopicAttributes.h"
#include "../../../qos/ParameterList.h"
#include "../../../qos/WriterQos.h"
#include "../../attributes/ReaderAttributes.h"
using namespace eprosima::fastrtps;
namespace eprosima {
namespace fastrtps{
namespace rtps {
struct CDRMessage_t;
/**
**@ingroup BUILTIN_MODULE
*/
class WriterProxyData
{
public:
RTPS_DllAPI WriterProxyData();
virtual RTPS_DllAPI ~WriterProxyData();
RTPS_DllAPI void guid(const GUID_t& guid)
{
m_guid = guid;
}
RTPS_DllAPI void guid(GUID_t&& guid)
{
m_guid = std::move(guid);
}
RTPS_DllAPI GUID_t guid() const
{
return m_guid;
}
RTPS_DllAPI GUID_t& guid()
{
return m_guid;
}
RTPS_DllAPI void unicastLocatorList(const LocatorList_t& unicastLocatorList)
{
m_unicastLocatorList = unicastLocatorList;
}
RTPS_DllAPI void unicastLocatorList(LocatorList_t&& unicastLocatorList)
{
m_unicastLocatorList = std::move(unicastLocatorList);
}
RTPS_DllAPI LocatorList_t unicastLocatorList() const
{
return m_unicastLocatorList;
}
RTPS_DllAPI LocatorList_t& unicastLocatorList()
{
return m_unicastLocatorList;
}
RTPS_DllAPI void multicastLocatorList(const LocatorList_t& multicastLocatorList)
{
m_multicastLocatorList = multicastLocatorList;
}
RTPS_DllAPI void multicastLocatorList(LocatorList_t&& multicastLocatorList)
{
m_multicastLocatorList = std::move(multicastLocatorList);
}
RTPS_DllAPI LocatorList_t multicastLocatorList() const
{
return m_multicastLocatorList;
}
RTPS_DllAPI LocatorList_t& multicastLocatorList()
{
return m_multicastLocatorList;
}
RTPS_DllAPI void key(const InstanceHandle_t& key)
{
m_key = key;
}
RTPS_DllAPI void key(InstanceHandle_t&& key)
{
m_key = std::move(key);
}
RTPS_DllAPI InstanceHandle_t key() const
{
return m_key;
}
RTPS_DllAPI InstanceHandle_t& key()
{
return m_key;
}
RTPS_DllAPI void RTPSParticipantKey(const InstanceHandle_t& RTPSParticipantKey)
{
m_RTPSParticipantKey = RTPSParticipantKey;
}
RTPS_DllAPI void RTPSParticipantKey(InstanceHandle_t&& RTPSParticipantKey)
{
m_RTPSParticipantKey = std::move(RTPSParticipantKey);
}
RTPS_DllAPI InstanceHandle_t RTPSParticipantKey() const
{
return m_RTPSParticipantKey;
}
RTPS_DllAPI InstanceHandle_t& RTPSParticipantKey()
{
return m_RTPSParticipantKey;
}
RTPS_DllAPI void typeName(const std::string& typeName)
{
m_typeName = typeName;
}
RTPS_DllAPI void typeName(std::string&& typeName)
{
m_typeName = std::move(typeName);
}
RTPS_DllAPI std::string typeName() const
{
return m_typeName;
}
RTPS_DllAPI std::string& typeName()
{
return m_typeName;
}
RTPS_DllAPI void topicName(const std::string& topicName)
{
m_topicName = topicName;
}
RTPS_DllAPI void topicName(std::string&& topicName)
{
m_topicName = std::move(topicName);
}
RTPS_DllAPI std::string topicName() const
{
return m_topicName;
}
RTPS_DllAPI std::string& topicName()
{
return m_topicName;
}
RTPS_DllAPI void userDefinedId(uint16_t userDefinedId)
{
m_userDefinedId = userDefinedId;
}
RTPS_DllAPI uint16_t userDefinedId() const
{
return m_userDefinedId;
}
RTPS_DllAPI uint16_t& userDefinedId()
{
return m_userDefinedId;
}
RTPS_DllAPI void typeMaxSerialized(uint32_t typeMaxSerialized)
{
m_typeMaxSerialized = typeMaxSerialized;
}
RTPS_DllAPI uint32_t typeMaxSerialized() const
{
return m_typeMaxSerialized;
}
RTPS_DllAPI uint32_t& typeMaxSerialized()
{
return m_typeMaxSerialized;
}
RTPS_DllAPI void isAlive(bool isAlive)
{
m_isAlive = isAlive;
}
RTPS_DllAPI bool isAlive() const
{
return m_isAlive;
}
RTPS_DllAPI bool& isAlive()
{
return m_isAlive;
}
RTPS_DllAPI void topicKind(TopicKind_t topicKind)
{
m_topicKind = topicKind;
}
RTPS_DllAPI TopicKind_t topicKind() const
{
return m_topicKind;
}
RTPS_DllAPI TopicKind_t& topicKind()
{
return m_topicKind;
}
//!WriterQOS
WriterQos m_qos;
//!
ParameterList_t m_parameterList;
//!Clear the information and return the object to the default state.
void clear();
//!Update certain parameters from another object.
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.
bool toParameterList();
//!Read a parameter list from a CDRMessage_t.
RTPS_DllAPI bool readFromCDRMessage(CDRMessage_t* msg);
/**
* Convert the ProxyData information to RemoteWriterAttributes object.
* @return Reference to the RemoteWriterAttributes object.
*/
RemoteWriterAttributes& toRemoteWriterAttributes();
//!Remote Attributes associated with this proxy data.
RemoteWriterAttributes m_remoteAtt;
private:
//!GUID
GUID_t m_guid;
//!Unicast locator list
LocatorList_t m_unicastLocatorList;
//!Multicast locator list
LocatorList_t m_multicastLocatorList;
//!GUID_t of the Writer converted to InstanceHandle_t
InstanceHandle_t m_key;
//!GUID_t of the participant converted to InstanceHandle
InstanceHandle_t m_RTPSParticipantKey;
//!Type name
std::string m_typeName;
//!Topic name
std::string m_topicName;
//!User defined ID
uint16_t m_userDefinedId;
//!Maximum size of the type associated with this Wrtiter, serialized.
uint32_t m_typeMaxSerialized;
//!Indicates if the Writer is Alive.
bool m_isAlive;
//!Topic kind
TopicKind_t m_topicKind;
};
}
} /* namespace rtps */
} /* namespace eprosima */
#endif
#endif /* WRITERPROXYDATA_H_ */
| 0 |
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/include/fastrtps | apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/include/fastrtps/attributes/SubscriberAttributes.h | // Copyright 2016 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.
/**
* @file SubscriberAttributes.h
*/
#ifndef SUBSCRIBERATTRIBUTES_H_
#define SUBSCRIBERATTRIBUTES_H_
#include <fastrtps/rtps/resources/ResourceManagement.h>
#include "../rtps/common/Time_t.h"
#include "../rtps/common/Locator.h"
#include "../rtps/attributes/ReaderAttributes.h"
#include "TopicAttributes.h"
#include "../qos/ReaderQos.h"
#include "../rtps/attributes/PropertyPolicy.h"
using namespace eprosima::fastrtps::rtps;
namespace eprosima {
namespace fastrtps {
/**
* Class SubscriberAttributes, used by the user to define the attributes of a Subscriber.
* @ingroup FASTRTPS_ATTRIBUTES_MODULE
*/
class SubscriberAttributes {
public:
SubscriberAttributes()
{
m_userDefinedID = -1;
m_entityID = -1;
expectsInlineQos = false;
historyMemoryPolicy = PREALLOCATED_MEMORY_MODE;
};
virtual ~SubscriberAttributes(){};
//!Topic Attributes
TopicAttributes topic;
//!Reader QOs.
ReaderQos qos;
//!Times for a RELIABLE Reader
ReaderTimes times;
//!Unicast locator list
LocatorList_t unicastLocatorList;
//!Multicast locator list
LocatorList_t multicastLocatorList;
//!Output locator list
LocatorList_t outLocatorList;
//!Expects Inline QOS
bool expectsInlineQos;
//!Underlying History memory policy
MemoryManagementPolicy_t historyMemoryPolicy;
PropertyPolicy properties;
/**
* Get the user defined ID
* @return User defined ID
*/
inline int16_t getUserDefinedID() const {return m_userDefinedID;}
/**
* Get the entity defined ID
* @return Entity ID
*/
inline int16_t getEntityID() const {return m_entityID;}
/**
* Set the user defined ID
* @param id User defined ID to be set
*/
inline void setUserDefinedID(uint8_t id){m_userDefinedID = id; };
/**
* Set the entity ID
* @param id Entity ID to be set
*/
inline void setEntityID(uint8_t id){m_entityID = id; };
private:
//!User Defined ID, used for StaticEndpointDiscovery, default value -1.
int16_t m_userDefinedID;
//!Entity ID, if the user want to specify the EntityID of the enpoint, default value -1.
int16_t m_entityID;
};
} /* namespace fastrtps */
} /* namespace eprosima */
#endif /* SUBSCRIBERPARAMS_H_ */
| 0 |
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/include/fastrtps | apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/include/fastrtps/attributes/ParticipantAttributes.h | // Copyright 2016 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.
/**
* @file ParticipantAttributes.h
*
*/
#ifndef PARTICIPANTATTRIBUTES_H_
#define PARTICIPANTATTRIBUTES_H_
#include "../rtps/attributes/RTPSParticipantAttributes.h"
using namespace eprosima::fastrtps::rtps;
namespace eprosima{
namespace fastrtps{
/**
* Class ParticipantAttributes, used by the user to define the attributes of a Participant.
* The Participants in the Publisher-Subscriber layer are only a container to a RTPSParticipant, so their attributes are the same.
* Still to maintain the equivalence this class is used to define them.
* @ingroup FASTRTPS_ATTRIBUTES_MODULE
*/
class ParticipantAttributes
{
public:
ParticipantAttributes(){};
virtual ~ParticipantAttributes(){};
//!Attributes of the associated RTPSParticipant.
RTPSParticipantAttributes rtps;
};
}
}
#endif /* PARTICIPANTATTRIBUTES_H_ */
| 0 |
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/include/fastrtps | apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/include/fastrtps/attributes/TopicAttributes.h | // Copyright 2016 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.
/**
* @file TopicAttributes.h
*/
#ifndef TOPICPARAMETERS_H_
#define TOPICPARAMETERS_H_
#include <string>
#include "../rtps/common/Types.h"
#include "../qos/QosPolicies.h"
#include "../log/Log.h"
using namespace eprosima::fastrtps::rtps;
namespace eprosima {
namespace fastrtps{
/**
* Class TopicAttributes, used by the user to define the attributes of the topic associated with a Publisher or Subscriber.
* @ingroup FASTRTPS_ATTRIBUTES_MODULE
*/
class TopicAttributes
{
public:
/**
* Default constructor
*/
TopicAttributes()
{
topicKind = NO_KEY;
topicName = "UNDEF";
topicDataType = "UNDEF";
}
//!Constructor, you need to provide the topic name and the topic data type.
TopicAttributes(const char* name, const char* dataType, TopicKind_t tKind= NO_KEY)
{
topicKind = tKind;
topicName = std::string(name);
topicDataType = std::string(dataType);
}
virtual ~TopicAttributes() {
}
/**
* Get the topic data type
* @return Topic data type
*/
const std::string& getTopicDataType() const {
return topicDataType;
}
/**
* Get the topic kind
* @return Topic kind
*/
TopicKind_t getTopicKind() const {
return topicKind;
}
/**
* Get the topic name
* @return Topic name
*/
const std::string& getTopicName() const {
return topicName;
}
//! TopicKind_t, default value NO_KEY.
TopicKind_t topicKind;
//! Topic Name.
std::string topicName;
//!Topic Data Type.
std::string topicDataType;
//!QOS Regarding the History to be saved.
HistoryQosPolicy historyQos;
//!QOS Regarding the resources to allocate.
ResourceLimitsQosPolicy resourceLimitsQos;
/**
* Method to check whether the defined QOS are correct.
* @return True if they are valid.
*/
bool checkQos()
{
if(resourceLimitsQos.max_samples_per_instance > resourceLimitsQos.max_samples && topicKind == WITH_KEY)
{
logError(RTPS_QOS_CHECK,"INCORRECT TOPIC QOS ("<< topicName <<"):max_samples_per_instance must be <= than max_samples");
return false;
}
if(resourceLimitsQos.max_samples_per_instance*resourceLimitsQos.max_instances > resourceLimitsQos.max_samples && topicKind == WITH_KEY)
logWarning(RTPS_QOS_CHECK,"TOPIC QOS: max_samples < max_samples_per_instance*max_instances");
if(historyQos.kind == KEEP_LAST_HISTORY_QOS)
{
if(historyQos.depth > resourceLimitsQos.max_samples)
{
logError(RTPS_QOS_CHECK,"INCORRECT TOPIC QOS ("<< topicName <<"): depth must be <= max_samples");
return false;
}
if(historyQos.depth > resourceLimitsQos.max_samples_per_instance && topicKind == WITH_KEY)
{
logError(RTPS_QOS_CHECK,"INCORRECT TOPIC QOS ("<< topicName <<"): depth must be <= max_samples_per_instance");
return false;
}
if(historyQos.depth <=0 )
{
logError(RTPS_QOS_CHECK,"INCORRECT TOPIC QOS ("<< topicName <<"): depth must be > 0");
return false;
}
}
if(resourceLimitsQos.max_samples != 0 && resourceLimitsQos.allocated_samples > resourceLimitsQos.max_samples)
{
logError(RTPS_QOS_CHECK,"INCORRECT TOPIC QOS ("<< topicName <<"): max_samples < allocated_samples");
return false;
}
return true;
}
};
#ifndef DOXYGEN_SHOULD_SKIP_THIS_PUBLIC
/**
* Check if two topic attributes are not equal
* @param t1 First instance of TopicAttributes to compare
* @param t2 Second instance of TopicAttributes to compare
* @return True if the instances are not equal. False if the instances are equal.
*/
bool inline operator!=(TopicAttributes& t1, TopicAttributes& t2)
{
if(t1.topicKind != t2.topicKind)
{
return true;
}
if(t1.topicName != t2.topicName)
{
return true;
}
if(t1.topicDataType != t2.topicDataType)
{
return true;
}
if(t1.historyQos.kind != t2.historyQos.kind)
{
return true;
}
if(t1.historyQos.kind == KEEP_LAST_HISTORY_QOS && t1.historyQos.depth != t2.historyQos.depth)
{
return true;
}
return false;
}
#endif
} /* namespace fastrtps */
} /* namespace eprosima */
#endif /* TOPICPARAMETERS_H_ */
| 0 |
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/include/fastrtps | apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/include/fastrtps/attributes/PublisherAttributes.h | // Copyright 2016 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.
/**
* @file PublisherAttributes.h
*/
#ifndef PUBLISHERATTRIBUTES_H_
#define PUBLISHERATTRIBUTES_H_
#include <fastrtps/rtps/resources/ResourceManagement.h>
#include "../rtps/common/Locator.h"
#include "../rtps/common/Time_t.h"
#include "../rtps/attributes/WriterAttributes.h"
#include <fastrtps/rtps/flowcontrol/ThroughputControllerDescriptor.h>
#include "TopicAttributes.h"
#include "../qos/WriterQos.h"
#include "../rtps/attributes/PropertyPolicy.h"
using namespace eprosima::fastrtps::rtps;
namespace eprosima {
namespace fastrtps{
/**
* Class PublisherAttributes, used by the user to define the attributes of a Publisher.
* @ingroup FASTRTPS_ATTRIBUTES_MODULE
*/
class PublisherAttributes {
public:
PublisherAttributes(){
m_userDefinedID = -1;
m_entityID = -1;
historyMemoryPolicy = PREALLOCATED_MEMORY_MODE;
};
virtual ~PublisherAttributes(){};
//!Topic Attributes for the Publisher
TopicAttributes topic;
//!QOS for the Publisher
WriterQos qos;
//!Writer Attributes
WriterTimes times;
//!Unicast locator list
LocatorList_t unicastLocatorList;
//!Multicast locator list
LocatorList_t multicastLocatorList;
//!Output locator list
LocatorList_t outLocatorList;
//!Throughput controller
ThroughputControllerDescriptor throughputController;
//!Underlying History memory policy
MemoryManagementPolicy_t historyMemoryPolicy;
PropertyPolicy properties;
/**
* Get the user defined ID
* @return User defined ID
*/
inline int16_t getUserDefinedID() const {return m_userDefinedID;}
/**
* Get the entity defined ID
* @return Entity ID
*/
inline int16_t getEntityID() const {return m_entityID;}
/**
* Set the user defined ID
* @param id User defined ID to be set
*/
inline void setUserDefinedID(uint8_t id){m_userDefinedID = id; };
/**
* Set the entity ID
* @param id Entity ID to be set
*/
inline void setEntityID(uint8_t id){m_entityID = id; };
private:
//!User Defined ID, used for StaticEndpointDiscovery, default value -1.
int16_t m_userDefinedID;
//!Entity ID, if the user want to specify the EntityID of the enpoint, default value -1.
int16_t m_entityID;
};
}
} /* namespace eprosima */
#endif /* PUBLISHERATTRIBUTES_H_ */
| 0 |
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/include/fastrtps | apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/include/fastrtps/attributes/all_attributes.h | // Copyright 2016 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.
/**
* @file all_attributes.h
*/
#ifndef ALL_ATTRIBUTES_H_
#define ALL_ATTRIBUTES_H_
#include "ParticipantAttributes.h"
#include "PublisherAttributes.h"
#include "SubscriberAttributes.h"
#include "TopicAttributes.h"
#endif /* ALL_ATTRIBUTES_H_ */
| 0 |
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/include/fastrtps | apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/include/fastrtps/log/Colors.h | // Copyright 2016 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.
/**
* @file Colors.h
*/
#ifndef _FASTRTPS_LOG_COLORS_H_
#define _FASTRTPS_LOG_COLORS_H_
#if defined(_WIN32)
#define C_DEF ""
#define C_RED ""
#define C_B_RED ""
#define C_GREEN ""
#define C_B_GREEN ""
#define C_YELLOW ""
#define C_B_YELLOW ""
#define C_BLUE ""
#define C_B_BLUE ""
#define C_MAGENTA ""
#define C_B_MAGENTA ""
#define C_CYAN ""
#define C_B_CYAN ""
#define C_WHITE ""
#define C_B_WHITE ""
#define C_BRIGHT ""
#else
#define C_DEF "\033[m"
#define C_RED "\033[31m"
#define C_B_RED "\033[31;1m"
#define C_GREEN "\033[32m"
#define C_B_GREEN "\033[32;1m"
#define C_YELLOW "\033[33m"
#define C_B_YELLOW "\033[33;1m"
#define C_BLUE "\033[34m"
#define C_B_BLUE "\033[34;1m"
#define C_MAGENTA "\033[35m"
#define C_B_MAGENTA "\033[35;1m"
#define C_CYAN "\033[36m"
#define C_B_CYAN "\033[36;1m"
#define C_WHITE "\033[37m"
#define C_B_WHITE "\033[37;1m"
#define C_BRIGHT "\033[1m"
#endif
#endif /* _FASTRTPS_LOG_COLORS_H_ */
| 0 |
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/include/fastrtps | apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/include/fastrtps/log/Log.h |
// Copyright 2016 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 _FASTRTPS_LOG_LOG_H_
#define _FASTRTPS_LOG_LOG_H_
#include <fastrtps/utils/DBQueue.h>
#include <fastrtps/fastrtps_dll.h>
#include <thread>
#include <sstream>
#include <atomic>
#include <regex>
/**
* eProsima log layer. Logging categories and verbosities can be specified dynamically at runtime. However, even on a category
* not covered by the current verbosity level, there is some overhead on calling a log macro. For maximum performance, you can
* opt out of logging any particular level by defining the following symbols:
*
* * #define LOG_NO_ERROR
* * #define LOG_NO_WARNING
* * #define LOG_NO_INFO
*
* Additionally. the lowest level (Info) is disabled by default on release branches.
*/
// Logging API:
//! Logs an info message. Disable it through Log::SetVerbosity, #define LOG_NO_INFO, or being in a release branch
#define logInfo(cat,msg) logInfo_(cat,msg)
//! Logs a warning. Disable reporting through Log::SetVerbosity or #define LOG_NO_WARNING
#define logWarning(cat,msg) logWarning_(cat,msg)
//! Logs an error. Disable reporting through #define LOG_NO_ERROR
#define logError(cat,msg) logError_(cat,msg)
namespace eprosima {
namespace fastrtps {
class LogConsumer;
/**
* Logging utilities.
* Logging is accessed through the three macros above, and configuration on the log output
* can be achieved through static methods on the class. Logging at various levels can be
* disabled dynamically (through the Verbosity level) or statically (through the LOG_NO_[VERB]
* macros) for maximum performance.
* @ingroup COMMON_MODULE
*/
class Log
{
public:
/**
* Types of log entry.
* * Error: Maximum priority. Can only be disabled statically through #define LOG_NO_ERROR.
* * Warning: Medium priority. Can be disabled statically and dynamically.
* * Info: Low priority. Useful for debugging. Disabled by default on release branches.
*/
enum Kind {
Error,
Warning,
Info,
};
/**
* Registers an user defined consumer to route log output. There is a default
* stdout consumer active at all times.
*/
RTPS_DllAPI static void RegisterConsumer(std::unique_ptr<LogConsumer>);
//! Enables the reporting of filenames in log entries. Disabled by default.
RTPS_DllAPI static void ReportFilenames(bool);
//! Enables the reporting of function names in log entries. Enabled by default when supported.
RTPS_DllAPI static void ReportFunctions(bool);
//! Sets the verbosity level, allowing for messages equal or under that priority to be logged.
RTPS_DllAPI static void SetVerbosity(Log::Kind);
//! Returns the current verbosity level.
RTPS_DllAPI static Log::Kind GetVerbosity();
//! Sets a filter that will pattern-match against log categories, dropping any unmatched categories.
RTPS_DllAPI static void SetCategoryFilter (const std::regex&);
//! Sets a filter that will pattern-match against filenames, dropping any unmatched categories.
RTPS_DllAPI static void SetFilenameFilter (const std::regex&);
//! Sets a filter that will pattern-match against the provided error string, dropping any unmatched categories.
RTPS_DllAPI static void SetErrorStringFilter (const std::regex&);
//! Returns the logging engine to configuration defaults.
RTPS_DllAPI static void Reset();
//! Stops the logging thread. It will re-launch on the next call to a successful log macro.
RTPS_DllAPI static void KillThread();
// Note: In VS2013, if you're linking this class statically, you will have to call KillThread before leaving
// main, due to an unsolved MSVC bug.
struct Context {
const char* filename;
int line;
const char* function;
const char* category;
};
struct Entry
{
std::string message;
Log::Context context;
Log::Kind kind;
};
/**
* Not recommended to call this method directly! Use the following macros:
* * logInfo(cat, msg);
* * logWarning(cat, msg);
* * logError(cat, msg);
*/
RTPS_DllAPI static void QueueLog(const std::string& message, const Log::Context&, Log::Kind);
private:
struct Resources
{
DBQueue<Entry> mLogs;
std::vector<std::unique_ptr<LogConsumer> > mConsumers;
std::unique_ptr<LogConsumer> mDefaultConsumer;
std::unique_ptr<std::thread> mLoggingThread;
// Condition variable segment.
std::condition_variable mCv;
std::mutex mCvMutex;
bool mLogging;
bool mWork;
// Context configuration.
std::mutex mConfigMutex;
bool mFilenames;
bool mFunctions;
std::unique_ptr<std::regex> mCategoryFilter;
std::unique_ptr<std::regex> mFilenameFilter;
std::unique_ptr<std::regex> mErrorStringFilter;
std::atomic<Log::Kind> mVerbosity;
Resources();
~Resources();
};
static struct Resources mResources;
// Applies transformations to the entries compliant with the options selected (such as
// erasure of certain context information, or filtering by category. Returns false
// if the log entry is blacklisted.
static bool Preprocess(Entry&);
static void LaunchThread();
static void Run();
};
/**
* Consumes a log entry to output it somewhere.
*/
class LogConsumer {
public:
virtual ~LogConsumer(){};
virtual void Consume(const Log::Entry&) = 0;
};
#if defined ( WIN32 )
#define __func__ __FUNCTION__
#endif
#ifndef LOG_NO_ERROR
#define logError_(cat, msg) {std::stringstream ss; ss << msg; Log::QueueLog(ss.str(), Log::Context{__FILE__, __LINE__, __func__, #cat}, Log::Kind::Error); }
#else
#define logError_(cat, msg)
#endif
#ifndef LOG_NO_WARNING
#define logWarning_(cat, msg) { if (Log::GetVerbosity() >= Log::Kind::Warning) { std::stringstream ss; ss << msg; Log::QueueLog(ss.str(), Log::Context{__FILE__, __LINE__, __func__, #cat}, Log::Kind::Warning); } }
#else
#define logWarning_(cat, msg)
#endif
#define COMPOSITE_LOG_NO_INFO (defined(__INTERNALDEBUG) || defined(_INTERNALDEBUG)) && (defined(_DEBUG) || defined(__DEBUG)) && (!defined(LOG_NO_INFO))
#if COMPOSITE_LOG_NO_INFO
#define logInfo_(cat, msg) { if (Log::GetVerbosity() >= Log::Kind::Info) { std::stringstream ss; ss << msg; Log::QueueLog(ss.str(), Log::Context{__FILE__, __LINE__, __func__, #cat}, Log::Kind::Info); } }
#else
#define logInfo_(cat, msg)
#endif
} // namespace fastrtps
} // namespace eprosima
#endif
| 0 |
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/include/fastrtps | apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/include/fastrtps/log/StdoutConsumer.h | // Copyright 2016 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 STDOUT_CONSUMER_H
#define STDOUT_CONSUMER_H
#include <fastrtps/log/Log.h>
namespace eprosima {
namespace fastrtps {
class StdoutConsumer: public LogConsumer {
public:
RTPS_DllAPI virtual void Consume(const Log::Entry&);
private:
void PrintHeader(const Log::Entry&) const;
void PrintContext(const Log::Entry&) const;
};
} // namespace fastrtps
} // namespace eprosima
#endif
| 0 |
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/include/fastrtps | apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/include/fastrtps/subscriber/Subscriber.h | // Copyright 2016 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.
/**
* @file Subscriber.h
*/
#ifndef SUBSCRIBER_H_
#define SUBSCRIBER_H_
#include "../rtps/common/Guid.h"
#include "../attributes/SubscriberAttributes.h"
using namespace eprosima::fastrtps::rtps;
namespace eprosima {
namespace fastrtps{
class SubscriberImpl;
class SampleInfo_t;
/**
* Class Subscriber, contains the public API that allows the user to control the reception of messages.
* This class should not be instantiated directly. DomainRTPSParticipant class should be used to correctly create this element.
* @ingroup FASTRTPS_MODULE
* @snippet fastrtps_example.cpp ex_Subscriber
*/
class RTPS_DllAPI Subscriber
{
friend class SubscriberImpl;
virtual ~Subscriber(){};
public:
/**
* @param pimpl Actual implementation of the subscriber
*/
Subscriber(SubscriberImpl* pimpl):mp_impl(pimpl){};
/**
* Get the associated GUID
* @return Associated GUID
*/
const GUID_t& getGuid();
/**
* Method to block the current thread until an unread message is available
*/
void waitForUnreadMessage();
/**
* Read next unread Data from the Subscriber.
* @param data Pointer to the object where you want the data stored.
* @param info Pointer to a SampleInfo_t structure that informs you about your sample.
* @return True if a sample was read.
*/
bool readNextData(void* data,SampleInfo_t* info);
/**
* Take next Data from the Subscriber. The data is removed from the subscriber.
* @param data Pointer to the object where you want the data stored.
* @param info Pointer to a SampleInfo_t structure that informs you about your sample.
* @return True if a sample was taken.
*/
bool takeNextData(void* data,SampleInfo_t* info);
/**
* Update the Attributes of the subscriber;
* @param att Reference to a SubscriberAttributes object to update the parameters;
* @return True if correctly updated, false if ANY of the updated parameters cannot be updated
*/
bool updateAttributes(SubscriberAttributes& att);
/**
* Get the Attributes of the Subscriber.
* @return Attributes of the subscriber
*/
SubscriberAttributes getAttributes();
/*!
* @brief Returns there is a clean state with all Publishers.
* It occurs when the Subscriber received all samples sent by Publishers. In other words,
* its WriterProxies are up to date.
* @return There is a clean state with all Publishers.
*/
bool isInCleanState() const;
private:
SubscriberImpl* mp_impl;
};
} /* namespace pubsub */
} /* namespace eprosima */
#endif /* SUBSCRIBER_H_ */
| 0 |
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/include/fastrtps | apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/include/fastrtps/subscriber/SubscriberHistory.h | // Copyright 2016 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.
/**
* @file SubscriberHistory.h
*
*/
#ifndef SUBSCRIBERHISTORY_H_
#define SUBSCRIBERHISTORY_H_
#ifndef DOXYGEN_SHOULD_SKIP_THIS_PUBLIC
#include <fastrtps/rtps/resources/ResourceManagement.h>
#include "../rtps/history/ReaderHistory.h"
#include "../qos/QosPolicies.h"
#include "SampleInfo.h"
using namespace eprosima::fastrtps::rtps;
namespace eprosima {
namespace fastrtps {
namespace rtps{
class WriterProxy;
}
using namespace rtps;
class SubscriberImpl;
/**
* Class SubscriberHistory, container of the different CacheChanges of a subscriber
* @ingroup FASTRTPS_MODULE
*/
class SubscriberHistory: public ReaderHistory {
public:
typedef std::pair<InstanceHandle_t,std::vector<CacheChange_t*>> t_p_I_Change;
typedef std::vector<t_p_I_Change> t_v_Inst_Caches;
/**
* Constructor. Requires information about the subscriner
* @param pimpl Pointer to the subscriber implementation
* @param payloadMax Maximum payload size per change
* @param history History QoS policy for the reader
* @param resource Resource Limit QoS policy for the reader
*/
SubscriberHistory(SubscriberImpl* pimpl,uint32_t payloadMax,
HistoryQosPolicy& history,ResourceLimitsQosPolicy& resource, MemoryManagementPolicy_t mempolicy);
virtual ~SubscriberHistory();
/**
* Called when a change is received by the Subscriber History. Will add the change to the history
* if it wasn't already present
* @param[in] change The received change
* @param unknown_missing_changes_up_to Number of missing changes before this one
* @return
*/
bool received_change(CacheChange_t* change, size_t unknown_missing_changes_up_to);
/** @name Read or take data methods.
* Methods to read or take data from the History.
* @param data Pointer to the object where you want to read or take the information.
* @param info Pointer to a SampleInfo_t object where you want
* to store the information about the retrieved data
*/
///@{
bool readNextData(void* data, SampleInfo_t* info);
bool takeNextData(void* data, SampleInfo_t* info);
///@}
/**
* Method to know whether there are unread CacheChange_t.
* @return True if there are any unread changes.
*/
bool isUnreadCache();
/**
* This method is called to remove a change from the SubscriberHistory.
* @param change Pointer to the CacheChange_t.
* @param vit Pointer to the iterator of the key-ordered cacheChange vector.
* @return True if removed.
*/
bool remove_change_sub(CacheChange_t* change,t_v_Inst_Caches::iterator* vit=nullptr);
//!Increase the unread count.
inline void increaseUnreadCount()
{
++m_unreadCacheCount;
}
//!Decrease the unread count.
inline void decreaseUnreadCount()
{
if(m_unreadCacheCount>0)
--m_unreadCacheCount;
}
/** Get the unread count.
* @return Unread count
*/
inline uint64_t getUnreadCount()
{
return m_unreadCacheCount;
}
private:
//!Number of unread CacheChange_t.
uint64_t m_unreadCacheCount;
//!Vector of pointer to the CacheChange_t divided by key.
t_v_Inst_Caches m_keyedChanges;
//!HistoryQosPolicy values.
HistoryQosPolicy m_historyQos;
//!ResourceLimitsQosPolicy values.
ResourceLimitsQosPolicy m_resourceLimitsQos;
//!Publisher Pointer
SubscriberImpl* mp_subImpl;
//!Type object to deserialize Key
void * mp_getKeyObject;
bool find_Key(CacheChange_t* a_change,t_v_Inst_Caches::iterator* vecPairIterrator);
};
} /* namespace fastrtps */
} /* namespace eprosima */
#endif
#endif /* SUBSCRIBERHISTORY_H_ */
| 0 |
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/include/fastrtps | apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/include/fastrtps/subscriber/SubscriberListener.h | // Copyright 2016 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.
/**
* @file SubscriberListener.h
*/
#ifndef SUBLISTENER_H_
#define SUBLISTENER_H_
#include "../rtps/common/MatchingInfo.h"
using namespace eprosima::fastrtps::rtps;
namespace eprosima {
namespace fastrtps {
class Subscriber;
/**
* Class SubscriberListener, it should be used by the end user to implement specific callbacks to certain actions.
* @ingroup FASTRTPS_MODULE
* @snippet fastrtps_example.cpp ex_SubscriberListener
*/
class RTPS_DllAPI SubscriberListener {
public:
SubscriberListener(){};
virtual ~SubscriberListener(){};
/**
* Virtual function to be implemented by the user containing the actions to be performed when a new Data Message is received.
* @param sub Subscriber
*/
virtual void onNewDataMessage(Subscriber * sub){(void) sub;};
/**
* Virtual method to be called when the subscriber is matched with a new Writer (or unmatched); i.e., when a writer publishing in the same topic is discovered.
* @param sub Subscriber
* @param info Matching information
*/
virtual void onSubscriptionMatched(Subscriber* sub, MatchingInfo& info){(void)sub; (void)info;};
};
} /* namespace pubsub */
} /* namespace eprosima */
#endif /* LISTENER_H_ */
| 0 |
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/include/fastrtps | apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/include/fastrtps/subscriber/SampleInfo.h | // Copyright 2016 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.
/**
* @file SampleInfo.h
*/
#ifndef SAMPLEINFO_H_
#define SAMPLEINFO_H_
#include <cstdint>
#include "../fastrtps_dll.h"
#include "../rtps/common/Time_t.h"
#include "../rtps/common/InstanceHandle.h"
#include "../rtps/common/CacheChange.h"
namespace eprosima {
namespace fastrtps {
/**
* Class SampleInfo_t with information that is provided along a sample when reading data from a Subscriber.
* @ingroup FASTRTPS_MODULE
*/
class RTPS_DllAPI SampleInfo_t {
public:
SampleInfo_t():sampleKind(ALIVE), ownershipStrength(0),
sample_identity(SampleIdentity::unknown()), related_sample_identity(SampleIdentity::unknown()) {}
virtual ~SampleInfo_t(){};
//!Sample kind.
ChangeKind_t sampleKind;
//!Ownership Strength of the writer of the sample (0 if the ownership kind is set to SHARED_OWNERSHIP_QOS).
uint16_t ownershipStrength;
//!Source timestamp of the sample.
Time_t sourceTimestamp;
//!InstanceHandle of the data
InstanceHandle_t iHandle;
SampleIdentity sample_identity;
SampleIdentity related_sample_identity;
};
} /* namespace */
} /* namespace eprosima */
#endif /* SAMPLEINFO_H_ */
| 0 |
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/include | apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/include/fastcdr/FastCdr.h | // Copyright 2016 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 _FASTCDR_FASTCDR_H_
#define _FASTCDR_FASTCDR_H_
#include "fastcdr_dll.h"
#include "FastBuffer.h"
#include "exceptions/NotEnoughMemoryException.h"
#include <stdint.h>
#include <string>
#include <vector>
#if !__APPLE__
#include <malloc.h>
#else
#include <stdlib.h>
#endif
#if HAVE_CXX0X
#include <array>
#endif
namespace eprosima
{
namespace fastcdr
{
/*!
* @brief This class offers an interface to serialize/deserialize some basic types using a modified CDR protocol inside a eprosima::FastBuffer.
* This modified CDR protocol provides a serialization mechanism much faster than common CDR protocol, because it doesn't use alignment.
* @ingroup FASTCDRAPIREFERENCE
*/
class Cdr_DllAPI FastCdr
{
public:
/*!
* @brief This class stores the current state of a CDR serialization.
*/
class Cdr_DllAPI state
{
friend class FastCdr;
public:
/*!
* @brief Default constructor.
*/
state(const FastCdr &fastcdr);
/*!
* @brief Copy constructor.
*/
state(const state&);
private:
state& operator=(const state&) NON_COPYABLE_CXX11;
//! @brief The position in the buffer when the state was created.
const FastBuffer::iterator m_currentPosition;
};
/*!
* @brief This constructor creates a eprosima::fastcdr::FastCdr object that can serialize/deserialize
* the assigned buffer.
*
* @param cdrBuffer A reference to the buffer that contains (or will contain) the CDR representation.
*/
FastCdr(FastBuffer &cdrBuffer);
/*!
* @brief This function skips a number of bytes in the CDR stream buffer.
* @param numBytes The number of bytes that will be jumped.
* @return True is returned when the jump operation works successfully. Otherwise, false is returned.
*/
bool jump(size_t numBytes);
/*!
* @brief This function resets the current position in the buffer to the begining.
*/
void reset();
/*!
* @brief This function returns the current position in the CDR stream.
* @return Pointer to the current position in the buffer.
*/
char* getCurrentPosition();
/*!
* @brief This function returns the length of the serialized data inside the stream.
* @return The length of the serialized data.
*/
inline size_t getSerializedDataLength() const { return m_currentPosition - m_cdrBuffer.begin();}
/*!
* @brief This function returns the current state of the CDR stream.
* @return The current state of the buffer.
*/
FastCdr::state getState();
/*!
* @brief This function sets a previous state of the CDR stream;
* @param state Previous state that will be set again.
*/
void setState(FastCdr::state &state);
/*!
* @brief This operator serializes an octet.
* @param octet_t The value of the octet that will be serialized in the buffer.
* @return Reference to the eprosima::fastcdr::FastCdr object.
* @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize in a position that exceeds the internal memory size.
*/
inline FastCdr& operator<<(const uint8_t octet_t){return serialize(octet_t);}
/*!
* @brief This operator serializes a character.
* @param char_t The value of the character that will be serialized in the buffer.
* @return Reference to the eprosima::fastcdr::FastCdr object.
* @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize in a position that exceeds the internal memory size.
*/
inline FastCdr& operator<<(const char char_t){return serialize(char_t);}
/*!
* @brief This operator serializes an unsigned short.
* @param ushort_t The value of the unsigned short that will be serialized in the buffer.
* @return Reference to the eprosima::fastcdr::FastCdr object.
* @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize in a position that exceeds the internal memory size.
*/
inline FastCdr& operator<<(const uint16_t ushort_t){return serialize(ushort_t);}
/*!
* @brief This operator serializes a short.
* @param short_t The value of the short that will be serialized in the buffer.
* @return Reference to the eprosima::fastcdr::FastCdr object.
* @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize in a position that exceeds the internal memory size.
*/
inline FastCdr& operator<<(const int16_t short_t){return serialize(short_t);}
/*!
* @brief This operator serializes an unsigned long.
* @param ulong_t The value of the unsigned long that will be serialized in the buffer.
* @return Reference to the eprosima::fastcdr::FastCdr object.
* @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize in a position that exceeds the internal memory size.
*/
inline FastCdr& operator<<(const uint32_t ulong_t){return serialize(ulong_t);}
/*!
* @brief This operator serializes a long.
* @param ulong_t The value of the long that will be serialized in the buffer.
* @return Reference to the eprosima::fastcdr::FastCdr object.
* @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize in a position that exceeds the internal memory size.
*/
inline FastCdr& operator<<(const int32_t long_t){return serialize(long_t);}
// TODO in FastCdr
inline FastCdr& operator<<(const wchar_t wchar){return serialize(wchar);}
/*!
* @brief This operator serializes an unsigned long long.
* @param ulonglong_t The value of the unsigned long long that will be serialized in the buffer.
* @return Reference to the eprosima::fastcdr::FastCdr object.
* @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize in a position that exceeds the internal memory size.
*/
inline FastCdr& operator<<(const uint64_t ulonglong_t){return serialize(ulonglong_t);}
/*!
* @brief This operator serializes a long long.
* @param longlong_t The value of the long long that will be serialized in the buffer.
* @return Reference to the eprosima::fastcdr::FastCdr object.
* @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize in a position that exceeds the internal memory size.
*/
inline FastCdr& operator<<(const int64_t longlong_t){return serialize(longlong_t);}
/*!
* @brief This operator serializes a float.
* @param float_t The value of the float that will be serialized in the buffer.
* @return Reference to the eprosima::fastcdr::FastCdr object.
* @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize in a position that exceeds the internal memory size.
*/
inline FastCdr& operator<<(const float float_t){return serialize(float_t);}
/*!
* @brief This operator serializes a double.
* @param double_t The value of the double that will be serialized in the buffer.
* @return Reference to the eprosima::fastcdr::FastCdr object.
* @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize in a position that exceeds the internal memory size.
*/
inline FastCdr& operator<<(const double double_t){return serialize(double_t);}
/*!
* @brief This operator serializes a boolean.
* @param bool_t The value of the boolean that will be serialized in the buffer.
* @return Reference to the eprosima::fastcdr::FastCdr object.
* @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize in a position that exceeds the internal memory size.
*/
inline FastCdr& operator<<(const bool bool_t){return serialize(bool_t);}
//TODO
inline FastCdr& operator<<(const char *string_t){return serialize(string_t);}
//TODO
inline FastCdr& operator<<(char *string_t){return serialize(string_t);}
/*!
* @brief This operator serializes a string.
* @param string_t The string that will be serialized in the buffer.
* @return Reference to the eprosima::fastcdr::FastCdr object.
* @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize in a position that exceeds the internal memory size.
*/
inline FastCdr& operator<<(const std::string &string_t){return serialize(string_t);}
#if HAVE_CXX0X
/*!
* @brief This operator template is used to serialize arrays.
* @param array_t The array that will be serialized in the buffer.
* @return Reference to the eprosima::fastcdr::FastCdr object.
* @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize in a position that exceeds the internal memory size.
*/
template<class _T, size_t _Size>
inline FastCdr& operator<<(const std::array<_T, _Size> &array_t){return serialize<_T, _Size>(array_t);}
#endif
/*!
* @brief This operator template is used to serialize sequences.
* @param vector_t The sequence that will be serialized in the buffer.
* @return Reference to the eprosima::fastcdr::FastCdr object.
* @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize in a position that exceeds the internal memory size.
*/
template<class _T>
inline FastCdr& operator<<(const std::vector<_T> &vector_t){return serialize<_T>(vector_t);}
// TODO
template<class _T>
inline FastCdr& operator<<(const _T &type_t)
{
type_t.serialize(*this);
return *this;
}
/*!
* @brief This operator deserializes an octet.
* @param octet_t The variable that will store the octet read from the buffer.
* @return Reference to the eprosima::fastcdr::FastCdr object.
* @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize in a position that exceeds the internal memory size.
*/
inline FastCdr& operator>>(uint8_t &octet_t){return deserialize(octet_t);}
/*!
* @brief This operator deserializes a character.
* @param char_t The variable that will store the character read from the buffer.
* @return Reference to the eprosima::fastcdr::FastCdr object.
* @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize in a position that exceeds the internal memory size.
*/
inline FastCdr& operator>>(char &char_t){return deserialize(char_t);}
/*!
* @brief This operator deserializes an unsigned short.
* @param ushort_t The variable that will store the unsigned short read from the buffer.
* @return Reference to the eprosima::fastcdr::FastCdr object.
* @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize in a position that exceeds the internal memory size.
*/
inline FastCdr& operator>>(uint16_t &ushort_t){return deserialize(ushort_t);}
/*!
* @brief This operator deserializes a short.
* @param short_t The variable that will store the short read from the buffer.
* @return Reference to the eprosima::fastcdr::FastCdr object.
* @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize in a position that exceeds the internal memory size.
*/
inline FastCdr& operator>>(int16_t &short_t){return deserialize(short_t);}
/*!
* @brief This operator deserializes an unsigned long.
* @param ulong_t The variable that will store the unsigned long read from the buffer.
* @return Reference to the eprosima::fastcdr::FastCdr object.
* @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize in a position that exceeds the internal memory size.
*/
inline FastCdr& operator>>(uint32_t &ulong_t){return deserialize(ulong_t);}
/*!
* @brief This operator deserializes a long.
* @param long_t The variable that will store the long read from the buffer.
* @return Reference to the eprosima::fastcdr::FastCdr object.
* @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize in a position that exceeds the internal memory size.
*/
inline FastCdr& operator>>(int32_t &long_t){return deserialize(long_t);}
// TODO in FastCdr
inline FastCdr& operator>>(wchar_t &wchar){return deserialize(wchar);}
/*!
* @brief This operator deserializes an unsigned long long.
* @param ulonglong_t The variable that will store the unsigned long long read from the buffer.
* @return Reference to the eprosima::fastcdr::FastCdr object.
* @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize in a position that exceeds the internal memory size.
*/
inline FastCdr& operator>>(uint64_t &ulonglong_t){return deserialize(ulonglong_t);}
/*!
* @brief This operator deserializes a long long.
* @param longlong_t The variable that will store the long long read from the buffer.
* @return Reference to the eprosima::fastcdr::FastCdr object.
* @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize in a position that exceeds the internal memory size.
*/
inline FastCdr& operator>>(int64_t &longlong_t){return deserialize(longlong_t);}
/*!
* @brief This operator deserializes a float.
* @param float_t The variable that will store the float read from the buffer.
* @return Reference to the eprosima::fastcdr::FastCdr object.
* @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize in a position that exceeds the internal memory size.
*/
inline FastCdr& operator>>(float &float_t){return deserialize(float_t);}
/*!
* @brief This operator deserializes a double.
* @param double_t The variable that will store the double read from the buffer.
* @return Reference to the eprosima::fastcdr::FastCdr object.
* @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize in a position that exceeds the internal memory size.
*/
inline FastCdr& operator>>(double &double_t){return deserialize(double_t);}
/*!
* @brief This operator deserializes a boolean.
* @param bool_t The variable that will store the boolean read from the buffer.
* @return Reference to the eprosima::fastcdr::FastCdr object.
* @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize in a position that exceeds the internal memory size.
* @exception exception::BadParamException This exception is thrown when trying to deserialize in an invalid value.
*/
inline FastCdr& operator>>(bool &bool_t){return deserialize(bool_t);}
//TODO
inline FastCdr& operator>>(char *&string_t){return deserialize(string_t);}
/*!
* @brief This operator deserializes a string.
* @param string_t The variable that will store the string read from the buffer.
* @return Reference to the eprosima::fastcdr::FastCdr object.
* @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize in a position that exceeds the internal memory size.
*/
inline FastCdr& operator>>(std::string &string_t){return deserialize(string_t);}
#if HAVE_CXX0X
/*!
* @brief This operator template is used to deserialize arrays.
* @param array_t The variable that will store the array read from the buffer.
* @return Reference to the eprosima::fastcdr::FastCdr object.
* @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize in a position that exceeds the internal memory size.
*/
template<class _T, size_t _Size>
inline FastCdr& operator>>(std::array<_T, _Size> &array_t){return deserialize<_T, _Size>(array_t);}
#endif
/*!
* @brief This operator template is used to deserialize sequences.
* @param vector_t The variable that will store the sequence read from the buffer.
* @return Reference to the eprosima::fastcdr::FastCdr object.
* @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize in a position that exceeds the internal memory size.
*/
template<class _T>
inline FastCdr& operator>>(std::vector<_T> &vector_t){return deserialize<_T>(vector_t);}
// TODO
template<class _T>
inline FastCdr& operator>>(_T &type_t)
{
type_t.deserialize(*this);
return *this;
}
/*!
* @brief This function serializes an octet.
* @param octet_t The value of the octet that will be serialized in the buffer.
* @return Reference to the eprosima::fastcdr::FastCdr object.
* @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize in a position that exceeds the internal memory size.
*/
inline
FastCdr& serialize(const uint8_t octet_t)
{
return serialize((char)octet_t);
}
/*!
* @brief This function serializes a character.
* @param char_t The value of the character that will be serialized in the buffer.
* @return Reference to the eprosima::fastcdr::FastCdr object.
* @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize in a position that exceeds the internal memory size.
*/
inline
FastCdr& serialize(const char char_t)
{
if(((m_lastPosition - m_currentPosition) >= sizeof(char_t)) || resize(sizeof(char_t)))
{
m_currentPosition++ << char_t;
return *this;
}
throw exception::NotEnoughMemoryException(exception::NotEnoughMemoryException::NOT_ENOUGH_MEMORY_MESSAGE_DEFAULT);
}
/*!
* @brief This function serializes an unsigned short.
* @param ushort_t The value of the unsigned short that will be serialized in the buffer.
* @return Reference to the eprosima::fastcdr::FastCdr object.
* @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize in a position that exceeds the internal memory size.
*/
inline
FastCdr& serialize(const uint16_t ushort_t)
{
return serialize((int16_t)ushort_t);
}
/*!
* @brief This function serializes a short.
* @param short_t The value of the short that will be serialized in the buffer.
* @return Reference to the eprosima::fastcdr::FastCdr object.
* @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize in a position that exceeds the internal memory size.
*/
inline
FastCdr& serialize(const int16_t short_t)
{
if(((m_lastPosition - m_currentPosition) >= sizeof(short_t)) || resize(sizeof(short_t)))
{
m_currentPosition << short_t;
m_currentPosition += sizeof(short_t);
return *this;
}
throw exception::NotEnoughMemoryException(exception::NotEnoughMemoryException::NOT_ENOUGH_MEMORY_MESSAGE_DEFAULT);
}
/*!
* @brief This function serializes an unsigned long.
* @param ulong_t The value of the unsigned long that will be serialized in the buffer.
* @return Reference to the eprosima::fastcdr::FastCdr object.
* @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize in a position that exceeds the internal memory size.
*/
inline
FastCdr& serialize(const uint32_t ulong_t)
{
return serialize((int32_t)ulong_t);
}
/*!
* @brief This function serializes a long.
* @param long_t The value of the long that will be serialized in the buffer.
* @return Reference to the eprosima::fastcdr::FastCdr object.
* @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize in a position that exceeds the internal memory size.
*/
inline
FastCdr& serialize(const int32_t long_t)
{
if(((m_lastPosition - m_currentPosition) >= sizeof(long_t)) || resize(sizeof(long_t)))
{
m_currentPosition << long_t;
m_currentPosition += sizeof(long_t);
return *this;
}
throw exception::NotEnoughMemoryException(exception::NotEnoughMemoryException::NOT_ENOUGH_MEMORY_MESSAGE_DEFAULT);
}
inline
FastCdr& serialize(const wchar_t wchar)
{
return serialize((uint32_t)wchar);
}
/*!
* @brief This function serializes an unsigned long long.
* @param ulonglong_t The value of the unsigned long long that will be serialized in the buffer.
* @return Reference to the eprosima::fastcdr::FastCdr object.
* @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize in a position that exceeds the internal memory size.
*/
inline
FastCdr& serialize(const uint64_t ulonglong_t)
{
return serialize((int64_t)ulonglong_t);
}
/*!
* @brief This function serializes a long long.
* @param longlong_t The value of the long long that will be serialized in the buffer.
* @return Reference to the eprosima::fastcdr::FastCdr object.
* @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize in a position that exceeds the internal memory size.
*/
inline
FastCdr& serialize(const int64_t longlong_t)
{
if(((m_lastPosition - m_currentPosition) >= sizeof(longlong_t)) || resize(sizeof(longlong_t)))
{
m_currentPosition << longlong_t;
m_currentPosition += sizeof(longlong_t);
return *this;
}
throw exception::NotEnoughMemoryException(exception::NotEnoughMemoryException::NOT_ENOUGH_MEMORY_MESSAGE_DEFAULT);
}
/*!
* @brief This function serializes a float.
* @param float_t The value of the float that will be serialized in the buffer.
* @return Reference to the eprosima::fastcdr::FastCdr object.
* @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize in a position that exceeds the internal memory size.
*/
inline
FastCdr& serialize(const float float_t)
{
if(((m_lastPosition - m_currentPosition) >= sizeof(float_t)) || resize(sizeof(float_t)))
{
m_currentPosition << float_t;
m_currentPosition += sizeof(float_t);
return *this;
}
throw exception::NotEnoughMemoryException(exception::NotEnoughMemoryException::NOT_ENOUGH_MEMORY_MESSAGE_DEFAULT);
}
/*!
* @brief This function serializes a double.
* @param double_t The value of the double that will be serialized in the buffer.
* @return Reference to the eprosima::fastcdr::FastCdr object.
* @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize in a position that exceeds the internal memory size.
*/
inline
FastCdr& serialize(const double double_t)
{
if(((m_lastPosition - m_currentPosition) >= sizeof(double_t)) || resize(sizeof(double_t)))
{
m_currentPosition << double_t;
m_currentPosition += sizeof(double_t);
return *this;
}
throw exception::NotEnoughMemoryException(exception::NotEnoughMemoryException::NOT_ENOUGH_MEMORY_MESSAGE_DEFAULT);
}
/*!
* @brief This function serializes a boolean.
* @param bool_t The value of the boolean that will be serialized in the buffer.
* @return Reference to the eprosima::fastcdr::FastCdr object.
* @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize in a position that exceeds the internal memory size.
*/
FastCdr& serialize(const bool bool_t);
/*!
* @brief This function serializes a string.
* @param string_t The pointer to the string that will be serialized in the buffer.
* @return Reference to the eprosima::fastcdr::FastCdr object.
* @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize in a position that exceeds the internal memory size.
*/
FastCdr& serialize(const char *string_t);
//TODO
inline FastCdr& serialize(char *string_t) {return serialize((const char*)string_t);}
/*!
* @brief This function serializes a std::string.
* @param string_t The string that will be serialized in the buffer.
* @return Reference to the eprosima::fastcdr::FastCdr object.
* @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize in a position that exceeds the internal memory size.
*/
inline
FastCdr& serialize(const std::string &string_t) {return serialize(string_t.c_str());}
#if HAVE_CXX0X
/*!
* @brief This function template serializes an array.
* @param array_t The array that will be serialized in the buffer.
* @return Reference to the eprosima::fastcdr::FastCdr object.
* @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize in a position that exceeds the internal memory size.
*/
template<class _T, size_t _Size>
inline FastCdr& serialize(const std::array<_T, _Size> &array_t)
{ return serializeArray(array_t.data(), array_t.size());}
#endif
/*!
* @brief This function template serializes a sequence of booleans.
* @param vector_t The sequence that will be serialized in the buffer.
* @return Reference to the eprosima::fastcdr::FastCdr object.
* @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize in a position that exceeds the internal memory size.
*/
#if !defined(_MSC_VER) && HAVE_CXX0X
template<class _T = bool>
FastCdr& serialize(const std::vector<bool> &vector_t)
{
return serializeBoolSequence(vector_t);
}
#endif
/*!
* @brief This function template serializes a sequence.
* @param vector_t The sequence that will be serialized in the buffer.
* @return Reference to the eprosima::fastcdr::FastCdr object.
* @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize in a position that exceeds the internal memory size.
*/
template<class _T>
FastCdr& serialize(const std::vector<_T> &vector_t)
{
state state(*this);
*this << (int32_t)vector_t.size();
try
{
return serializeArray(vector_t.data(), vector_t.size());
}
catch(eprosima::fastcdr::exception::Exception &ex)
{
setState(state);
ex.raise();
}
return *this;
}
#ifdef _MSC_VER
template<>
FastCdr& serialize<bool>(const std::vector<bool> &vector_t)
{
return serializeBoolSequence(vector_t);
}
#endif
// TODO
template<class _T>
inline FastCdr& serialize(const _T &type_t)
{
type_t.serialize(*this);
return *this;
}
/*!
* @brief This function serializes an array of octets.
* @param octet_t The sequence of octets that will be serialized in the buffer.
* @param numElements Number of the elements in the array.
* @return Reference to the eprosima::fastcdr::FastCdr object.
* @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize in a position that exceeds the internal memory size.
*/
inline
FastCdr& serializeArray(const uint8_t *octet_t, size_t numElements)
{
return serializeArray((const char*)octet_t, numElements);
}
/*!
* @brief This function serializes an array of characters.
* @param char_t The array of characters that will be serialized in the buffer.
* @param numElements Number of the elements in the array.
* @return Reference to the eprosima::fastcdr::FastCdr object.
* @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize in a position that exceeds the internal memory size.
*/
FastCdr& serializeArray(const char *char_t, size_t numElements);
/*!
* @brief This function serializes an array of unsigned shorts.
* @param ushort_t The array of unsigned shorts that will be serialized in the buffer.
* @param numElements Number of the elements in the array.
* @return Reference to the eprosima::fastcdr::FastCdr object.
* @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize in a position that exceeds the internal memory size.
*/
inline
FastCdr& serializeArray(const uint16_t *ushort_t, size_t numElements)
{
return serializeArray((const int16_t*)ushort_t, numElements);
}
/*!
* @brief This function serializes an array of shorts.
* @param short_t The array of shorts that will be serialized in the buffer.
* @param numElements Number of the elements in the array.
* @return Reference to the eprosima::fastcdr::FastCdr object.
* @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize in a position that exceeds the internal memory size.
*/
FastCdr& serializeArray(const int16_t *short_t, size_t numElements);
/*!
* @brief This function serializes an array of unsigned longs.
* @param ulong_t The array of unsigned longs that will be serialized in the buffer.
* @param numElements Number of the elements in the array.
* @return Reference to the eprosima::fastcdr::FastCdr object.
* @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize in a position that exceeds the internal memory size.
*/
inline
FastCdr& serializeArray(const uint32_t *ulong_t, size_t numElements)
{
return serializeArray((const int32_t*)ulong_t, numElements);
}
/*!
* @brief This function serializes an array of longs.
* @param long_t The array of longs that will be serialized in the buffer.
* @param numElements Number of the elements in the array.
* @return Reference to the eprosima::fastcdr::FastCdr object.
* @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize in a position that exceeds the internal memory size.
*/
FastCdr& serializeArray(const int32_t *long_t, size_t numElements);
FastCdr& serializeArray(const wchar_t *wchar, size_t numElements);
/*!
* @brief This function serializes an array of unsigned long longs.
* @param ulonglong_t The array of unsigned long longs that will be serialized in the buffer.
* @param numElements Number of the elements in the array.
* @return Reference to the eprosima::fastcdr::FastCdr object.
* @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize in a position that exceeds the internal memory size.
*/
inline
FastCdr& serializeArray(const uint64_t *ulonglong_t, size_t numElements)
{
return serializeArray((const int64_t*)ulonglong_t, numElements);
}
/*!
* @brief This function serializes an array of long longs.
* @param longlong_t The array of long longs that will be serialized in the buffer.
* @param numElements Number of the elements in the array.
* @return Reference to the eprosima::fastcdr::FastCdr object.
* @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize in a position that exceeds the internal memory size.
*/
FastCdr& serializeArray(const int64_t *longlong_t, size_t numElements);
/*!
* @brief This function serializes an array of floats.
* @param float_t The array of floats that will be serialized in the buffer.
* @param numElements Number of the elements in the array.
* @return Reference to the eprosima::fastcdr::FastCdr object.
* @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize in a position that exceeds the internal memory size.
*/
FastCdr& serializeArray(const float *float_t, size_t numElements);
/*!
* @brief This function serializes an array of doubles.
* @param double_t The array of doubles that will be serialized in the buffer.
* @param numElements Number of the elements in the array.
* @return Reference to the eprosima::fastcdr::FastCdr object.
* @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize in a position that exceeds the internal memory size.
*/
FastCdr& serializeArray(const double *double_t, size_t numElements);
/*!
* @brief This function serializes an array of booleans.
* @param bool_t The array of booleans that will be serialized in the buffer.
* @param numElements Number of the elements in the array.
* @return Reference to the eprosima::fastcdr::FastCdr object.
* @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize in a position that exceeds the internal memory size.
*/
FastCdr& serializeArray(const bool *bool_t, size_t numElements);
// TODO
inline
FastCdr& serializeArray(const std::string *string_t, size_t numElements)
{
for(size_t count = 0; count < numElements; ++count)
serialize(string_t[count].c_str());
return *this;
}
// TODO
template<class _T>
FastCdr& serializeArray(const std::vector<_T> *vector_t, size_t numElements)
{
for(size_t count = 0; count < numElements; ++count)
serialize(vector_t[count]);
return *this;
}
// TODO
template<class _T>
FastCdr& serializeArray(const _T *type_t, size_t numElements)
{
for(size_t count = 0; count < numElements; ++count)
type_t[count].serialize(*this);
return *this;
}
/*!
* @brief This function template serializes a raw sequence.
* @param sequence_t Pointer to the sequence that will be serialized in the buffer.
* @param numElements The number of elements contained in the sequence.
* @return Reference to the eprosima::fastcdr::FastCdr object.
* @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize in a position that exceeds the internal memory size.
*/
template<class _T>
FastCdr& serializeSequence(const _T *sequence_t, size_t numElements)
{
state state(*this);
serialize((int32_t)numElements);
try
{
return serializeArray(sequence_t, numElements);
}
catch(eprosima::fastcdr::exception::Exception &ex)
{
setState(state);
ex.raise();
}
return *this;
}
/*!
* @brief This function deserializes an octet.
* @param octet_t The variable that will store the octet read from the buffer.
* @return Reference to the eprosima::fastcdr::FastCdr object.
* @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize in a position that exceeds the internal memory size.
*/
inline
FastCdr& deserialize(uint8_t &octet_t)
{
return deserialize((char&)octet_t);
}
/*!
* @brief This function deserializes a character.
* @param char_t The variable that will store the character read from the buffer.
* @return Reference to the eprosima::fastcdr::FastCdr object.
* @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize in a position that exceeds the internal memory size.
*/
inline
FastCdr& deserialize(char &char_t)
{
if((m_lastPosition - m_currentPosition) >= sizeof(char_t))
{
m_currentPosition++ >> char_t;
return *this;
}
throw exception::NotEnoughMemoryException(exception::NotEnoughMemoryException::NOT_ENOUGH_MEMORY_MESSAGE_DEFAULT);
}
/*!
* @brief This function deserializes an unsigned short.
* @param ushort_t The variable that will store the unsigned short read from the buffer.
* @return Reference to the eprosima::fastcdr::FastCdr object.
* @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize in a position that exceeds the internal memory size.
*/
inline
FastCdr& deserialize(uint16_t &ushort_t)
{
return deserialize((int16_t&)ushort_t);
}
/*!
* @brief This function deserializes a short.
* @param short_t The variable that will store the short read from the buffer.
* @return Reference to the eprosima::fastcdr::FastCdr object.
* @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize in a position that exceeds the internal memory size.
*/
inline
FastCdr& deserialize(int16_t &short_t)
{
if((m_lastPosition - m_currentPosition) >= sizeof(short_t))
{
m_currentPosition >> short_t;
m_currentPosition += sizeof(short_t);
return *this;
}
throw exception::NotEnoughMemoryException(exception::NotEnoughMemoryException::NOT_ENOUGH_MEMORY_MESSAGE_DEFAULT);
}
/*!
* @brief This function deserializes an unsigned long.
* @param ulong_t The variable that will store the unsigned long read from the buffer.
* @return Reference to the eprosima::fastcdr::FastCdr object.
* @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize in a position that exceeds the internal memory size.
*/
inline
FastCdr& deserialize(uint32_t &ulong_t)
{
return deserialize((int32_t&)ulong_t);
}
/*!
* @brief This function deserializes a long.
* @param long_t The variable that will store the long read from the buffer.
* @return Reference to the eprosima::fastcdr::FastCdr object.
* @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize in a position that exceeds the internal memory size.
*/
inline
FastCdr& deserialize(int32_t &long_t)
{
if((m_lastPosition - m_currentPosition) >= sizeof(long_t))
{
m_currentPosition >> long_t;
m_currentPosition += sizeof(long_t);
return *this;
}
throw exception::NotEnoughMemoryException(exception::NotEnoughMemoryException::NOT_ENOUGH_MEMORY_MESSAGE_DEFAULT);
}
inline
FastCdr& deserialize(wchar_t &wchar)
{
uint32_t ret;
deserialize(ret);
wchar = (wchar_t)ret;
return *this;
}
/*!
* @brief This function deserializes an unsigned long long.
* @param ulonglong_t The variable that will store the unsigned long long read from the buffer.
* @return Reference to the eprosima::fastcdr::FastCdr object.
* @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize in a position that exceeds the internal memory size.
*/
inline
FastCdr& deserialize(uint64_t &ulonglong_t)
{
return deserialize((int64_t&)ulonglong_t);
}
/*!
* @brief This function deserializes a long long.
* @param longlong_t The variable that will store the long long read from the buffer.
* @return Reference to the eprosima::fastcdr::FastCdr object.
* @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize in a position that exceeds the internal memory size.
*/
inline
FastCdr& deserialize(int64_t &longlong_t)
{
if((m_lastPosition - m_currentPosition) >= sizeof(longlong_t))
{
m_currentPosition >> longlong_t;
m_currentPosition += sizeof(longlong_t);
return *this;
}
throw exception::NotEnoughMemoryException(exception::NotEnoughMemoryException::NOT_ENOUGH_MEMORY_MESSAGE_DEFAULT);
}
/*!
* @brief This function deserializes a float.
* @param float_t The variable that will store the float read from the buffer.
* @return Reference to the eprosima::fastcdr::FastCdr object.
* @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize in a position that exceeds the internal memory size.
*/
inline
FastCdr& deserialize(float &float_t)
{
if((m_lastPosition - m_currentPosition) >= sizeof(float_t))
{
m_currentPosition >> float_t;
m_currentPosition += sizeof(float_t);
return *this;
}
throw exception::NotEnoughMemoryException(exception::NotEnoughMemoryException::NOT_ENOUGH_MEMORY_MESSAGE_DEFAULT);
}
/*!
* @brief This function deserializes a double.
* @param double_t The variable that will store the double read from the buffer.
* @return Reference to the eprosima::fastcdr::FastCdr object.
* @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize in a position that exceeds the internal memory size.
*/
inline
FastCdr& deserialize(double &double_t)
{
if((m_lastPosition - m_currentPosition) >= sizeof(double_t))
{
m_currentPosition >> double_t;
m_currentPosition += sizeof(double_t);
return *this;
}
throw exception::NotEnoughMemoryException(exception::NotEnoughMemoryException::NOT_ENOUGH_MEMORY_MESSAGE_DEFAULT);
}
/*!
* @brief This function deserializes a boolean.
* @param bool_t The variable that will store the boolean read from the buffer.
* @return Reference to the eprosima::fastcdr::FastCdr object.
* @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize in a position that exceeds the internal memory size.
* @exception exception::BadParamException This exception is thrown when trying to deserialize in an invalid value.
*/
FastCdr& deserialize(bool &bool_t);
/*!
* @brief This function deserializes a string.
* This function allocates memory to store the string. The user pointer will be set to point this allocated memory.
* The user will have to free this allocated memory using free()
* @param string_t The pointer that will point to the string read from the buffer.
* The user will have to free the allocated memory using free()
* @return Reference to the eprosima::fastcdr::FastCdr object.
* @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize in a position that exceeds the internal memory size.
*/
FastCdr& deserialize(char *&string_t);
/*!
* @brief This function deserializes a std::string.
* @param string_t The variable that will store the string read from the buffer.
* @return Reference to the eprosima::fastcdr::FastCdr object.
* @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize in a position that exceeds the internal memory size.
*/
inline
FastCdr& deserialize(std::string &string_t)
{
uint32_t length = 0;
const char *str = readString(length);
string_t = std::string(str, length);
return *this;
}
#if HAVE_CXX0X
/*!
* @brief This function template deserializes an array.
* @param array_t The variable that will store the array read from the buffer.
* @return Reference to the eprosima::fastcdr::FastCdr object.
* @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize in a position that exceeds the internal memory size.
*/
template<class _T, size_t _Size>
inline FastCdr& deserialize(std::array<_T, _Size> &array_t)
{ return deserializeArray(array_t.data(), array_t.size());}
#endif
/*!
* @brief This function template deserializes a sequence of booleans.
* @param vector_t The variable that will store the sequence read from the buffer.
* @return Reference to the eprosima::fastcdr::FastCdr object.
* @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize in a position that exceeds the internal memory size.
*/
#if !defined(_MSC_VER) && HAVE_CXX0X
template<class _T = bool>
FastCdr& deserialize(std::vector<bool> &vector_t)
{
return deserializeBoolSequence(vector_t);
}
#endif
/*!
* @brief This function template deserializes a sequence.
* @param vector_t The variable that will store the sequence read from the buffer.
* @return Reference to the eprosima::fastcdr::FastCdr object.
* @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize in a position that exceeds the internal memory size.
*/
template<class _T>
FastCdr& deserialize(std::vector<_T> &vector_t)
{
uint32_t seqLength = 0;
state state(*this);
*this >> seqLength;
try
{
vector_t.resize(seqLength);
return deserializeArray(vector_t.data(), vector_t.size());
}
catch(eprosima::fastcdr::exception::Exception &ex)
{
setState(state);
ex.raise();
}
return *this;
}
#ifdef _MSC_VER
template<>
FastCdr& deserialize<bool>(std::vector<bool> &vector_t)
{
return deserializeBoolSequence(vector_t);
}
#endif
// TODO
template<class _T>
inline FastCdr& deserialize(_T &type_t)
{
type_t.deserialize(*this);
return *this;
}
/*!
* @brief This function deserializes an array of octets.
* @param octet_t The variable that will store the array of octets read from the buffer.
* @param numElements Number of the elements in the array.
* @return Reference to the eprosima::fastcdr::FastCdr object.
* @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize in a position that exceeds the internal memory size.
*/
inline
FastCdr& deserializeArray(uint8_t *octet_t, size_t numElements)
{
return deserializeArray((char*)octet_t, numElements);
}
/*!
* @brief This function deserializes an array of characters.
* @param char_t The variable that will store the array of characters read from the buffer.
* @param numElements Number of the elements in the array.
* @return Reference to the eprosima::fastcdr::FastCdr object.
* @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize in a position that exceeds the internal memory size.
*/
FastCdr& deserializeArray(char *char_t, size_t numElements);
/*!
* @brief This function deserializes an array of unsigned shorts.
* @param ushort_t The variable that will store the array of unsigned shorts read from the buffer.
* @param numElements Number of the elements in the array.
* @return Reference to the eprosima::fastcdr::FastCdr object.
* @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize in a position that exceeds the internal memory size.
*/
inline
FastCdr& deserializeArray(uint16_t *ushort_t, size_t numElements)
{
return deserializeArray((int16_t*)ushort_t, numElements);
}
/*!
* @brief This function deserializes an array of shorts.
* @param short_t The variable that will store the array of shorts read from the buffer.
* @param numElements Number of the elements in the array.
* @return Reference to the eprosima::fastcdr::FastCdr object.
* @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize in a position that exceeds the internal memory size.
*/
FastCdr& deserializeArray(int16_t *short_t, size_t numElements);
/*!
* @brief This function deserializes an array of unsigned longs.
* @param ulong_t The variable that will store the array of unsigned longs read from the buffer.
* @param numElements Number of the elements in the array.
* @return Reference to the eprosima::fastcdr::FastCdr object.
* @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize in a position that exceeds the internal memory size.
*/
inline
FastCdr& deserializeArray(uint32_t *ulong_t, size_t numElements)
{
return deserializeArray((int32_t*)ulong_t, numElements);
}
/*!
* @brief This function deserializes an array of longs.
* @param long_t The variable that will store the array of longs read from the buffer.
* @param numElements Number of the elements in the array.
* @return Reference to the eprosima::fastcdr::FastCdr object.
* @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize in a position that exceeds the internal memory size.
*/
FastCdr& deserializeArray(int32_t *long_t, size_t numElements);
FastCdr& deserializeArray(wchar_t *wchar, size_t numElements);
/*!
* @brief This function deserializes an array of unsigned long longs.
* @param ulonglong_t The variable that will store the array of unsigned long longs read from the buffer.
* @param numElements Number of the elements in the array.
* @return Reference to the eprosima::fastcdr::FastCdr object.
* @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize in a position that exceeds the internal memory size.
*/
inline
FastCdr& deserializeArray(uint64_t *ulonglong_t, size_t numElements)
{
return deserializeArray((int64_t*)ulonglong_t, numElements);
}
/*!
* @brief This function deserializes an array of long longs.
* @param longlong_t The variable that will store the array of long longs read from the buffer.
* @param numElements Number of the elements in the array.
* @return Reference to the eprosima::fastcdr::FastCdr object.
* @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize in a position that exceeds the internal memory size.
*/
FastCdr& deserializeArray(int64_t *longlong_t, size_t numElements);
/*!
* @brief This function deserializes an array of floats.
* @param float_t The variable that will store the array of floats read from the buffer.
* @param numElements Number of the elements in the array.
* @return Reference to the eprosima::fastcdr::FastCdr object.
* @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize in a position that exceeds the internal memory size.
*/
FastCdr& deserializeArray(float *float_t, size_t numElements);
/*!
* @brief This function deserializes an array of doubles.
* @param double_t The variable that will store the array of doubles read from the buffer.
* @param numElements Number of the elements in the array.
* @return Reference to the eprosima::fastcdr::FastCdr object.
* @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize in a position that exceeds the internal memory size.
*/
FastCdr& deserializeArray(double *double_t, size_t numElements);
/*!
* @brief This function deserializes an array of booleans.
* @param bool_t The variable that will store the array of booleans read from the buffer.
* @param numElements Number of the elements in the array.
* @return Reference to the eprosima::fastcdr::FastCdr object.
* @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize in a position that exceeds the internal memory size.
*/
FastCdr& deserializeArray(bool *bool_t, size_t numElements);
// TODO
inline
FastCdr& deserializeArray(std::string *string_t, size_t numElements)
{
for(size_t count = 0; count < numElements; ++count)
deserialize(string_t[count]);
return *this;
}
// TODO
template<class _T>
FastCdr& deserializeArray(std::vector<_T> *vector_t, size_t numElements)
{
for(size_t count = 0; count < numElements; ++count)
deserialize(vector_t[count]);
return *this;
}
// TODO
template<class _T>
FastCdr& deserializeArray(_T *type_t, size_t numElements)
{
for(size_t count = 0; count < numElements; ++count)
type_t[count].deserialize(*this);
return *this;
}
#if !defined(_MSC_VER) && HAVE_CXX0X
template<class _T = std::string>
FastCdr& deserializeSequence(std::string *&sequence_t, size_t &numElements)
{
return deserializeStringSequence(sequence_t, numElements);
}
#endif
/*!
* @brief This function template deserializes a raw sequence.
* This function allocates memory to store the sequence. The user pointer will be set to point this allocated memory.
* The user will have to free this allocated memory using free()
* @param sequence_t The pointer that will store the sequence read from the buffer.
* @param numElements This variable return the number of elements of the sequence.
* @return Reference to the eprosima::fastcdr::FastCdr object.
* @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize in a position that exceeds the internal memory size.
*/
template<class _T>
FastCdr& deserializeSequence(_T *&sequence_t, size_t &numElements)
{
uint32_t seqLength = 0;
state state(*this);
deserialize(seqLength);
try
{
sequence_t = (_T*)calloc(seqLength, sizeof(_T));
deserializeArray(sequence_t, seqLength);
}
catch(eprosima::fastcdr::exception::Exception &ex)
{
free(sequence_t);
sequence_t = NULL;
setState(state);
ex.raise();
}
numElements = seqLength;
return *this;
}
#ifdef _MSC_VER
template<>
FastCdr& deserializeSequence<std::string>(std::string *&sequence_t, size_t &numElements)
{
return deserializeStringSequence(sequence_t, numElements);
}
#endif
private:
FastCdr(const FastCdr&) NON_COPYABLE_CXX11;
FastCdr& operator=(const FastCdr&) NON_COPYABLE_CXX11;
FastCdr& serializeBoolSequence(const std::vector<bool> &vector_t);
FastCdr& deserializeBoolSequence(std::vector<bool> &vector_t);
FastCdr& deserializeStringSequence(std::string *&sequence_t, size_t &numElements);
#if HAVE_CXX0X
/*!
* @brief This function template detects the content type of the STD container array and serializes the array.
* @param array_t The array that will be serialized in the buffer.
* @param numElements Number of the elements in the array.
* @return Reference to the eprosima::fastcdr::FastCdr object.
* @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize in a position that exceeds the internal memory size.
*/
template<class _T, size_t _Size>
FastCdr& serializeArray(const std::array<_T, _Size> *array_t, size_t numElements)
{
return serializeArray(array_t->data(), numElements * array_t->size());
}
/*!
* @brief This function template detects the content type of the STD container array and deserializes the array.
* @param array_t The variable that will store the array read from the buffer.
* @param numElements Number of the elements in the array.
* @return Reference to the eprosima::fastcdr::FastCdr object.
* @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize in a position that exceeds the internal memory size.
*/
template<class _T, size_t _Size>
FastCdr& deserializeArray(std::array<_T, _Size> *array_t, size_t numElements)
{
return deserializeArray(array_t->data(), numElements * array_t->size());
}
#endif
bool resize(size_t minSizeInc);
const char* readString(uint32_t &length);
//! @brief Reference to the buffer that will be serialized/deserialized.
FastBuffer &m_cdrBuffer;
//! @brief The current position in the serialization/deserialization process.
FastBuffer::iterator m_currentPosition;
//! @brief The last position in the buffer;
FastBuffer::iterator m_lastPosition;
};
} //namespace fastcdr
} //namespace eprosima
#endif //_FASTCDR_FASTCDR_H_
| 0 |
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/include | apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/include/fastcdr/fastcdr_dll.h | // Copyright 2016 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 _FASTCDR_FASTCDR_DLL_H_
#define _FASTCDR_FASTCDR_DLL_H_
#include "config.h"
// normalize macros
#if !defined(FASTCDR_DYN_LINK) && !defined(FASTCDR_STATIC_LINK) \
&& !defined(EPROSIMA_ALL_DYN_LINK) && !defined(EPROSIMA_ALL_STATIC_LINK)
#define FASTCDR_STATIC_LINK
#endif
#if defined(EPROSIMA_ALL_DYN_LINK) && !defined(FASTCDR_DYN_LINK)
#define FASTCDR_DYN_LINK
#endif
#if defined(FASTCDR_DYN_LINK) && defined(FASTCDR_STATIC_LINK)
#error Must not define both FASTCDR_DYN_LINK and FASTCDR_STATIC_LINK
#endif
#if defined(EPROSIMA_ALL_NO_LIB) && !defined(FASTCDR_NO_LIB)
#define FASTCDR_NO_LIB
#endif
// enable dynamic linking
#if defined(_WIN32)
#if defined(EPROSIMA_ALL_DYN_LINK) || defined(FASTCDR_DYN_LINK)
#if defined(FASTCDR_SOURCE)
#define Cdr_DllAPI __declspec( dllexport )
#else
#define Cdr_DllAPI __declspec( dllimport )
#endif // FASTCDR_SOURCE
#else
#define Cdr_DllAPI
#endif
#else
#define Cdr_DllAPI
#endif // _WIN32
// Auto linking.
#if !defined(FASTCDR_SOURCE) && !defined(EPROSIMA_ALL_NO_LIB) \
&& !defined(FASTCDR_NO_LIB)
// Set properties.
#define EPROSIMA_LIB_NAME fastcdr
#if defined(EPROSIMA_ALL_DYN_LINK) || defined(FASTCDR_DYN_LINK)
#define EPROSIMA_DYN_LINK
#endif
#include "eProsima_auto_link.h"
#endif // auto-linking disabled
#endif // _FASTCDR_FASTCDR_DLL_H_
| 0 |
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/include | apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/include/fastcdr/config.h | /* include/fastcdr/config.h. Generated from config.h.in by configure. */
// Copyright 2016 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 _FASTCDR_CONFIG_H_
#define _FASTCDR_CONFIG_H_
#ifndef FASTCDR_VERSION_MAJOR
#define FASTCDR_VERSION_MAJOR 1
#endif
#ifndef FASTCDR_VERSION_MINOR
#define FASTCDR_VERSION_MINOR 0
#endif
#ifndef FASTCDR_VERSION_MICRO
#define FASTCDR_VERSION_MICRO 7
#endif
#ifndef FASTCDR_VERSION_STR
#define FASTCDR_VERSION_STR "@FASTCDR_VERSION_STR@"
#endif
// C++11 support defines
#ifndef HAVE_CXX11
#define HAVE_CXX11 1
#endif
// C++0x support defines
#ifndef HAVE_CXX0X
#define HAVE_CXX0X 1
#endif
// Endianness defines
#ifndef __BIG_ENDIAN__
#define __BIG_ENDIAN__ 0
#endif
// C++11 Non-copyable feature
#ifndef NON_COPYABLE_CXX11
#if !defined(HAVE_CXX0X) || (defined(_MSC_VER) && _MSC_VER <= 1600)
#define NON_COPYABLE_CXX11
#else
#define NON_COPYABLE_CXX11 = delete
#endif
#endif
#endif // _FASTCDR_CONFIG_H_
| 0 |
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/include | apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/include/fastcdr/FastBuffer.h | // Copyright 2016 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 _FASTCDR_CDRBUFFER_H_
#define _FASTCDR_CDRBUFFER_H_
#include "fastcdr_dll.h"
#include <stdint.h>
#include <cstdio>
#include <string.h>
#include <cstddef>
namespace eprosima
{
namespace fastcdr
{
/*!
* @brief This class implements the iterator used to go through a FastBuffer.
*/
class Cdr_DllAPI _FastBuffer_iterator
{
public:
/*!
* @brief Default constructor.
* The iterator points any position.
*/
_FastBuffer_iterator() : m_buffer(NULL), m_currentPosition(NULL) {}
/*!
* @brief Constructor.
* The iterator points to the indicated position.
* @param buffer Pointer to the raw buffer.
* @param index Position of the raw buffer where the iterator will point.
*/
explicit _FastBuffer_iterator(char *buffer, size_t index) : m_buffer(buffer), m_currentPosition(&m_buffer[index]){}
/*!
* @brief This operator changes the iterator's raw buffer.
* This operator makes the iterator point to the same position but in another raw buffer.
* The new raw buffer is the same than the source iterator's.
* @param iterator The source iterator. The iterator will use the source iterator's raw buffer after this operation.
*/
inline
void operator<<(const _FastBuffer_iterator &iterator)
{
ptrdiff_t diff = m_currentPosition - m_buffer;
m_buffer = iterator.m_buffer;
m_currentPosition = m_buffer + diff;
}
/*!
* @brief This operator changes the position where the iterator points.
* This operator takes the index of the source iterator, but the iterator continues using its raw buffer.
* @param The source iterator. The iterator will use the source's iterator index to point to its own raw buffer.
*/
inline
void operator>>(const _FastBuffer_iterator &iterator)
{
ptrdiff_t diff = iterator.m_currentPosition - iterator.m_buffer;
m_currentPosition = m_buffer + diff;
}
/*!
* @brief This operator copies a data in the raw buffer.
* The copy uses the size of the data type.
* @param data Data to be copied. Cannot be NULL.
*/
template<typename _T>
inline
void operator<<(const _T &data)
{
*((_T*)m_currentPosition) = data;
}
/*!
* @brief This operator copies data from the raw buffer to a variable.
* The copy uses the size of the data type.
* @param data Data to be filled.
*/
template<typename _T>
inline
void operator>>(_T &data)
{
data = *((_T*)m_currentPosition);
}
/*!
* @brief This function copies a buffer into the raw buffer.
* @param src The source buffer.
* @param size The number of bytes to be copied.
*/
inline
void memcopy(const void* src, const size_t size)
{
memcpy(m_currentPosition, src, size);
}
/*!
* @brief This function copies from the raw buffer to a external buffer.
* @param dst The destination buffer.
* @param size The size of bytes to be copied.
*/
inline
void rmemcopy(void* dst, const size_t size)
{
memcpy(dst, m_currentPosition, size);
}
/*!
* @brief This function increments the position where the iterator points.
* @param numBytes Number of bytes the iterator moves the position.
*/
inline
void operator+=(size_t numBytes)
{
m_currentPosition += numBytes;
}
/*!
* @brief This operator returns the subtraction of the current interator's position and the source iterator's position.
* @iterator Source iterator whose position is subtracted to the current iterator's position.
* @return The result of subtract the current iterator's position and the source iterator's position.
*/
inline
size_t operator-(const _FastBuffer_iterator &it) const
{
return m_currentPosition - it.m_currentPosition;
}
/*!
* @brief This function increments the iterator in one the position.
* @return The current iterator.
*/
inline
_FastBuffer_iterator operator++()
{
++m_currentPosition;
return *this;
}
/*!
* @brief This function increments the iterator in one the position.
* @return The current iterator.
*/
inline
_FastBuffer_iterator operator++(int)
{
_FastBuffer_iterator tmp = *this;
++*this;
return tmp;
}
/*!
* @brief This function returns the current position in the raw buffer.
* @return The current position in the raw buffer.
*/
inline
char* operator&()
{
return m_currentPosition;
}
private:
//! Pointer to the raw buffer.
char *m_buffer;
//! Current position in the raw buffer.
char *m_currentPosition;
};
/*!
* @brief This class represents a stream of bytes that contains (or will contain)
* serialized data. This class is used by the serializers to serialize
* or deserialize using their representation.
* @ingroup FASTCDRAPIREFERENCE
*/
class Cdr_DllAPI FastBuffer
{
public:
typedef _FastBuffer_iterator iterator;
/*!
* @brief This constructor creates an internal stream and assigns it to the eprosima::fastcdr::FastBuffers object.
* The user can obtain this internal stream using the function eprosima::fastcdr::FastBuffers::getBuffer(). Be careful because this internal stream
* is deleted in the destruction of the eprosima::fastcdr::FastBuffers object.
*/
FastBuffer();
/*!
* @brief This constructor assigns the user's stream of bytes to the eprosima::fastcdr::FastBuffers object.
* The user's stream will be used to serialize.
*
* @param buffer The user's buffer that will be used. This buffer is not deallocated in the object's destruction. Cannot be NULL.
* @param bufferSize The length of user's buffer.
*/
FastBuffer(char* const buffer, const size_t bufferSize);
/*!
* @brief Default destructor.
*/
virtual ~FastBuffer();
/*!
* @brief This function returns the stream that the eprosima::fastcdr::FastBuffers uses to serialize data.
* @return The stream used by eprosima::fastcdr::FastBuffers to serialize data.
*/
inline char* getBuffer() const { return m_buffer;}
/*!
* @brief This function returns the size of the allocated memory of the stream that the eprosima::fastcdr::FastBuffers uses to serialize data.
* @return The size of the allocated memory of the stream used by the eprosima::fastcdr::FastBuffers to serialize data.
*/
inline size_t getBufferSize() const { return m_bufferSize;}
/*!
* @brief This function returns a iterator that points to the begining of the stream.
* @return The new iterator.
*/
inline
iterator begin()
{
return (iterator(m_buffer, 0));
}
/*!
* @brief This function returns a iterator that points to the end of the stream.
* @return The new iterator.
*/
inline
iterator end()
{
return (iterator(m_buffer, m_bufferSize));
}
/*!
* @brief This function resizes the raw buffer. It will call the user's defined function for this purpose.
* @param minSizeInc The minimun growth expected of the current raw buffer.
* @return True if the operation works. False if it does not.
*/
bool resize(size_t minSizeInc);
private:
//! @brief Pointer to the stream of bytes that contains the serialized data.
char *m_buffer;
//! @brief The total size of the user's buffer.
size_t m_bufferSize;
//! @brief This variable indicates if the managed buffer is internal or is from the user.
bool m_internalBuffer;
};
} //namespace fastcdr
} //namespace eprosima
#endif // _FASTCDR_FASTCDRBUFFER_H_
| 0 |
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/include | apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/include/fastcdr/eProsima_auto_link.h | // Copyright 2016 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.
/*
Expected defines.
- EPROSIMA_LIB_NAME
- FASTCDR_VERSION_MAJOR
- FASTCDR_VERSION_MINOR
*/
#if defined(_MSC_VER)
#define EPROSIMA_STRINGIZE(X) EPROSIMA_DO_STRINGIZE(X)
#define EPROSIMA_DO_STRINGIZE(X) #X
#if defined(_DEBUG)
#define EPROSIMA_LIB_DEBUG_TAG "d"
#else
#define EPROSIMA_LIB_DEBUG_TAG
#endif // _DEBUG
// Select linkage option.
#if (defined(_DLL) || defined(_RTLDLL)) && defined(EPROSIMA_DYN_LINK)
#define EPROSIMA_LIB_PREFIX
#elif defined(EPROSIMA_DYN_LINK)
#error "Mixing a dll eprosima library with a static runtime is a bad idea"
#else
#define EPROSIMA_LIB_PREFIX "lib"
#endif
// Include library
#if defined(EPROSIMA_LIB_NAME) \
&& defined(EPROSIMA_LIB_PREFIX) \
&& defined(EPROSIMA_LIB_DEBUG_TAG) \
&& defined(FASTCDR_VERSION_MAJOR) \
&& defined(FASTCDR_VERSION_MINOR)
#pragma comment(lib, EPROSIMA_LIB_PREFIX EPROSIMA_STRINGIZE(EPROSIMA_LIB_NAME) EPROSIMA_LIB_DEBUG_TAG "-" EPROSIMA_STRINGIZE(FASTCDR_VERSION_MAJOR) "." EPROSIMA_STRINGIZE(FASTCDR_VERSION_MINOR) ".lib")
#else
#error "Some required macros where not defined"
#endif
#endif // _MSC_VER
// Undef macros
#ifdef EPROSIMA_LIB_PREFIX
#undef EPROSIMA_LIB_PREFIX
#endif
#ifdef EPROSIMA_LIB_NAME
#undef EPROSIMA_LIB_NAME
#endif
#ifdef EPROSIMA_LIB_DEBUG_TAG
#undef EPROSIMA_LIB_DEBUG_TAG
#endif
| 0 |
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/include | apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/include/fastcdr/Cdr.h | // Copyright 2016 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 _FASTCDR_CDR_H_
#define _FASTCDR_CDR_H_
#include "fastcdr_dll.h"
#include "FastBuffer.h"
#include "exceptions/NotEnoughMemoryException.h"
#include <stdint.h>
#include <string>
#include <vector>
#if !__APPLE__
#include <malloc.h>
#else
#include <stdlib.h>
#endif
#if HAVE_CXX0X
#include <array>
#endif
namespace eprosima
{
namespace fastcdr
{
/*!
* @brief This class offers an interface to serialize/deserialize some basic types using CDR protocol inside an eprosima::fastcdr::FastBuffer.
* @ingroup FASTCDRAPIREFERENCE
*/
class Cdr_DllAPI Cdr
{
public:
//! @brief This enumeration represents the two kinds of CDR serialization supported by eprosima::fastcdr::CDR.
typedef enum
{
//! @brief Common CORBA CDR serialization.
CORBA_CDR,
//! @brief DDS CDR serialization.
DDS_CDR
} CdrType;
//! @brief This enumeration represents the two posible values of the flag that points if the content is a parameter list (only in DDS CDR).
typedef enum
#ifdef HAVE_CXX0X
: uint8_t
#endif
{
//! @brief Specifies that the content is not a parameter list.
DDS_CDR_WITHOUT_PL = 0x0,
//! @brief Specifies that the content is a parameter list.
DDS_CDR_WITH_PL = 0x2
} DDSCdrPlFlag;
/*!
* @brief This enumeration represents endianness types.
*/
typedef enum
#ifdef HAVE_CXX0X
: uint8_t
#endif
{
//! @brief Big endianness.
BIG_ENDIANNESS = 0x0,
//! @brief Little endianness.
LITTLE_ENDIANNESS = 0x1
} Endianness;
//! @brief Default endiness in the system.
static const Endianness DEFAULT_ENDIAN;
/*!
* @brief This class stores the current state of a CDR serialization.
*/
class Cdr_DllAPI state
{
friend class Cdr;
public:
/*!
* @brief Default constructor.
*/
state(const Cdr &cdr);
/*!
* @brief Copy constructor.
*/
state(const state&);
private:
state& operator=(const state&) NON_COPYABLE_CXX11;
//! @brief The position in the buffer when the state was created.
const FastBuffer::iterator m_currentPosition;
//! @brief The position from the aligment is calculated, when the state was created..
const FastBuffer::iterator m_alignPosition;
//! @brief This attribute specified if it is needed to swap the bytes when the state was created..
bool m_swapBytes;
//! @brief Stores the last datasize serialized/deserialized when the state was created.
size_t m_lastDataSize;
};
/*!
* @brief This constructor creates an eprosima::fastcdr::Cdr object that can serialize/deserialize
* the assigned buffer.
*
* @param cdrBuffer A reference to the buffer that contains (or will contain) the CDR representation.
* @param endianness The initial endianness that will be used. The default value is the endianness of the system.
* @param cdrType Represents the type of CDR that will be used in serialization/deserialization. The default value is CORBA CDR.
*/
Cdr(FastBuffer &cdrBuffer, const Endianness endianness = DEFAULT_ENDIAN, const CdrType cdrType = CORBA_CDR);
/*!
* @brief This function reads the encapsulation of the CDR stream.
* If the CDR stream contains an encapsulation, then this function will be calles before starting to deserialize.
* @return Reference to the eprosima::fastcdr::Cdr object.
* @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize a position that exceeds the internal memory size.
* @exception exception::BadParamException This exception is thrown when trying to deserialize an invalid value.
*/
Cdr& read_encapsulation();
Cdr& serialize_encapsulation();
/*!
* @brief This function returns the parameter list flag when the CDR type is eprosima::fastcdr::DDS_CDR.
* @return The flag that specifies if the content is a parameter list.
*/
DDSCdrPlFlag getDDSCdrPlFlag() const;
// TODO
void setDDSCdrPlFlag(DDSCdrPlFlag plFlag);
/*!
* @brief This function returns the option flags when the CDR type is eprosima::fastcdr::DDS_CDR.
* @return The option flags.
*/
uint16_t getDDSCdrOptions() const;
// TODO
void setDDSCdrOptions(uint16_t options);
// TODO
void changeEndianness(Endianness endianness);
/*!
* @brief This function returns the current endianness used by the CDR type.
* @return The endianness.
*/
Endianness endianness() { return (Endianness)m_endianness; }
/*!
* @brief This function skips a number of bytes in the CDR stream buffer.
* @param numBytes The number of bytes that will be jumped.
* @return True is returned when it works successfully. Otherwise, false is returned.
*/
bool jump(size_t numBytes);
/*!
* @brief This function resets the current position in the buffer to the beginning.
*/
void reset();
/*!
* @brief This function returns the pointer to the current used buffer.
*/
char* getBufferPointer();
/*!
* @brief This function returns the current position in the CDR stream.
* @return Pointer to the current position in the buffer.
*/
char* getCurrentPosition();
/*!
* @brief This function returns the length of the serialized data inside the stream.
* @return The length of the serialized data.
*/
inline size_t getSerializedDataLength() const { return m_currentPosition - m_cdrBuffer.begin();}
/*! TODO */
inline static size_t alignment(size_t current_alignment, size_t dataSize) { return (dataSize - (current_alignment % dataSize)) & (dataSize-1);}
/*!
* @brief This function returns the current state of the CDR serialization process.
* @return The current state of the CDR serialization process.
*/
state getState();
/*!
* @brief This function sets a previous state of the CDR serialization process;
* @param state Previous state that will be set.
*/
void setState(state &state);
bool moveAlignmentForward(size_t numBytes);
/*!
* @brief This function resets the alignment to the current position in the buffer.
*/
inline void resetAlignment(){m_alignPosition = m_currentPosition;}
/*!
* @brief This operator serializes an octet.
* @param octet_t The value of the octet that will be serialized in the buffer.
* @return Reference to the eprosima::fastcdr::Cdr object.
* @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize a position that exceeds the internal memory size.
*/
inline Cdr& operator<<(const uint8_t octet_t){return serialize(octet_t);}
/*!
* @brief This operator serializes a character.
* @param char_t The value of the character that will be serialized in the buffer.
* @return Reference to the eprosima::fastcdr::Cdr object.
* @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize a position that exceeds the internal memory size.
*/
inline Cdr& operator<<(const char char_t){return serialize(char_t);}
/*!
* @brief This operator serializes an unsigned short.
* @param ushort_t The value of the unsigned short that will be serialized in the buffer.
* @return Reference to the eprosima::fastcdr::Cdr object.
* @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize a position that exceeds the internal memory size.
*/
inline Cdr& operator<<(const uint16_t ushort_t){return serialize(ushort_t);}
/*!
* @brief This operator serializes a short.
* @param short_t The value of the short that will be serialized in the buffer.
* @return Reference to the eprosima::fastcdr::Cdr object.
* @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize a position that exceeds the internal memory size.
*/
inline Cdr& operator<<(const int16_t short_t){return serialize(short_t);}
/*!
* @brief This operator serializes an unsigned long.
* @param ulong_t The value of the unsigned long that will be serialized in the buffer.
* @return Reference to the eprosima::fastcdr::Cdr object.
* @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize a position that exceeds the internal memory size.
*/
inline Cdr& operator<<(const uint32_t ulong_t){return serialize(ulong_t);}
/*!
* @brief This operator serializes a long.
* @param ulong_t The value of the long that will be serialized in the buffer.
* @return Reference to the eprosima::fastcdr::Cdr object.
* @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize a position that exceeds the internal memory size.
*/
inline Cdr& operator<<(const int32_t long_t){return serialize(long_t);}
// TODO in FastCdr
inline Cdr& operator<<(const wchar_t wchar){return serialize(wchar);}
/*!
* @brief This operator serializes an unsigned long long.
* @param ulonglong_t The value of the unsigned long long that will be serialized in the buffer.
* @return Reference to the eprosima::fastcdr::Cdr object.
* @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize a position that exceeds the internal memory size.
*/
inline Cdr& operator<<(const uint64_t ulonglong_t){return serialize(ulonglong_t);}
/*!
* @brief This operator serializes a long long.
* @param longlong_t The value of the long long that will be serialized in the buffer.
* @return Reference to the eprosima::fastcdr::Cdr object.
* @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize a position that exceeds the internal memory size.
*/
inline Cdr& operator<<(const int64_t longlong_t){return serialize(longlong_t);}
/*!
* @brief This operator serializes a float.
* @param float_t The value of the float that will be serialized in the buffer.
* @return Reference to the eprosima::fastcdr::Cdr object.
* @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize a position that exceeds the internal memory size.
*/
inline Cdr& operator<<(const float float_t){return serialize(float_t);}
/*!
* @brief This operator serializes a double.
* @param double_t The value of the double that will be serialized in the buffer.
* @return Reference to the eprosima::fastcdr::Cdr object.
* @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize a position that exceeds the internal memory size.
*/
inline Cdr& operator<<(const double double_t){return serialize(double_t);}
/*!
* @brief This operator serializes a boolean.
* @param bool_t The value of the boolean that will be serialized in the buffer.
* @return Reference to the eprosima::fastcdr::Cdr object.
* @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize a position that exceeds the internal memory size.
*/
inline Cdr& operator<<(const bool bool_t){return serialize(bool_t);}
//TODO
inline Cdr& operator<<(const char *string_t){return serialize(string_t);}
//TODO
inline Cdr& operator<<(char *string_t){return serialize(string_t);}
/*!
* @brief This operator serializes a string.
* @param string_t The string that will be serialized in the buffer.
* @return Reference to the eprosima::fastcdr::Cdr object.
* @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize a position that exceeds the internal memory size.
*/
inline Cdr& operator<<(const std::string &string_t){return serialize(string_t);}
#if HAVE_CXX0X
/*!
* @brief This operator template is used to serialize arrays.
* @param array_t The array that will be serialized in the buffer.
* @return Reference to the eprosima::fastcdr::Cdr object.
* @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize a position that exceeds the internal memory size.
*/
template<class _T, size_t _Size>
inline Cdr& operator<<(const std::array<_T, _Size> &array_t){return serialize<_T, _Size>(array_t);}
#endif
/*!
* @brief This operator template is used to serialize sequences.
* @param vector_t The sequence that will be serialized in the buffer.
* @return Reference to the eprosima::fastcdr::Cdr object.
* @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize a position that exceeds the internal memory size.
*/
template<class _T>
inline Cdr& operator<<(const std::vector<_T> &vector_t){return serialize<_T>(vector_t);}
// TODO
template<class _T>
inline Cdr& operator<<(const _T &type_t)
{
type_t.serialize(*this);
return *this;
}
/*!
* @brief This operator deserializes an octet.
* @param octet_t The variable that will store the octet read from the buffer.
* @return Reference to the eprosima::fastcdr::Cdr object.
* @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize a position that exceeds the internal memory size.
*/
inline Cdr& operator>>(uint8_t &octet_t){return deserialize(octet_t);}
/*!
* @brief This operator deserializes a character.
* @param char_t The variable that will store the character read from the buffer.
* @return Reference to the eprosima::fastcdr::Cdr object.
* @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize a position that exceeds the internal memory size.
*/
inline Cdr& operator>>(char &char_t){return deserialize(char_t);}
/*!
* @brief This operator deserializes an unsigned short.
* @param ushort_t The variable that will store the unsigned short read from the buffer.
* @return Reference to the eprosima::fastcdr::Cdr object.
* @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize a position that exceeds the internal memory size.
*/
inline Cdr& operator>>(uint16_t &ushort_t){return deserialize(ushort_t);}
/*!
* @brief This operator deserializes a short.
* @param short_t The variable that will store the short read from the buffer.
* @return Reference to the eprosima::fastcdr::Cdr object.
* @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize a position that exceeds the internal memory size.
*/
inline Cdr& operator>>(int16_t &short_t){return deserialize(short_t);}
/*!
* @brief This operator deserializes an unsigned long.
* @param ulong_t The variable that will store the unsigned long read from the buffer.
* @return Reference to the eprosima::fastcdr::Cdr object.
* @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize a position that exceeds the internal memory size.
*/
inline Cdr& operator>>(uint32_t &ulong_t){return deserialize(ulong_t);}
/*!
* @brief This operator deserializes a long.
* @param long_t The variable that will store the long read from the buffer.
* @return Reference to the eprosima::fastcdr::Cdr object.
* @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize a position that exceeds the internal memory size.
*/
inline Cdr& operator>>(int32_t &long_t){return deserialize(long_t);}
// TODO in FastCdr
inline Cdr& operator>>(wchar_t &wchar){return deserialize(wchar);}
/*!
* @brief This operator deserializes a unsigned long long.
* @param ulonglong_t The variable that will store the unsigned long long read from the buffer.
* @return Reference to the eprosima::fastcdr::Cdr object.
* @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize a position that exceeds the internal memory size.
*/
inline Cdr& operator>>(uint64_t &ulonglong_t){return deserialize(ulonglong_t);}
/*!
* @brief This operator deserializes a long long.
* @param longlong_t The variable that will store the long long read from the buffer.
* @return Reference to the eprosima::fastcdr::Cdr object.
* @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize a position that exceeds the internal memory size.
*/
inline Cdr& operator>>(int64_t &longlong_t){return deserialize(longlong_t);}
/*!
* @brief This operator deserializes a float.
* @param float_t The variable that will store the float read from the buffer.
* @return Reference to the eprosima::fastcdr::Cdr object.
* @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize a position that exceeds the internal memory size.
*/
inline Cdr& operator>>(float &float_t){return deserialize(float_t);}
/*!
* @brief This operator deserializes a double.
* @param double_t The variable that will store the double read from the buffer.
* @return Reference to the eprosima::fastcdr::Cdr object.
* @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize a position that exceeds the internal memory size.
*/
inline Cdr& operator>>(double &double_t){return deserialize(double_t);}
/*!
* @brief This operator deserializes a boolean.
* @param bool_t The variable that will store the boolean read from the buffer.
* @return Reference to the eprosima::fastcdr::Cdr object.
* @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize a position that exceeds the internal memory size.
* @exception exception::BadParamException This exception is thrown when trying to deserialize an invalid value.
*/
inline Cdr& operator>>(bool &bool_t){return deserialize(bool_t);}
//TODO
inline Cdr& operator>>(char *&string_t){return deserialize(string_t);}
/*!
* @brief This operator deserializes a string.
* @param string_t The variable that will store the string read from the buffer.
* @return Reference to the eprosima::fastcdr::Cdr object.
* @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize a position that exceeds the internal memory size.
*/
inline Cdr& operator>>(std::string &string_t){return deserialize(string_t);}
#if HAVE_CXX0X
/*!
* @brief This operator template is used to deserialize arrays.
* @param array_t The variable that will store the array read from the buffer.
* @return Reference to the eprosima::fastcdr::Cdr object.
* @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize a position that exceeds the internal memory size.
*/
template<class _T, size_t _Size>
inline Cdr& operator>>(std::array<_T, _Size> &array_t){return deserialize<_T, _Size>(array_t);}
#endif
/*!
* @brief This operator template is used to deserialize sequences.
* @param vector_t The variable that will store the sequence read from the buffer.
* @return Reference to the eprosima::fastcdr::Cdr object.
* @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize a position that exceeds the internal memory size.
*/
template<class _T>
inline Cdr& operator>>(std::vector<_T> &vector_t){return deserialize<_T>(vector_t);}
// TODO
template<class _T>
inline Cdr& operator>>(_T &type_t)
{
type_t.deserialize(*this);
return *this;
}
/*!
* @brief This function serializes an octet.
* @param octet_t The value of the octet that will be serialized in the buffer.
* @return Reference to the eprosima::fastcdr::Cdr object.
* @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize a position that exceeds the internal memory size.
*/
inline
Cdr& serialize(const uint8_t octet_t)
{
return serialize((char)octet_t);
}
/*!
* @brief This function serializes an octet with a different endianness.
* @param octet_t The value of the octet that will be serialized in the buffer.
* @param endianness Endianness that will be used in the serialization of this value.
* @return Reference to the eprosima::fastcdr::Cdr object.
* @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize a position that exceeds the internal memory size.
*/
inline
Cdr& serialize(const uint8_t octet_t, Endianness endianness)
{
return serialize((char)octet_t, endianness);
}
/*!
* @brief This function serializes a character.
* @param char_t The value of the character that will be serialized in the buffer.
* @return Reference to the eprosima::fastcdr::Cdr object.
* @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize a position that exceeds the internal memory size.
*/
Cdr& serialize(const char char_t);
/*!
* @brief This function serializes a character with a different endianness.
* @param char_t The value of the character that will be serialized in the buffer.
* @param endianness Endianness that will be used in the serialization of this value.
* @return Reference to the eprosima::fastcdr::Cdr object.
* @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize a position that exceeds the internal memory size.
*/
inline
Cdr& serialize(const char char_t, Endianness /*endianness*/)
{
return serialize(char_t);
}
/*!
* @brief This function serializes an unsigned short.
* @param ushort_t The value of the unsigned short that will be serialized in the buffer.
* @return Reference to the eprosima::fastcdr::Cdr object.
* @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize a position that exceeds the internal memory size.
*/
inline
Cdr& serialize(const uint16_t ushort_t)
{
return serialize((int16_t)ushort_t);
}
/*!
* @brief This function serializes an unsigned short with a different endianness.
* @param ushort_t The value of the unsigned short that will be serialized in the buffer.
* @param endianness Endianness that will be used in the serialization of this value.
* @return Reference to the eprosima::fastcdr::Cdr object.
* @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize a position that exceeds the internal memory size.
*/
inline
Cdr& serialize(const uint16_t ushort_t, Endianness endianness)
{
return serialize((int16_t)ushort_t, endianness);
}
/*!
* @brief This function serializes a short.
* @param short_t The value of the short that will be serialized in the buffer.
* @return Reference to the eprosima::fastcdr::Cdr object.
* @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize a position that exceeds the internal memory size.
*/
Cdr& serialize(const int16_t short_t);
/*!
* @brief This function serializes a short with a different endianness.
* @param short_t The value of the short that will be serialized in the buffer.
* @param endianness Endianness that will be used in the serialization of this value.
* @return Reference to the eprosima::fastcdr::Cdr object.
* @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize a position that exceeds the internal memory size.
*/
Cdr& serialize(const int16_t short_t, Endianness endianness);
/*!
* @brief This function serializes an unsigned long.
* @param ulong_t The value of the unsigned long that will be serialized in the buffer.
* @return Reference to the eprosima::fastcdr::Cdr object.
* @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize a position that exceeds the internal memory size.
*/
inline
Cdr& serialize(const uint32_t ulong_t)
{
return serialize((int32_t)ulong_t);
}
/*!
* @brief This function serializes an unsigned long with a different endianness.
* @param ulong_t The value of the unsigned long that will be serialized in the buffer.
* @param endianness Endianness that will be used in the serialization of this value.
* @return Reference to the eprosima::fastcdr::Cdr object.
* @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize a position that exceeds the internal memory size.
*/
inline
Cdr& serialize(const uint32_t ulong_t, Endianness endianness)
{
return serialize((int32_t)ulong_t, endianness);
}
/*!
* @brief This function serializes a long.
* @param long_t The value of the long that will be serialized in the buffer.
* @return Reference to the eprosima::fastcdr::Cdr object.
* @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize a position that exceeds the internal memory size.
*/
Cdr& serialize(const int32_t long_t);
/*!
* @brief This function serializes a long with a different endianness.
* @param long_t The value of the long that will be serialized in the buffer.
* @param endianness Endianness that will be used in the serialization of this value.
* @return Reference to the eprosima::fastcdr::Cdr object.
* @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize a position that exceeds the internal memory size.
*/
Cdr& serialize(const int32_t long_t, Endianness endianness);
inline
Cdr& serialize(const wchar_t wchar)
{
return serialize((uint32_t)wchar);
}
inline
Cdr& serialize(const wchar_t wchar, Endianness endianness)
{
return serialize((uint32_t)wchar, endianness);
}
/*!
* @brief This function serializes an unsigned long long.
* @param ulonglong_t The value of the unsigned long long that will be serialized in the buffer.
* @return Reference to the eprosima::fastcdr::Cdr object.
* @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize a position that exceeds the internal memory size.
*/
inline
Cdr& serialize(const uint64_t ulonglong_t)
{
return serialize((int64_t)ulonglong_t);
}
/*!
* @brief This function serializes an unsigned long long with a different endianness.
* @param ulonglong_t The value of the unsigned long long that will be serialized in the buffer.
* @param endianness Endianness that will be used in the serialization of this value.
* @return Reference to the eprosima::fastcdr::Cdr object.
* @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize a position that exceeds the internal memory size.
*/
inline
Cdr& serialize(const uint64_t ulonglong_t, Endianness endianness)
{
return serialize((int64_t)ulonglong_t, endianness);
}
/*!
* @brief This function serializes a long long.
* @param longlong_t The value of the long long that will be serialized in the buffer.
* @return Reference to the eprosima::fastcdr::Cdr object.
* @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize a position that exceeds the internal memory size.
*/
Cdr& serialize(const int64_t longlong_t);
/*!
* @brief This function serializes a long long with a different endianness.
* @param longlong_t The value of the long long that will be serialized in the buffer.
* @param endianness Endianness that will be used in the serialization of this value.
* @return Reference to the eprosima::fastcdr::Cdr object.
* @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize a position that exceeds the internal memory size.
*/
Cdr& serialize(const int64_t longlong_t, Endianness endianness);
/*!
* @brief This function serializes a float.
* @param float_t The value of the float that will be serialized in the buffer.
* @return Reference to the eprosima::fastcdr::Cdr object.
* @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize a position that exceeds the internal memory size.
*/
Cdr& serialize(const float float_t);
/*!
* @brief This function serializes a float with a different endianness.
* @param float_t The value of the float that will be serialized in the buffer.
* @param endianness Endianness that will be used in the serialization of this value.
* @return Reference to the eprosima::fastcdr::Cdr object.
* @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize a position that exceeds the internal memory size.
*/
Cdr& serialize(const float float_t, Endianness endianness);
/*!
* @brief This function serializes a double.
* @param double_t The value of the double that will be serialized in the buffer.
* @return Reference to the eprosima::fastcdr::Cdr object.
* @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize a position that exceeds the internal memory size.
*/
Cdr& serialize(const double double_t);
/*!
* @brief This function serializes a double with a different endianness.
* @param double_t The value of the double that will be serialized in the buffer.
* @param endianness Endianness that will be used in the serialization of this value.
* @return Reference to the eprosima::fastcdr::Cdr object.
* @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize a position that exceeds the internal memory size.
*/
Cdr& serialize(const double double_t, Endianness endianness);
/*!
* @brief This function serializes a boolean.
* @param bool_t The value of the boolean that will be serialized in the buffer.
* @return Reference to the eprosima::fastcdr::Cdr object.
* @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize a position that exceeds the internal memory size.
*/
Cdr& serialize(const bool bool_t);
/*!
* @brief This function serializes a boolean with a different endianness.
* @param bool_t The value of the boolean that will be serialized in the buffer.
* @param endianness Endianness that will be used in the serialization of this value.
* @return Reference to the eprosima::fastcdr::Cdr object.
* @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize a position that exceeds the internal memory size.
*/
inline
Cdr& serialize(const bool bool_t, Endianness /*endianness*/)
{
return serialize(bool_t);
}
/*!
* @brief This function serializes a string.
* @param string_t The pointer to the string that will be serialized in the buffer.
* @return Reference to the eprosima::fastcdr::Cdr object.
* @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize a position that exceeds the internal memory size.
*/
Cdr& serialize(const char *string_t);
Cdr& serialize(const char *string_t, size_t length);
/*!
* @brief This function serializes a string with a different endianness.
* @param string_t The pointer to the string that will be serialized in the buffer.
* @param endianness Endianness that will be used in the serialization of this value.
* @return Reference to the eprosima::fastcdr::Cdr object.
* @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize a position that exceeds the internal memory size.
*/
Cdr& serialize(const char *string_t, Endianness endianness);
Cdr& serialize(const char *string_t, size_t length, Endianness endianness);
//TODO
inline Cdr& serialize(char *string_t) {return serialize((const char*)string_t);}
//TODO
inline Cdr& serialize(char *string_t, Endianness endianness) {return serialize((const char*)string_t, endianness);}
/*!
* @brief This function serializes a std::string.
* @param string_t The string that will be serialized in the buffer.
* @return Reference to the eprosima::fastcdr::Cdr object.
* @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize a position that exceeds the internal memory size.
*/
inline
Cdr& serialize(const std::string &string_t) {return serialize(string_t.c_str(), string_t.size());}
/*!
* @brief This function serializes a std::string with a different endianness.
* @param string_t The string that will be serialized in the buffer.
* @param endianness Endianness that will be used in the serialization of this value.
* @return Reference to the eprosima::fastcdr::Cdr object.
* @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize a position that exceeds the internal memory size.
*/
inline
Cdr& serialize(const std::string &string_t, Endianness endianness) {return serialize(string_t.c_str(), string_t.size(), endianness);}
#if HAVE_CXX0X
/*!
* @brief This function template serializes an array.
* @param array_t The array that will be serialized in the buffer.
* @return Reference to the eprosima::fastcdr::Cdr object.
* @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize a position that exceeds the internal memory size.
*/
template<class _T, size_t _Size>
inline Cdr& serialize(const std::array<_T, _Size> &array_t)
{ return serializeArray(array_t.data(), array_t.size());}
/*!
* @brief This function template serializes an array with a different endianness.
* @param array_t The array that will be serialized in the buffer.
* @param endianness Endianness that will be used in the serialization of this value.
* @return Reference to the eprosima::fastcdr::Cdr object.
* @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize a position that exceeds the internal memory size.
*/
template<class _T, size_t _Size>
inline Cdr& serialize(const std::array<_T, _Size> &array_t, Endianness endianness)
{ return serializeArray(array_t.data(), array_t.size(), endianness);}
#endif
/*!
* @brief This function template serializes a sequence of booleans.
* @param vector_t The sequence that will be serialized in the buffer.
* @return Reference to the eprosima::fastcdr::Cdr object.
* @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize a position that exceeds the internal memory size.
*/
#if !defined(_MSC_VER) && HAVE_CXX0X
template<class _T = bool>
Cdr& serialize(const std::vector<bool> &vector_t)
{
return serializeBoolSequence(vector_t);
}
#endif
/*!
* @brief This function template serializes a sequence.
* @param vector_t The sequence that will be serialized in the buffer.
* @return Reference to the eprosima::fastcdr::Cdr object.
* @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize a position that exceeds the internal memory size.
*/
template<class _T>
Cdr& serialize(const std::vector<_T> &vector_t)
{
state state(*this);
*this << (int32_t)vector_t.size();
try
{
return serializeArray(vector_t.data(), vector_t.size());
}
catch(eprosima::fastcdr::exception::Exception &ex)
{
setState(state);
ex.raise();
}
return *this;
}
#ifdef _MSC_VER
template<>
Cdr& serialize<bool>(const std::vector<bool> &vector_t)
{
return serializeBoolSequence(vector_t);
}
#endif
/*!
* @brief This function template serializes a sequence with a different endianness.
* @param vector_t The sequence that will be serialized in the buffer.
* @param endianness Endianness that will be used in the serialization of this value.
* @return Reference to the eprosima::fastcdr::Cdr object.
* @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize a position that exceeds the internal memory size.
*/
template<class _T>
Cdr& serialize(const std::vector<_T> &vector_t, Endianness endianness)
{
bool auxSwap = m_swapBytes;
m_swapBytes = (m_swapBytes && (m_endianness == endianness)) || (!m_swapBytes && (m_endianness != endianness));
try
{
serialize(vector_t);
m_swapBytes = auxSwap;
}
catch(eprosima::fastcdr::exception::Exception &ex)
{
m_swapBytes = auxSwap;
ex.raise();
}
return *this;
}
// TODO
template<class _T>
inline Cdr& serialize(const _T &type_t)
{
type_t.serialize(*this);
return *this;
}
/*!
* @brief This function serializes an array of octets.
* @param octet_t The sequence of octets that will be serialized in the buffer.
* @param numElements Number of the elements in the array.
* @return Reference to the eprosima::fastcdr::Cdr object.
* @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize a position that exceeds the internal memory size.
*/
inline
Cdr& serializeArray(const uint8_t *octet_t, size_t numElements)
{
return serializeArray((const char*)octet_t, numElements);
}
/*!
* @brief This function serializes an array of octets with a different endianness.
* @param octet_t The array of octets that will be serialized in the buffer.
* @param numElements Number of the elements in the array.
* @param endianness Endianness that will be used in the serialization of this value.
* @return Reference to the eprosima::fastcdr::Cdr object.
* @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize a position that exceeds the internal memory size.
*/
inline
Cdr& serializeArray(const uint8_t *octet_t, size_t numElements, Endianness /*endianness*/)
{
return serializeArray((const char*)octet_t, numElements);
}
/*!
* @brief This function serializes an array of characters.
* @param char_t The array of characters that will be serialized in the buffer.
* @param numElements Number of the elements in the array.
* @return Reference to the eprosima::fastcdr::Cdr object.
* @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize a position that exceeds the internal memory size.
*/
Cdr& serializeArray(const char *char_t, size_t numElements);
/*!
* @brief This function serializes an array of characters with a different endianness.
* @param char_t The array of characters that will be serialized in the buffer.
* @param numElements Number of the elements in the array.
* @param endianness Endianness that will be used in the serialization of this value.
* @return Reference to the eprosima::fastcdr::Cdr object.
* @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize a position that exceeds the internal memory size.
*/
inline
Cdr& serializeArray(const char *char_t, size_t numElements, Endianness /*endianness*/)
{
return serializeArray(char_t, numElements);
}
/*!
* @brief This function serializes an array of unsigned shorts.
* @param ushort_t The array of unsigned shorts that will be serialized in the buffer.
* @param numElements Number of the elements in the array.
* @return Reference to the eprosima::fastcdr::Cdr object.
* @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize a position that exceeds the internal memory size.
*/
inline
Cdr& serializeArray(const uint16_t *ushort_t, size_t numElements)
{
return serializeArray((const int16_t*)ushort_t, numElements);
}
/*!
* @brief This function serializes an array of unsigned shorts with a different endianness.
* @param ushort_t The array of unsigned shorts that will be serialized in the buffer.
* @param numElements Number of the elements in the array.
* @param endianness Endianness that will be used in the serialization of this value.
* @return Reference to the eprosima::fastcdr::Cdr object.
* @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize a position that exceeds the internal memory size.
*/
inline
Cdr& serializeArray(const uint16_t *ushort_t, size_t numElements, Endianness endianness)
{
return serializeArray((const int16_t*)ushort_t, numElements, endianness);
}
/*!
* @brief This function serializes an array of shorts.
* @param short_t The array of shorts that will be serialized in the buffer.
* @param numElements Number of the elements in the array.
* @return Reference to the eprosima::fastcdr::Cdr object.
* @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize a position that exceeds the internal memory size.
*/
Cdr& serializeArray(const int16_t *short_t, size_t numElements);
/*!
* @brief This function serializes an array of shorts with a different endianness.
* @param short_t The array of shorts that will be serialized in the buffer.
* @param numElements Number of the elements in the array.
* @param endianness Endianness that will be used in the serialization of this value.
* @return Reference to the eprosima::fastcdr::Cdr object.
* @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize a position that exceeds the internal memory size.
*/
Cdr& serializeArray(const int16_t *short_t, size_t numElements, Endianness endianness);
/*!
* @brief This function serializes an array of unsigned longs.
* @param ulong_t The array of unsigned longs that will be serialized in the buffer.
* @param numElements Number of the elements in the array.
* @return Reference to the eprosima::fastcdr::Cdr object.
* @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize a position that exceeds the internal memory size.
*/
inline
Cdr& serializeArray(const uint32_t *ulong_t, size_t numElements)
{
return serializeArray((const int32_t*)ulong_t, numElements);
}
/*!
* @brief This function serializes an array of unsigned longs with a different endianness.
* @param ulong_t The array of unsigned longs that will be serialized in the buffer.
* @param numElements Number of the elements in the array.
* @param endianness Endianness that will be used in the serialization of this value.
* @return Reference to the eprosima::fastcdr::Cdr object.
* @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize a position that exceeds the internal memory size.
*/
inline
Cdr& serializeArray(const uint32_t *ulong_t, size_t numElements, Endianness endianness)
{
return serializeArray((const int32_t*)ulong_t, numElements, endianness);
}
/*!
* @brief This function serializes an array of longs.
* @param long_t The array of longs that will be serialized in the buffer.
* @param numElements Number of the elements in the array.
* @return Reference to the eprosima::fastcdr::Cdr object.
* @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize a position that exceeds the internal memory size.
*/
Cdr& serializeArray(const int32_t *long_t, size_t numElements);
/*!
* @brief This function serializes an array of longs with a different endianness.
* @param long_t The array of longs that will be serialized in the buffer.
* @param numElements Number of the elements in the array.
* @param endianness Endianness that will be used in the serialization of this value.
* @return Reference to the eprosima::fastcdr::Cdr object.
* @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize a position that exceeds the internal memory size.
*/
Cdr& serializeArray(const int32_t *long_t, size_t numElements, Endianness endianness);
Cdr& serializeArray(const wchar_t *wchar, size_t numElements);
Cdr& serializeArray(const wchar_t *wchar, size_t numElements, Endianness endianness);
/*!
* @brief This function serializes an array of unsigned long longs.
* @param ulonglong_t The array of unsigned long longs that will be serialized in the buffer.
* @param numElements Number of the elements in the array.
* @return Reference to the eprosima::fastcdr::Cdr object.
* @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize a position that exceeds the internal memory size.
*/
inline
Cdr& serializeArray(const uint64_t *ulonglong_t, size_t numElements)
{
return serializeArray((const int64_t*)ulonglong_t, numElements);
}
/*!
* @brief This function serializes an array of unsigned long longs with a different endianness.
* @param ulonglong_t The array of unsigned long longs that will be serialized in the buffer.
* @param numElements Number of the elements in the array.
* @param endianness Endianness that will be used in the serialization of this value.
* @return Reference to the eprosima::fastcdr::Cdr object.
* @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize a position that exceeds the internal memory size.
*/
inline
Cdr& serializeArray(const uint64_t *ulonglong_t, size_t numElements, Endianness endianness)
{
return serializeArray((const int64_t*)ulonglong_t, numElements, endianness);
}
/*!
* @brief This function serializes an array of long longs.
* @param longlong_t The array of long longs that will be serialized in the buffer.
* @param numElements Number of the elements in the array.
* @return Reference to the eprosima::fastcdr::Cdr object.
* @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize a position that exceeds the internal memory size.
*/
Cdr& serializeArray(const int64_t *longlong_t, size_t numElements);
/*!
* @brief This function serializes an array of long longs with a different endianness.
* @param longlong_t The array of long longs that will be serialized in the buffer.
* @param numElements Number of the elements in the array.
* @param endianness Endianness that will be used in the serialization of this value.
* @return Reference to the eprosima::fastcdr::Cdr object.
* @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize a position that exceeds the internal memory size.
*/
Cdr& serializeArray(const int64_t *longlong_t, size_t numElements, Endianness endianness);
/*!
* @brief This function serializes an array of floats.
* @param float_t The array of floats that will be serialized in the buffer.
* @param numElements Number of the elements in the array.
* @return Reference to the eprosima::fastcdr::Cdr object.
* @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize a position that exceeds the internal memory size.
*/
Cdr& serializeArray(const float *float_t, size_t numElements);
/*!
* @brief This function serializes an array of floats with a different endianness.
* @param float_t The array of floats that will be serialized in the buffer.
* @param numElements Number of the elements in the array.
* @param endianness Endianness that will be used in the serialization of this value.
* @return Reference to the eprosima::fastcdr::Cdr object.
* @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize a position that exceeds the internal memory size.
*/
Cdr& serializeArray(const float *float_t, size_t numElements, Endianness endianness);
/*!
* @brief This function serializes an array of doubles.
* @param double_t The array of doubles that will be serialized in the buffer.
* @param numElements Number of the elements in the array.
* @return Reference to the eprosima::fastcdr::Cdr object.
* @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize a position that exceeds the internal memory size.
*/
Cdr& serializeArray(const double *double_t, size_t numElements);
/*!
* @brief This function serializes an array of doubles with a different endianness.
* @param double_t The array of doubles that will be serialized in the buffer.
* @param numElements Number of the elements in the array.
* @param endianness Endianness that will be used in the serialization of this value.
* @return Reference to the eprosima::fastcdr::Cdr object.
* @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize a position that exceeds the internal memory size.
*/
Cdr& serializeArray(const double *double_t, size_t numElements, Endianness endianness);
/*!
* @brief This function serializes an array of booleans.
* @param bool_t The array of booleans that will be serialized in the buffer.
* @param numElements Number of the elements in the array.
* @return Reference to the eprosima::fastcdr::Cdr object.
* @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize a position that exceeds the internal memory size.
*/
Cdr& serializeArray(const bool *bool_t, size_t numElements);
/*!
* @brief This function serializes an array of booleans with a different endianness.
* @param bool_t The array of booleans that will be serialized in the buffer.
* @param numElements Number of the elements in the array.
* @param endianness Endianness that will be used in the serialization of this value.
* @return Reference to the eprosima::fastcdr::Cdr object.
* @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize a position that exceeds the internal memory size.
*/
inline
Cdr& serializeArray(const bool *bool_t, size_t numElements, Endianness /*endianness*/)
{
return serializeArray(bool_t, numElements);
}
// TODO
inline
Cdr& serializeArray(const std::string *string_t, size_t numElements)
{
for(size_t count = 0; count < numElements; ++count)
serialize(string_t[count].c_str());
return *this;
}
inline
Cdr& serializeArray(const std::string *string_t, size_t numElements, Endianness endianness)
{
bool auxSwap = m_swapBytes;
m_swapBytes = (m_swapBytes && (m_endianness == endianness)) || (!m_swapBytes && (m_endianness != endianness));
try
{
serializeArray(string_t, numElements);
m_swapBytes = auxSwap;
}
catch(eprosima::fastcdr::exception::Exception &ex)
{
m_swapBytes = auxSwap;
ex.raise();
}
return *this;
}
// TODO
template<class _T>
Cdr& serializeArray(const std::vector<_T> *vector_t, size_t numElements)
{
for(size_t count = 0; count < numElements; ++count)
serialize(vector_t[count]);
return *this;
}
// TODO
template<class _T>
Cdr& serializeArray(const _T *type_t, size_t numElements)
{
for(size_t count = 0; count < numElements; ++count)
type_t[count].serialize(*this);
return *this;
}
template<class _T>
Cdr& serializeArray(const _T *type_t, size_t numElements, Endianness endianness)
{
bool auxSwap = m_swapBytes;
m_swapBytes = (m_swapBytes && (m_endianness == endianness)) || (!m_swapBytes && (m_endianness != endianness));
try
{
serializeArray(type_t, numElements);
m_swapBytes = auxSwap;
}
catch(eprosima::fastcdr::exception::Exception &ex)
{
m_swapBytes = auxSwap;
ex.raise();
}
return *this;
}
/*!
* @brief This function template serializes a raw sequence.
* @param sequence_t Pointer to the sequence that will be serialized in the buffer.
* @param numElements The number of elements contained in the sequence.
* @return Reference to the eprosima::fastcdr::Cdr object.
* @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize a position that exceeds the internal memory size.
*/
template<class _T>
Cdr& serializeSequence(const _T *sequence_t, size_t numElements)
{
state state(*this);
serialize((int32_t)numElements);
try
{
return serializeArray(sequence_t, numElements);
}
catch(eprosima::fastcdr::exception::Exception &ex)
{
setState(state);
ex.raise();
}
return *this;
}
/*!
* @brief This function template serializes a raw sequence with a different endianness.
* @param sequence_t Pointer to the sequence that will be serialized in the buffer.
* @param numElements The number of elements contained in the sequence.
* @return Reference to the eprosima::fastcdr::Cdr object.
* @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize a position that exceeds the internal memory size.
*/
template<class _T>
Cdr& serializeSequence(const _T *sequence_t, size_t numElements, Endianness endianness)
{
bool auxSwap = m_swapBytes;
m_swapBytes = (m_swapBytes && (m_endianness == endianness)) || (!m_swapBytes && (m_endianness != endianness));
try
{
serializeSequence(sequence_t, numElements);
m_swapBytes = auxSwap;
}
catch(eprosima::fastcdr::exception::Exception &ex)
{
m_swapBytes = auxSwap;
ex.raise();
}
return *this;
}
/*!
* @brief This function deserializes an octet.
* @param octet_t The variable that will store the octet read from the buffer.
* @return Reference to the eprosima::fastcdr::Cdr object.
* @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize a position that exceeds the internal memory size.
*/
inline
Cdr& deserialize(uint8_t &octet_t)
{
return deserialize((char&)octet_t);
}
/*!
* @brief This function deserializes an octet with a different endianness.
* @param octet_t The variable that will store the octet read from the buffer.
* @param endianness Endianness that will be used in the serialization of this value.
* @return Reference to the eprosima::fastcdr::Cdr object.
* @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize a position that exceeds the internal memory size.
*/
inline
Cdr& deserialize(uint8_t &octet_t, Endianness endianness)
{
return deserialize((char&)octet_t, endianness);
}
/*!
* @brief This function deserializes a character.
* @param char_t The variable that will store the character read from the buffer.
* @return Reference to the eprosima::fastcdr::Cdr object.
* @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize a position that exceeds the internal memory size.
*/
Cdr& deserialize(char &char_t);
/*!
* @brief This function deserializes a character with a different endianness.
* @param char_t The variable that will store the character read from the buffer.
* @param endianness Endianness that will be used in the serialization of this value.
* @return Reference to the eprosima::fastcdr::Cdr object.
* @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize a position that exceeds the internal memory size.
*/
inline
Cdr& deserialize(char &char_t, Endianness /*endianness*/)
{
return deserialize(char_t);
}
/*!
* @brief This function deserializes an unsigned short.
* @param ushort_t The variable that will store the unsigned short read from the buffer.
* @return Reference to the eprosima::fastcdr::Cdr object.
* @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize a position that exceeds the internal memory size.
*/
inline
Cdr& deserialize(uint16_t &ushort_t)
{
return deserialize((int16_t&)ushort_t);
}
/*!
* @brief This function deserializes an unsigned short with a different endianness.
* @param ushort_t The variable that will store the unsigned short read from the buffer.
* @param endianness Endianness that will be used in the serialization of this value.
* @return Reference to the eprosima::fastcdr::Cdr object.
* @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize a position that exceeds the internal memory size.
*/
inline
Cdr& deserialize(uint16_t &ushort_t, Endianness endianness)
{
return deserialize((int16_t&)ushort_t, endianness);
}
/*!
* @brief This function deserializes a short.
* @param short_t The variable that will store the short read from the buffer.
* @return Reference to the eprosima::fastcdr::Cdr object.
* @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize a position that exceeds the internal memory size.
*/
Cdr& deserialize(int16_t &short_t);
/*!
* @brief This function deserializes a short with a different endianness.
* @param short_t The variable that will store the short read from the buffer.
* @param endianness Endianness that will be used in the serialization of this value.
* @return Reference to the eprosima::fastcdr::Cdr object.
* @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize a position that exceeds the internal memory size.
*/
Cdr& deserialize(int16_t &short_t, Endianness endianness);
/*!
* @brief This function deserializes an unsigned long.
* @param ulong_t The variable that will store the unsigned long read from the buffer.
* @return Reference to the eprosima::fastcdr::Cdr object.
* @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize a position that exceeds the internal memory size.
*/
inline
Cdr& deserialize(uint32_t &ulong_t)
{
return deserialize((int32_t&)ulong_t);
}
/*!
* @brief This function deserializes an unsigned long with a different endianness.
* @param ulong_t The variable that will store the unsigned long read from the buffer..
* @param endianness Endianness that will be used in the serialization of this value.
* @return Reference to the eprosima::fastcdr::Cdr object.
* @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize a position that exceeds the internal memory size.
*/
inline
Cdr& deserialize(uint32_t &ulong_t, Endianness endianness)
{
return deserialize((int32_t&)ulong_t, endianness);
}
/*!
* @brief This function deserializes a long.
* @param long_t The variable that will store the long read from the buffer.
* @return Reference to the eprosima::fastcdr::Cdr object.
* @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize a position that exceeds the internal memory size.
*/
Cdr& deserialize(int32_t &long_t);
/*!
* @brief This function deserializes a long with a different endianness.
* @param long_t The variable that will store the long read from the buffer.
* @param endianness Endianness that will be used in the serialization of this value.
* @return Reference to the eprosima::fastcdr::Cdr object.
* @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize a position that exceeds the internal memory size.
*/
Cdr& deserialize(int32_t &long_t, Endianness endianness);
inline
Cdr& deserialize(wchar_t &wchar)
{
uint32_t ret;
deserialize(ret);
wchar = (wchar_t)ret;
return *this;
}
inline
Cdr& deserialize(wchar_t &wchar, Endianness endianness)
{
uint32_t ret;
deserialize(ret, endianness);
wchar = (wchar_t)ret;
return *this;
}
/*!
* @brief This function deserializes an unsigned long long.
* @param ulonglong_t The variable that will store the unsigned long long read from the buffer.
* @return Reference to the eprosima::fastcdr::Cdr object.
* @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize a position that exceeds the internal memory size.
*/
inline
Cdr& deserialize(uint64_t &ulonglong_t)
{
return deserialize((int64_t&)ulonglong_t);
}
/*!
* @brief This function deserializes an unsigned long long with a different endianness.
* @param ulonglong_t The variable that will store the unsigned long long read from the buffer.
* @param endianness Endianness that will be used in the serialization of this value.
* @return Reference to the eprosima::fastcdr::Cdr object.
* @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize a position that exceeds the internal memory size.
*/
inline
Cdr& deserialize(uint64_t &ulonglong_t, Endianness endianness)
{
return deserialize((int64_t&)ulonglong_t, endianness);
}
/*!
* @brief This function deserializes a long long.
* @param longlong_t The variable that will store the long long read from the buffer.
* @return Reference to the eprosima::fastcdr::Cdr object.
* @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize a position that exceeds the internal memory size.
*/
Cdr& deserialize(int64_t &longlong_t);
/*!
* @brief This function deserializes a long long with a different endianness.
* @param longlong_t The variable that will store the long long read from the buffer.
* @param endianness Endianness that will be used in the serialization of this value.
* @return Reference to the eprosima::fastcdr::Cdr object.
* @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize a position that exceeds the internal memory size.
*/
Cdr& deserialize(int64_t &longlong_t, Endianness endianness);
/*!
* @brief This function deserializes a float.
* @param float_t The variable that will store the float read from the buffer.
* @return Reference to the eprosima::fastcdr::Cdr object.
* @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize a position that exceeds the internal memory size.
*/
Cdr& deserialize(float &float_t);
/*!
* @brief This function deserializes a float with a different endianness.
* @param float_t The variable that will store the float read from the buffer.
* @param endianness Endianness that will be used in the serialization of this value.
* @return Reference to the eprosima::fastcdr::Cdr object.
* @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize a position that exceeds the internal memory size.
*/
Cdr& deserialize(float &float_t, Endianness endianness);
/*!
* @brief This function deserializes a double.
* @param double_t The variable that will store the double read from the buffer.
* @return Reference to the eprosima::fastcdr::Cdr object.
* @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize a position that exceeds the internal memory size.
*/
Cdr& deserialize(double &double_t);
/*!
* @brief This function deserializes a double with a different endianness.
* @param double_t The variable that will store the double read from the buffer.
* @param endianness Endianness that will be used in the serialization of this value.
* @return Reference to the eprosima::fastcdr::Cdr object.
* @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize a position that exceeds the internal memory size.
*/
Cdr& deserialize(double &double_t, Endianness endianness);
/*!
* @brief This function deserializes a boolean.
* @param bool_t The variable that will store the boolean read from the buffer.
* @return Reference to the eprosima::fastcdr::Cdr object.
* @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize a position that exceeds the internal memory size.
* @exception exception::BadParamException This exception is thrown when trying to deserialize an invalid value.
*/
Cdr& deserialize(bool &bool_t);
/*!
* @brief This function deserializes a boolean with a different endianness.
* @param bool_t The variable that will store the boolean read from the buffer.
* @param endianness Endianness that will be used in the serialization of this value.
* @return Reference to the eprosima::fastcdr::Cdr object.
* @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize a position that exceeds the internal memory size.
* @exception exception::BadParamException This exception is thrown when trying to deserialize an invalid value.
*/
inline
Cdr& deserialize(bool &bool_t, Endianness /*endianness*/)
{
return deserialize(bool_t);
};
/*!
* @brief This function deserializes a string.
* This function allocates memory to store the string. The user pointer will be set to point this allocated memory.
* The user will have to free this allocated memory using free()
* @param string_t The pointer that will point to the string read from the buffer.
* The user will have to free the allocated memory using free()
* @return Reference to the eprosima::fastcdr::Cdr object.
* @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize a position that exceeds the internal memory size.
*/
Cdr& deserialize(char *&string_t);
/*!
* @brief This function deserializes a string with a different endianness.
* This function allocates memory to store the string. The user pointer will be set to point this allocated memory.
* The user will have to free this allocated memory using free()
* @param string_t The pointer that will point to the string read from the buffer.
* The user will have to free the allocated memory using free()
* @return Reference to the eprosima::fastcdr::Cdr object.
* @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize a position that exceeds the internal memory size.
*/
Cdr& deserialize(char *&string_t, Endianness endianness);
/*!
* @brief This function deserializes a std::string.
* @param string_t The variable that will store the string read from the buffer.
* @return Reference to the eprosima::fastcdr::Cdr object.
* @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize a position that exceeds the internal memory size.
*/
inline
Cdr& deserialize(std::string &string_t)
{
uint32_t length = 0;
const char *str = readString(length);
string_t = std::string(str, length);
return *this;
}
/*!
* @brief This function deserializes a string with a different endianness.
* @param string_t The variable that will store the string read from the buffer.
* @param endianness Endianness that will be used in the serialization of this value.
* @return Reference to the eprosima::fastcdr::Cdr object.
* @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize a position that exceeds the internal memory size.
*/
inline
Cdr& deserialize(std::string &string_t, Endianness endianness)
{
bool auxSwap = m_swapBytes;
m_swapBytes = (m_swapBytes && (m_endianness == endianness)) || (!m_swapBytes && (m_endianness != endianness));
try
{
deserialize(string_t);
m_swapBytes = auxSwap;
}
catch(eprosima::fastcdr::exception::Exception &ex)
{
m_swapBytes = auxSwap;
ex.raise();
}
return *this;
}
#if HAVE_CXX0X
/*!
* @brief This function template deserializes an array.
* @param array_t The variable that will store the array read from the buffer.
* @return Reference to the eprosima::fastcdr::Cdr object.
* @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize a position that exceeds the internal memory size.
*/
template<class _T, size_t _Size>
inline Cdr& deserialize(std::array<_T, _Size> &array_t)
{ return deserializeArray(array_t.data(), array_t.size());}
/*!
* @brief This function template deserializes an array with a different endianness.
* @param array_t The variable that will store the array read from the buffer.
* @param endianness Endianness that will be used in the serialization of this value.
* @return Reference to the eprosima::fastcdr::Cdr object.
* @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize a position that exceeds the internal memory size.
*/
template<class _T, size_t _Size>
inline Cdr& deserialize(std::array<_T, _Size> &array_t, Endianness endianness)
{ return deserializeArray(array_t.data(), array_t.size(), endianness);}
#endif
/*!
* @brief This function template deserializes a sequence.
* @param vector_t The variable that will store the sequence read from the buffer.
* @return Reference to the eprosima::fastcdr::Cdr object.
* @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize a position that exceeds the internal memory size.
*/
#if !defined(_MSC_VER) && HAVE_CXX0X
template<class _T = bool>
Cdr& deserialize(std::vector<bool> &vector_t)
{
return deserializeBoolSequence(vector_t);
}
#endif
/*!
* @brief This function template deserializes a sequence.
* @param vector_t The variable that will store the sequence read from the buffer.
* @return Reference to the eprosima::fastcdr::Cdr object.
* @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize a position that exceeds the internal memory size.
*/
template<class _T>
Cdr& deserialize(std::vector<_T> &vector_t)
{
uint32_t seqLength = 0;
state state(*this);
*this >> seqLength;
try
{
vector_t.resize(seqLength);
return deserializeArray(vector_t.data(), vector_t.size());
}
catch(eprosima::fastcdr::exception::Exception &ex)
{
setState(state);
ex.raise();
}
return *this;
}
#ifdef _MSC_VER
template<>
Cdr& deserialize<bool>(std::vector<bool> &vector_t)
{
return deserializeBoolSequence(vector_t);
}
#endif
/*!
* @brief This function template deserializes a sequence with a different endianness.
* @param vector_t The variable that will store the sequence read from the buffer.
* @param endianness Endianness that will be used in the serialization of this value.
* @return Reference to the eprosima::fastcdr::Cdr object.
* @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize a position that exceeds the internal memory size.
*/
template<class _T>
Cdr& deserialize(std::vector<_T> &vector_t, Endianness endianness)
{
bool auxSwap = m_swapBytes;
m_swapBytes = (m_swapBytes && (m_endianness == endianness)) || (!m_swapBytes && (m_endianness != endianness));
try
{
deserialize(vector_t);
m_swapBytes = auxSwap;
}
catch(exception::Exception &ex)
{
m_swapBytes = auxSwap;
ex.raise();
}
return *this;
}
// TODO
template<class _T>
inline Cdr& deserialize(_T &type_t)
{
type_t.deserialize(*this);
return *this;
}
/*!
* @brief This function deserializes an array of octets.
* @param octet_t The variable that will store the array of octets read from the buffer.
* @param numElements Number of the elements in the array.
* @return Reference to the eprosima::fastcdr::Cdr object.
* @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize a position that exceeds the internal memory size.
*/
inline
Cdr& deserializeArray(uint8_t *octet_t, size_t numElements)
{
return deserializeArray((char*)octet_t, numElements);
}
/*!
* @brief This function deserializes an array of octets with a different endianness.
* @param octet_t The variable that will store the array of octets read from the buffer.
* @param numElements Number of the elements in the array.
* @param endianness Endianness that will be used in the serialization of this value.
* @return Reference to the eprosima::fastcdr::Cdr object.
* @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize a position that exceeds the internal memory size.
*/
inline
Cdr& deserializeArray(uint8_t *octet_t, size_t numElements, Endianness endianness)
{
return deserializeArray((char*)octet_t, numElements, endianness);
}
/*!
* @brief This function deserializes an array of characters.
* @param char_t The variable that will store the array of characters read from the buffer.
* @param numElements Number of the elements in the array.
* @return Reference to the eprosima::fastcdr::Cdr object.
* @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize a position that exceeds the internal memory size.
*/
Cdr& deserializeArray(char *char_t, size_t numElements);
/*!
* @brief This function deserializes an array of characters with a different endianness.
* @param char_t The variable that will store the array of characters read from the buffer.
* @param numElements Number of the elements in the array.
* @param endianness Endianness that will be used in the serialization of this value.
* @return Reference to the eprosima::fastcdr::Cdr object.
* @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize a position that exceeds the internal memory size.
*/
inline
Cdr& deserializeArray(char *char_t, size_t numElements, Endianness /*endianness*/)
{
return deserializeArray(char_t, numElements);
}
/*!
* @brief This function deserializes an array of unsigned shorts.
* @param ushort_t The variable that will store the array of unsigned shorts read from the buffer.
* @param numElements Number of the elements in the array.
* @return Reference to the eprosima::fastcdr::Cdr object.
* @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize a position that exceeds the internal memory size.
*/
inline
Cdr& deserializeArray(uint16_t *ushort_t, size_t numElements)
{
return deserializeArray((int16_t*)ushort_t, numElements);
}
/*!
* @brief This function deserializes an array of unsigned shorts with a different endianness.
* @param ushort_t The variable that will store the array of unsigned shorts read from the buffer.
* @param numElements Number of the elements in the array.
* @param endianness Endianness that will be used in the serialization of this value.
* @return Reference to the eprosima::fastcdr::Cdr object.
* @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize a position that exceeds the internal memory size.
*/
inline
Cdr& deserializeArray(uint16_t *ushort_t, size_t numElements, Endianness endianness)
{
return deserializeArray((int16_t*)ushort_t, numElements, endianness);
}
/*!
* @brief This function deserializes an array of shorts.
* @param short_t The variable that will store the array of shorts read from the buffer.
* @param numElements Number of the elements in the array.
* @return Reference to the eprosima::fastcdr::Cdr object.
* @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize a position that exceeds the internal memory size.
*/
Cdr& deserializeArray(int16_t *short_t, size_t numElements);
/*!
* @brief This function deserializes an array of shorts with a different endianness.
* @param short_t The variable that will store the array of shorts read from the buffer.
* @param numElements Number of the elements in the array.
* @param endianness Endianness that will be used in the serialization of this value.
* @return Reference to the eprosima::fastcdr::Cdr object.
* @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize a position that exceeds the internal memory size.
*/
Cdr& deserializeArray(int16_t *short_t, size_t numElements, Endianness endianness);
/*!
* @brief This function deserializes an array of unsigned longs.
* @param ulong_t The variable that will store the array of unsigned longs read from the buffer.
* @param numElements Number of the elements in the array.
* @return Reference to the eprosima::fastcdr::Cdr object.
* @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize a position that exceeds the internal memory size.
*/
inline
Cdr& deserializeArray(uint32_t *ulong_t, size_t numElements)
{
return deserializeArray((int32_t*)ulong_t, numElements);
}
/*!
* @brief This function deserializes an array of unsigned longs with a different endianness.
* @param ulong_t The variable that will store the array of unsigned longs read from the buffer.
* @param numElements Number of the elements in the array.
* @param endianness Endianness that will be used in the serialization of this value.
* @return Reference to the eprosima::fastcdr::Cdr object.
* @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize a position that exceeds the internal memory size.
*/
inline
Cdr& deserializeArray(uint32_t *ulong_t, size_t numElements, Endianness endianness)
{
return deserializeArray((int32_t*)ulong_t, numElements, endianness);
}
/*!
* @brief This function deserializes an array of longs.
* @param long_t The variable that will store the array of longs read from the buffer.
* @param numElements Number of the elements in the array.
* @return Reference to the eprosima::fastcdr::Cdr object.
* @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize a position that exceeds the internal memory size.
*/
Cdr& deserializeArray(int32_t *long_t, size_t numElements);
/*!
* @brief This function deserializes an array of longs with a different endianness.
* @param long_t The variable that will store the array of longs read from the buffer.
* @param numElements Number of the elements in the array.
* @param endianness Endianness that will be used in the serialization of this value.
* @return Reference to the eprosima::fastcdr::Cdr object.
* @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize a position that exceeds the internal memory size.
*/
Cdr& deserializeArray(int32_t *long_t, size_t numElements, Endianness endianness);
Cdr& deserializeArray(wchar_t *wchar, size_t numElements);
Cdr& deserializeArray(wchar_t *wchar, size_t numElements, Endianness endianness);
/*!
* @brief This function deserializes an array of unsigned long longs.
* @param ulonglong_t The variable that will store the array of unsigned long longs read from the buffer.
* @param numElements Number of the elements in the array.
* @return Reference to the eprosima::fastcdr::Cdr object.
* @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize a position that exceeds the internal memory size.
*/
inline
Cdr& deserializeArray(uint64_t *ulonglong_t, size_t numElements)
{
return deserializeArray((int64_t*)ulonglong_t, numElements);
}
/*!
* @brief This function deserializes an array of unsigned long longs with a different endianness.
* @param ulonglong_t The variable that will store the array of unsigned long longs read from the buffer.
* @param numElements Number of the elements in the array.
* @param endianness Endianness that will be used in the serialization of this value.
* @return Reference to the eprosima::fastcdr::Cdr object.
* @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize a position that exceeds the internal memory size.
*/
inline
Cdr& deserializeArray(uint64_t *ulonglong_t, size_t numElements, Endianness endianness)
{
return deserializeArray((int64_t*)ulonglong_t, numElements, endianness);
}
/*!
* @brief This function deserializes an array of long longs.
* @param longlong_t The variable that will store the array of long longs read from the buffer.
* @param numElements Number of the elements in the array.
* @return Reference to the eprosima::fastcdr::Cdr object.
* @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize a position that exceeds the internal memory size.
*/
Cdr& deserializeArray(int64_t *longlong_t, size_t numElements);
/*!
* @brief This function deserializes an array of long longs with a different endianness.
* @param longlong_t The variable that will store the array of long longs read from the buffer.
* @param numElements Number of the elements in the array.
* @param endianness Endianness that will be used in the serialization of this value.
* @return Reference to the eprosima::fastcdr::Cdr object.
* @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize a position that exceeds the internal memory size.
*/
Cdr& deserializeArray(int64_t *longlong_t, size_t numElements, Endianness endianness);
/*!
* @brief This function deserializes an array of floats.
* @param float_t The variable that will store the array of floats read from the buffer.
* @param numElements Number of the elements in the array.
* @return Reference to the eprosima::fastcdr::Cdr object.
* @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize a position that exceeds the internal memory size.
*/
Cdr& deserializeArray(float *float_t, size_t numElements);
/*!
* @brief This function deserializes an array of floats with a different endianness.
* @param float_t The variable that will store the array of floats read from the buffer.
* @param numElements Number of the elements in the array.
* @param endianness Endianness that will be used in the serialization of this value.
* @return Reference to the eprosima::fastcdr::Cdr object.
* @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize a position that exceeds the internal memory size.
*/
Cdr& deserializeArray(float *float_t, size_t numElements, Endianness endianness);
/*!
* @brief This function deserializes an array of doubles.
* @param double_t The variable that will store the array of doubles read from the buffer.
* @param numElements Number of the elements in the array.
* @return Reference to the eprosima::fastcdr::Cdr object.
* @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize a position that exceeds the internal memory size.
*/
Cdr& deserializeArray(double *double_t, size_t numElements);
/*!
* @brief This function deserializes an array of doubles with a different endianness.
* @param double_t The variable that will store the array of doubles read from the buffer.
* @param numElements Number of the elements in the array.
* @param endianness Endianness that will be used in the serialization of this value.
* @return Reference to the eprosima::fastcdr::Cdr object.
* @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize a position that exceeds the internal memory size.
*/
Cdr& deserializeArray(double *double_t, size_t numElements, Endianness endianness);
/*!
* @brief This function deserializes an array of booleans.
* @param bool_t The variable that will store the array of booleans read from the buffer.
* @param numElements Number of the elements in the array.
* @return Reference to the eprosima::fastcdr::Cdr object.
* @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize a position that exceeds the internal memory size.
*/
Cdr& deserializeArray(bool *bool_t, size_t numElements);
/*!
* @brief This function deserializes an array of booleans with a different endianness.
* @param bool_t The variable that will store the array of booleans read from the buffer.
* @param numElements Number of the elements in the array.
* @param endianness Endianness that will be used in the serialization of this value.
* @return Reference to the eprosima::fastcdr::Cdr object.
* @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize a position that exceeds the internal memory size.
*/
inline
Cdr& deserializeArray(bool *bool_t, size_t numElements, Endianness /*endianness*/)
{
return deserializeArray(bool_t, numElements);
}
// TODO
inline
Cdr& deserializeArray(std::string *string_t, size_t numElements)
{
for(size_t count = 0; count < numElements; ++count)
deserialize(string_t[count]);
return *this;
}
inline
Cdr& deserializeArray(std::string *string_t, size_t numElements, Endianness endianness)
{
bool auxSwap = m_swapBytes;
m_swapBytes = (m_swapBytes && (m_endianness == endianness)) || (!m_swapBytes && (m_endianness != endianness));
try
{
deserializeArray(string_t, numElements);
m_swapBytes = auxSwap;
}
catch(eprosima::fastcdr::exception::Exception &ex)
{
m_swapBytes = auxSwap;
ex.raise();
}
return *this;
}
// TODO
template<class _T>
Cdr& deserializeArray(std::vector<_T> *vector_t, size_t numElements)
{
for(size_t count = 0; count < numElements; ++count)
deserialize(vector_t[count]);
return *this;
}
// TODO
template<class _T>
Cdr& deserializeArray(_T *type_t, size_t numElements)
{
for(size_t count = 0; count < numElements; ++count)
type_t[count].deserialize(*this);
return *this;
}
template<class _T>
Cdr& deserializeArray(_T *type_t, size_t numElements, Endianness endianness)
{
bool auxSwap = m_swapBytes;
m_swapBytes = (m_swapBytes && (m_endianness == endianness)) || (!m_swapBytes && (m_endianness != endianness));
try
{
deserializeArray(type_t, numElements);
m_swapBytes = auxSwap;
}
catch(eprosima::fastcdr::exception::Exception &ex)
{
m_swapBytes = auxSwap;
ex.raise();
}
return *this;
}
#if !defined(_MSC_VER) && HAVE_CXX0X
template<class _T = std::string>
Cdr& deserializeSequence(std::string *&sequence_t, size_t &numElements)
{
return deserializeStringSequence(sequence_t, numElements);
}
#endif
/*!
* @brief This function template deserializes a raw sequence.
* This function allocates memory to store the sequence. The user pointer will be set to point this allocated memory.
* The user will have to free this allocated memory using free()
* @param sequence_t The pointer that will store the sequence read from the buffer.
* @param numElements This variable return the number of elements of the sequence.
* @return Reference to the eprosima::fastcdr::Cdr object.
* @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize a position that exceeds the internal memory size.
*/
template<class _T>
Cdr& deserializeSequence(_T *&sequence_t, size_t &numElements)
{
uint32_t seqLength = 0;
state state(*this);
deserialize(seqLength);
try
{
sequence_t = (_T*)calloc(seqLength, sizeof(_T));
deserializeArray(sequence_t, seqLength);
}
catch(eprosima::fastcdr::exception::Exception &ex)
{
free(sequence_t);
sequence_t = NULL;
setState(state);
ex.raise();
}
numElements = seqLength;
return *this;
}
#ifdef _MSC_VER
template<>
Cdr& deserializeSequence<std::string>(std::string *&sequence_t, size_t &numElements)
{
return deserializeStringSequence(sequence_t, numElements);
}
#endif
/*!
* @brief This function template deserializes a raw sequence with a different endianness.
* This function allocates memory to store the sequence. The user pointer will be set to point this allocated memory.
* The user will have to free this allocated memory using free()
* @param sequence_t The pointer that will store the sequence read from the buffer.
* @param numElements This variable return the number of elements of the sequence.
* @return Reference to the eprosima::fastcdr::Cdr object.
* @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize a position that exceeds the internal memory size.
*/
template<class _T>
Cdr& deserializeSequence(_T *&sequence_t, size_t &numElements, Endianness endianness)
{
bool auxSwap = m_swapBytes;
m_swapBytes = (m_swapBytes && (m_endianness == endianness)) || (!m_swapBytes && (m_endianness != endianness));
try
{
deserializeSequence(sequence_t, numElements);
m_swapBytes = auxSwap;
}
catch(eprosima::fastcdr::exception::Exception &ex)
{
m_swapBytes = auxSwap;
ex.raise();
}
return *this;
}
private:
Cdr(const Cdr&) NON_COPYABLE_CXX11;
Cdr& operator=(const Cdr&) NON_COPYABLE_CXX11;
Cdr& serializeBoolSequence(const std::vector<bool> &vector_t);
Cdr& deserializeBoolSequence(std::vector<bool> &vector_t);
Cdr& deserializeStringSequence(std::string *&sequence_t, size_t &numElements);
#if HAVE_CXX0X
/*!
* @brief This function template detects the content type of the STD container array and serializes the array.
* @param array_t The array that will be serialized in the buffer.
* @param numElements Number of the elements in the array.
* @return Reference to the eprosima::fastcdr::Cdr object.
* @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize a position that exceeds the internal memory size.
*/
template<class _T, size_t _Size>
Cdr& serializeArray(const std::array<_T, _Size> *array_t, size_t numElements)
{
return serializeArray(array_t->data(), numElements * array_t->size());
}
/*!
* @brief This function template detects the content type of the STD container array and serializes the array with a different endianness.
* @param array_t The array that will be serialized in the buffer.
* @param numElements Number of the elements in the array.
* @param endianness Endianness that will be used in the serialization of this value.
* @return Reference to the eprosima::fastcdr::Cdr object.
* @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize a position that exceeds the internal memory size.
*/
template<class _T, size_t _Size>
Cdr& serializeArray(const std::array<_T, _Size> *array_t, size_t numElements, Endianness endianness)
{
return serializeArray(array_t->data(), numElements * array_t->size(), endianness);
}
/*!
* @brief This function template detects the content type of the STD container array and deserializes the array.
* @param array_t The variable that will store the array read from the buffer.
* @param numElements Number of the elements in the array.
* @return Reference to the eprosima::fastcdr::Cdr object.
* @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize a position that exceeds the internal memory size.
*/
template<class _T, size_t _Size>
Cdr& deserializeArray(std::array<_T, _Size> *array_t, size_t numElements)
{
return deserializeArray(array_t->data(), numElements * array_t->size());
}
/*!
* @brief This function template detects the content type of STD container array and deserializes the array with a different endianness.
* @param array_t The variable that will store the array read from the buffer.
* @param numElements Number of the elements in the array.
* @param endianness Endianness that will be used in the serialization of this value.
* @return Reference to the eprosima::fastcdr::Cdr object.
* @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize a position that exceeds the internal memory size.
*/
template<class _T, size_t _Size>
Cdr& deserializeArray(std::array<_T, _Size> *array_t, size_t numElements, Endianness endianness)
{
return deserializeArray(array_t->data(), numElements * array_t->size(), endianness);
}
#endif
/*!
* @brief This function returns the extra bytes regarding the allignment.
* @param dataSize The size of the data that will be serialized.
* @return The size needed for the aligment.
*/
inline size_t alignment(size_t dataSize) const {return dataSize > m_lastDataSize ? (dataSize - ((m_currentPosition - m_alignPosition) % dataSize)) & (dataSize-1) : 0;}
/*!
* @brief This function jumps the number of bytes of the alignment. These bytes should be calculated with the function eprosima::fastcdr::Cdr::alignment.
* @param align The number of bytes to be skipped.
*/
inline void makeAlign(size_t align){m_currentPosition += align;}
/*!
* @brief This function resizes the internal buffer. It only applies if the FastBuffer object was created with the default constructor.
* @param minSizeInc Minimun size increase for the internal buffer
* @return True if the resize was succesful, false if it was not
*/
bool resize(size_t minSizeInc);
//TODO
const char* readString(uint32_t &length);
//! @brief Reference to the buffer that will be serialized/deserialized.
FastBuffer &m_cdrBuffer;
//! @brief The type of CDR that will be use in serialization/deserialization.
CdrType m_cdrType;
//! @brief Using DDS_CDR type, this attribute stores if the stream buffer contains a parameter list or not.
DDSCdrPlFlag m_plFlag;
//! @brief This attribute stores the option flags when the CDR type is DDS_CDR;
uint16_t m_options;
//! @brief The endianness that will be applied over the buffer.
uint8_t m_endianness;
//! @brief This attribute specifies if it is needed to swap the bytes.
bool m_swapBytes;
//! @brief Stores the last datasize serialized/deserialized. It's used to optimize.
size_t m_lastDataSize;
//! @brief The current position in the serialization/deserialization process.
FastBuffer::iterator m_currentPosition;
//! @brief The position from where the aligment is calculated.
FastBuffer::iterator m_alignPosition;
//! @brief The last position in the buffer;
FastBuffer::iterator m_lastPosition;
};
} //namespace fastcdr
} //namespace eprosima
#endif // _CDR_CDR_H_
| 0 |
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/include/fastcdr | apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/include/fastcdr/exceptions/NotEnoughMemoryException.h | // Copyright 2016 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 _FASTCDR_EXCEPTIONS_NOTENOUGHMEMORYEXCEPTION_H_
#define _FASTCDR_EXCEPTIONS_NOTENOUGHMEMORYEXCEPTION_H_
#include "Exception.h"
namespace eprosima
{
namespace fastcdr
{
namespace exception
{
/*!
* @brief This class is thrown as an exception when the buffer's internal memory reachs its size limit.
* @ingroup EXCEPTIONMODULE
*/
class NotEnoughMemoryException : public Exception
{
public:
/*!
* @brief Default constructor.
*
* @param message A error message. This message is copied.
*/
Cdr_DllAPI NotEnoughMemoryException(const char* const &message);
/*!
* @brief Default copy constructor.
*
* @param ex NotEnoughMemoryException that will be copied.
*/
Cdr_DllAPI NotEnoughMemoryException(const NotEnoughMemoryException &ex);
#if HAVE_CXX0X
/*!
* @brief Default move constructor.
*
* @param ex NotEnoughMemoryException that will be moved.
*/
Cdr_DllAPI NotEnoughMemoryException(NotEnoughMemoryException&& ex);
#endif
/*!
* @brief Assigment operation.
*
* @param ex NotEnoughMemoryException that will be copied.
*/
Cdr_DllAPI NotEnoughMemoryException& operator=(const NotEnoughMemoryException &ex);
#if HAVE_CXX0X
/*!
* @brief Assigment operation.
*
* @param ex NotEnoughMemoryException that will be moved.
*/
Cdr_DllAPI NotEnoughMemoryException& operator=(NotEnoughMemoryException&& ex);
#endif
//! @brief Default constructor
virtual Cdr_DllAPI ~NotEnoughMemoryException() throw();
//! @brief This function throws the object as exception.
virtual Cdr_DllAPI void raise() const;
//! @brief Default message used in the library.
static Cdr_DllAPI const char* const NOT_ENOUGH_MEMORY_MESSAGE_DEFAULT;
};
} //namespace exception
} //namespace fastcdr
} //namespace eprosima
#endif // _FASTCDR_EXCEPTIONS_NOTENOUGHMEMORYEXCEPTION_H_
| 0 |
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/include/fastcdr | apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/include/fastcdr/exceptions/BadParamException.h | // Copyright 2016 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 _FASTCDR_EXCEPTIONS_BADPARAMEXCEPTION_H_
#define _FASTCDR_EXCEPTIONS_BADPARAMEXCEPTION_H_
#include "Exception.h"
namespace eprosima
{
namespace fastcdr
{
namespace exception
{
/*!
* @brief This class is thrown as an exception when a invalid parameter was being serialized.
* @ingroup EXCEPTIONMODULE
*/
class BadParamException : public Exception
{
public:
/*!
* @brief Default constructor.
*
* @param message A error message. This message is copied.
*/
Cdr_DllAPI BadParamException(const char* const &message);
/*!
* @brief Default copy constructor.
*
* @param ex BadParamException that will be copied.
*/
Cdr_DllAPI BadParamException(const BadParamException &ex);
#if HAVE_CXX0X
/*!
* @brief Default move constructor.
*
* @param ex BadParamException that will be moved.
*/
Cdr_DllAPI BadParamException(BadParamException&& ex);
#endif
/*!
* @brief Assigment operation.
*
* @param ex BadParamException that will be copied.
*/
Cdr_DllAPI BadParamException& operator=(const BadParamException &ex);
#if HAVE_CXX0X
/*!
* @brief Assigment operation.
*
* @param ex BadParamException that will be moved.
*/
BadParamException& operator=(BadParamException&& ex);
#endif
//! @brief Default constructor
virtual Cdr_DllAPI ~BadParamException() throw();
//! @brief This function throws the object as exception.
virtual Cdr_DllAPI void raise() const;
//! @brief Default message used in the library.
static Cdr_DllAPI const char* const BAD_PARAM_MESSAGE_DEFAULT;
};
} //namespace exception
} //namespace fastcdr
} //namespace eprosima
#endif // _FASTCDR_EXCEPTIONS_BADPARAMEXCEPTION_H_
| 0 |
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/include/fastcdr | apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/include/fastcdr/exceptions/Exception.h | // Copyright 2016 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 _FASTCDR_EXCEPTIONS_EXCEPTION_H_
#define _FASTCDR_EXCEPTIONS_EXCEPTION_H_
#include "../fastcdr_dll.h"
#include <string>
#include <exception>
namespace eprosima
{
namespace fastcdr
{
namespace exception
{
/*!
* @brief This abstract class is used to create exceptions.
* @ingroup EXCEPTIONMODULE
*/
class Exception : public std::exception
{
public:
//! \brief Default destructor.
virtual Cdr_DllAPI ~Exception() throw();
//! \brief This function throws the object as exception.
virtual Cdr_DllAPI void raise() const = 0;
/*!
* @brief This function returns the error message.
*
* @return The error message.
*/
virtual Cdr_DllAPI const char* what() const throw() ;
protected:
/*!
* @brief Default constructor.
*
* @param message A error message. This message is copied.
*/
Cdr_DllAPI Exception(const char* const &message);
/*!
* @brief Default copy constructor.
*
* @param ex Exception that will be copied.
*/
Cdr_DllAPI Exception(const Exception &ex);
#if HAVE_CXX0X
/*!
* @brief Default move constructor.
*
* @param ex Exception that will be moved.
*/
Cdr_DllAPI Exception(Exception&& ex);
#endif
/*!
* @brief Assigment operation.
*
* @param ex Exception that will be copied.
*/
Cdr_DllAPI Exception& operator=(const Exception &ex);
#if HAVE_CXX0X
/*!
* @brief Assigment operation.
*
* @param ex Exception that will be moved.
*/
Cdr_DllAPI Exception& operator=(Exception&&);
#endif
private:
std::string m_message;
};
} //namespace exception
} //namespace fastcdr
} //namespace eprosima
#endif // _FASTCDR_EXCEPTIONS_EXCEPTION_H_
| 0 |
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/share/fastrtps/examples/C++ | apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/share/fastrtps/examples/C++/SampleConfig_Multimedia/CMakeLists.txt | # Copyright 2016 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.
cmake_minimum_required(VERSION 2.8.12)
project("UseCaseDemonstrator")
# Find requirements
find_package(fastcdr REQUIRED)
find_package(fastrtps REQUIRED)
# Set C++11
include(CheckCXXCompilerFlag)
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_CLANG OR
CMAKE_CXX_COMPILER_ID MATCHES "Clang")
check_cxx_compiler_flag(--std=c++11 SUPPORTS_CXX11)
if(SUPPORTS_CXX11)
add_compile_options(--std=c++11)
else()
message(FATAL_ERROR "Compiler doesn't support C++11")
endif()
endif()
message(STATUS "Configuring UseCaseDemonstrator example...")
file(GLOB USECASEDEMONSTRATOR_EXAMPLE_SOURCES "*.cxx")
add_executable(sampleconfig_multimedia ${USECASEDEMONSTRATOR_EXAMPLE_SOURCES} sampleconfig_fastest.cpp)
target_link_libraries(sampleconfig_multimedia fastrtps fastcdr)
install(TARGETS sampleconfig_multimedia
RUNTIME DESTINATION examples/C++/UseCaseDemonstrator/${BIN_INSTALL_DIR}
)
| 0 |
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/share/fastrtps/examples/C++ | apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/share/fastrtps/examples/C++/SampleConfig_Multimedia/samplePubSubTypes.h | // Copyright 2016 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.
/*!
* @file samplePubSubTypes.h
* This header file contains the declaration of the serialization functions.
*
* This file was generated by the tool fastcdrgen.
*/
#ifndef _SAMPLE_PUBSUBTYPES_H_
#define _SAMPLE_PUBSUBTYPES_H_
#include <fastrtps/TopicDataType.h>
using namespace eprosima::fastrtps;
#include "sample.h"
/*!
* @brief This class represents the TopicDataType of the type sample defined by the user in the IDL file.
* @ingroup SAMPLE
*/
class samplePubSubType : public TopicDataType {
public:
typedef sample type;
samplePubSubType();
virtual ~samplePubSubType();
bool serialize(void *data, SerializedPayload_t *payload);
bool deserialize(SerializedPayload_t *payload, void *data);
std::function<uint32_t()> getSerializedSizeProvider(void* data);
bool getKey(void *data, InstanceHandle_t *ihandle);
void* createData();
void deleteData(void * data);
MD5 m_md5;
unsigned char* m_keyBuffer;
};
#endif // _sample_PUBSUBTYPE_H_ | 0 |
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/share/fastrtps/examples/C++ | apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/share/fastrtps/examples/C++/SampleConfig_Multimedia/Makefile | # Copyright 2016 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.
CPP=g++
LN=g++
AR=ar
CP=cp
SYSLIBS= -ldl -lnsl -lm -lpthread -lrt
DEFINES=
COMMON_CFLAGS= -c -Wall -D__LITTLE_ENDIAN__ -std=c++11
## CHOOSE HERE BETWEEN 32 and 64 bit architecture
##32 BIT ARCH:
#COMMON_CFLAGS+= -m32 -fpic
#LDFLAGS=-m32
#64BIT ARCH:
COMMON_CFLAGS+= -m64 -fpic
LDFLAGS=-m64
CFLAGS = $(COMMON_CFLAGS) -O2
INCLUDES= -I.
LIBS = -lfastcdr -lfastrtps $(SYSLIBS)
DIRECTORIES= output.dir bin.dir
all: $(DIRECTORIES) SampleConfig_Multimedia
SAMPLECONFIG_MULTIMEDIA_TARGET= bin/SampleConfig_Multimedia
SAMPLECONFIG_MULTIMEDIA_SRC_CXXFILES=
SAMPLECONFIG_MULTIMEDIA_SRC_CPPFILES= SampleConfig_Multimedia/sampleconfig_fastest.cpp \
SampleConfig_Multimedia/sample.cxx \
SampleConfig_Multimedia/samplePubSubTypes.cxx
# Project sources are copied to the current directory
SAMPLECONFIG_MULTIMEDIA_SRCS= $(SAMPLECONFIG_MULTIMEDIA_SRC_CXXFILES) $(SAMPLECONFIG_MULTIMEDIA_SRC_CPPFILES)
# Source directories
SAMPLECONFIG_MULTIMEDIA_SOURCES_DIRS_AUX= $(foreach srcdir, $(dir $(SAMPLECONFIG_MULTIMEDIA_SRCS)), $(srcdir))
SAMPLECONFIG_MULTIMEDIA_SOURCES_DIRS= $(shell echo $(SAMPLECONFIG_MULTIMEDIA_SOURCES_DIRS_AUX) | tr " " "\n" | sort | uniq | tr "\n" " ")
SAMPLECONFIG_MULTIMEDIA_OBJS = $(foreach obj,$(notdir $(addsuffix .o, $(SAMPLECONFIG_MULTIMEDIA_SRCS))), output/$(obj))
SAMPLECONFIG_MULTIMEDIA_DEPS = $(foreach dep,$(notdir $(addsuffix .d, $(SAMPLECONFIG_MULTIMEDIA_SRCS))), output/$(dep))
OBJS+= $(SAMPLECONFIG_MULTIMEDIA_OBJS)
DEPS+= $(SAMPLECONFIG_MULTIMEDIA_DEPS)
SampleConfig_Multimedia: $(SAMPLECONFIG_MULTIMEDIA_TARGET)
$(SAMPLECONFIG_MULTIMEDIA_TARGET): $(SAMPLECONFIG_MULTIMEDIA_OBJS)
$(LN) $(LDFLAGS) -o $(SAMPLECONFIG_MULTIMEDIA_TARGET) $(SAMPLECONFIG_MULTIMEDIA_OBJS) $(LIBS)
vpath %.cxx $(SAMPLECONFIG_MULTIMEDIA_SOURCES_DIRS)
vpath %.cpp $(SAMPLECONFIG_MULTIMEDIA_SOURCES_DIRS)
output/%.cxx.o:%.cxx
@echo Calculating dependencies $<
@$(CC) $(CFLAGS) -MM $(CFLAGS) $(INCLUDES) $< | sed "s/^.*:/output\/&/g" > $(@:%.cxx.o=%.cxx.d)
@echo Compiling $<
@$(CC) $(CFLAGS) $(INCLUDES) $< -o $@
output/%.cpp.o:%.cpp
@echo Calculating dependencies $<
@$(CPP) $(CFLAGS) -MM $(CFLAGS) $(INCLUDES) $< | sed "s/^.*:/output\/&/g" > $(@:%.cpp.o=%.cpp.d)
@echo Compiling $<
@$(CPP) $(CFLAGS) $(INCLUDES) $< -o $@
.PHONY: SampleConfig_Multimedia
clean:
@rm -f $(OBJS)
@rm -f $(DEPS)
ifneq ($(MAKECMDGOALS), clean)
-include $(DEPS)
endif
%.dir :
@echo "Checking directory $*"
@if [ ! -d $* ]; then \
echo "Making directory $*"; \
mkdir -p $* ; \
fi;
| 0 |
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/share/fastrtps/examples/C++ | apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/share/fastrtps/examples/C++/SampleConfig_Multimedia/sampleconfig_fastest.cpp | #include <iostream>
#include <string>
#include <fastrtps/participant/Participant.h>
#include <fastrtps/attributes/ParticipantAttributes.h>
#include <fastrtps/subscriber/Subscriber.h>
#include <fastrtps/attributes/SubscriberAttributes.h>
#include <fastrtps/publisher/Publisher.h>
#include <fastrtps/attributes/PublisherAttributes.h>
#include <fastrtps/Domain.h>
#include <fastrtps/subscriber/SampleInfo.h>
#include <fastrtps/utils/eClock.h>
#include "samplePubSubTypes.h"
//Enums and configuration structure
enum Reliability_type { Best_Effort, Reliable };
enum Durability_type { Transient_Local, Volatile };
enum HistoryKind_type { Keep_Last, Keep_All };
enum Key_type { No_Key, With_Key};
typedef struct{
Reliability_type reliability;
Durability_type durability;
HistoryKind_type historykind;
Key_type keys;
uint16_t history_size;
uint8_t depth;
uint8_t no_keys;
uint16_t max_samples_per_key;
} example_configuration;
void fastest();
int main(){
fastest();
return 0;
}
void fastest(){
samplePubSubType sampleType;
sample my_sample;
SampleInfo_t sample_info;
ParticipantAttributes PparamPub;
PparamPub.rtps.builtin.domainId = 0;
PparamPub.rtps.builtin.leaseDuration = c_TimeInfinite;
PparamPub.rtps.setName("PublisherParticipant");
Participant *PubParticipant = Domain::createParticipant(PparamPub);
if(PubParticipant == nullptr){
std::cout << " Something went wrong while creating the Publisher Participant..." << std::endl;
return;
}
Domain::registerType(PubParticipant,(TopicDataType*) &sampleType);
//Publisher config
PublisherAttributes Pparam;
Pparam.topic.topicDataType = sampleType.getName();
Pparam.topic.topicName = "samplePubSubTopic";
Pparam.historyMemoryPolicy = DYNAMIC_RESERVE_MEMORY_MODE;
Pparam.topic.topicKind = NO_KEY;
Pparam.topic.historyQos.kind = KEEP_LAST_HISTORY_QOS;
Pparam.qos.m_durability.kind = VOLATILE_DURABILITY_QOS;
Pparam.qos.m_reliability.kind = BEST_EFFORT_RELIABILITY_QOS;
Pparam.topic.historyQos.depth = 50;
Pparam.topic.resourceLimitsQos.max_samples = 100;
Pparam.topic.resourceLimitsQos.max_instances = 1;
Pparam.topic.resourceLimitsQos.max_samples_per_instance = 100;
std::cout << "Creating Best-Effort Publisher..." << std::endl;
Publisher *myPub= Domain::createPublisher(PubParticipant, Pparam, nullptr);
if(myPub == nullptr){
std::cout << "Something went wrong while creating the Publisher..." << std::endl;
return;
}
ParticipantAttributes PparamSub;
PparamSub.rtps.builtin.domainId = 0;
PparamSub.rtps.builtin.leaseDuration = c_TimeInfinite;
PparamSub.rtps.setName("SubscriberParticipant");
Participant *SubParticipant = Domain::createParticipant(PparamSub);
if(SubParticipant == nullptr){
std::cout << " Something went wrong while creating the Subscriber Participant..." << std::endl;
return;
}
Domain::registerType(SubParticipant,(TopicDataType*) &sampleType);
// Sub
SubscriberAttributes Rparam;
Rparam.topic.topicDataType = sampleType.getName();
Rparam.topic.topicName = "samplePubSubTopic";
Rparam.historyMemoryPolicy = DYNAMIC_RESERVE_MEMORY_MODE;
Rparam.topic.topicKind = NO_KEY;
Rparam.topic.historyQos.kind = KEEP_LAST_HISTORY_QOS;
Rparam.qos.m_durability.kind = VOLATILE_DURABILITY_QOS;
Rparam.qos.m_reliability.kind = BEST_EFFORT_RELIABILITY_QOS;
Rparam.topic.historyQos.depth = 50;
Rparam.topic.resourceLimitsQos.max_samples = 100;
Rparam.topic.resourceLimitsQos.max_instances = 1;
Rparam.topic.resourceLimitsQos.max_samples_per_instance = 100;
std::cout << "Creating Subscriber..." << std::endl;
Subscriber *mySub1= Domain::createSubscriber(PubParticipant, Rparam, nullptr);
if(myPub == nullptr){
std::cout << "something went wrong while creating the Subscriber..." << std::endl;
return;
}
//Send 20 samples
std::cout << "Publishing 10 samples on the topic..." << std::endl;
for(uint8_t j=0; j < 10; j++){
my_sample.index(j+1);
my_sample.key_value(1);
myPub->write(&my_sample);
}
eClock::my_sleep(1500);
//Read the contents of both histories:
std::cout << "The Reliable Subscriber holds: " << std::endl;
while(mySub1->readNextData(&my_sample, &sample_info)){
std::cout << std::to_string(my_sample.index()) << " ";
}
std::cout << std::endl;
}
| 0 |
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/share/fastrtps/examples/C++ | apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/share/fastrtps/examples/C++/SampleConfig_Multimedia/sample.cxx | // Copyright 2016 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.
/*!
* @file sample.cpp
* This source file contains the definition of the described types in the IDL file.
*
* This file was generated by the tool gen.
*/
#ifdef _WIN32
// Remove linker warning LNK4221 on Visual Studio
namespace { char dummy; }
#endif
#include "sample.h"
#include <fastcdr/Cdr.h>
#include <fastcdr/exceptions/BadParamException.h>
using namespace eprosima::fastcdr::exception;
#include <utility>
sample::sample()
{
m_index = 0;
m_key_value = 0;
}
sample::~sample()
{
}
sample::sample(const sample &x)
{
m_index = x.m_index;
m_key_value = x.m_key_value;
}
sample::sample(sample &&x)
{
m_index = x.m_index;
m_key_value = x.m_key_value;
}
sample& sample::operator=(const sample &x)
{
m_index = x.m_index;
m_key_value = x.m_key_value;
return *this;
}
sample& sample::operator=(sample &&x)
{
m_index = x.m_index;
m_key_value = x.m_key_value;
return *this;
}
size_t sample::getMaxCdrSerializedSize(size_t current_alignment)
{
size_t initial_alignment = current_alignment;
current_alignment += 1 + eprosima::fastcdr::Cdr::alignment(current_alignment, 1);
current_alignment += 1 + eprosima::fastcdr::Cdr::alignment(current_alignment, 1);
return current_alignment - initial_alignment;
}
size_t sample::getCdrSerializedSize(const sample& data, size_t current_alignment)
{
size_t initial_alignment = current_alignment;
current_alignment += 1 + eprosima::fastcdr::Cdr::alignment(current_alignment, 1);
current_alignment += 1 + eprosima::fastcdr::Cdr::alignment(current_alignment, 1);
return current_alignment - initial_alignment;
}
void sample::serialize(eprosima::fastcdr::Cdr &scdr) const
{
scdr << m_index;
scdr << m_key_value;
}
void sample::deserialize(eprosima::fastcdr::Cdr &dcdr)
{
dcdr >> m_index;
dcdr >> m_key_value;
}
size_t sample::getKeyMaxCdrSerializedSize(size_t current_alignment)
{
size_t current_align = current_alignment;
current_align += 1 + eprosima::fastcdr::Cdr::alignment(current_align, 1);
return current_align;
}
bool sample::isKeyDefined()
{
return true;
}
void sample::serializeKey(eprosima::fastcdr::Cdr &scdr) const
{
scdr << m_key_value;
} | 0 |
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/share/fastrtps/examples/C++ | apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/share/fastrtps/examples/C++/SampleConfig_Multimedia/README.txt | ------------------------------------------------
- Use Case Sample Configuration: Controller for eProsima Fast RTPS -
------------------------------------------------
1 - Application description
---------------------------
eProsima Fast RTPS provides users with a wide range of configuration options. This example has the objective of providing a testing ground where you can experiment and see the influence different combinations of parameters can have on the behaviours on the Publisher/Subscriber scheme.
This example is a supplement to the UseCaseLauncher example, consisting on an application which ilustrates the effect the different kinds of Subscriber Histories have on sample storage.
2 - Configuration options
--------------------------
These are the main parameters that affect the behaviour of eProsima Fast RTPS and that are used in the Use Case set of example:
- Reliability Kind
Defines how eProsima Fast RTPS deals upon possible packet loss during data exchanges.
+ Best Effort: No arrival confirmation. It is fast but lost samples are not re-sent.
+ Reliable: With arrival confirmation. It is slower but provides guarantee that all lost samples are re-sent and eventually received by the subscriber.
Since this application runs the Publisher and Subscriber on the same machine, data loss is highly unlikely. Therefore this option will not play a relevant role on the application behaviour.
- Durability Kind
Defines what to do with samples that exist prior to the existence of the Subscriber.
+ Volatile: Past samples are ignored, the Subscriber starts to receive data generated after it has joined the network.
+ Transient Local: Past samples are sent.
- History Kind
Defines the storage policy for past samples.
+ Keep Last: The History will save and give access to the alst "k" received samples. This "k" number is called the History Depth and can be manually set too by the user.
+ Keep All: The History will save and give access to all received samples until the maximum samples size of the History is reached.
This parameter affects cases of "late-joining" Subscribers: Subscribers that come online after data transfers on a topic have started.
- Keys
Keys allow to have multiple data endpoints within a topic as opposed to all data published in a topic going into the same "inbox".
+ On a topic without keys, all pieces of data go into a single endpoint.
+ On a topic without keys, the key field is used to determine which of the multiple endpoints the data goes into. If, for example, a history is set to transient local with depth=3 (the last three samples are stores) then eProsima FastRTPS will ensure that 3 samples per data endpoint are stored. This means that three samples are stored for each unique key instead of three samples total.
It is important to note that even if you configure a Topic and your History to be able to hold items from multiple keys, this configuration does not take effect unless you explicitly enable Keys.
- Depth
The depth is the amount of past samples that are stored in the history before starting to overwrite. Only takes effect when the History is on "Keep Last" mode.
- History Size
This accounts for the total number of samples that can be stored in the history, regardless of any other configuration option.
- Instances
Instances are the different data sinks the History is divided and act as receptors of the Keys.
- Instance size
As it happens with depth, you can define a maximun number of past samples to be stored. If you set one Instance and an instance size more restrictive than the depth, the instance size will be the limiting factor.
5. Application examples
----------------------
The following list provides examples configurations for real-life scenarios, including the present example.
- Multimedia feed
Audio and Video transmission have a common characteristic: Having a stable, high datarate feed is more important than having a 100% lossless transmission.
Reliability: Best-Effort. We want to have a fast tranmission. If a sample is lost, it can be recovered via error-correcting algorithms.
Durability: Volatile. We do not mind data from the past, we want to stream what is happening in the present.
History: Keep-Last with Low Depth. Once displayed or recorded on the receiving application, they are not needed in the History.
note: In the case of video, depth can be as low as 1. A missing sample of a 50 frames per second stream represents virtually no information loss.
- Distributed measurement: Controllers
Lets say we have a factory with a network of distributed temperature sensors and we want to use eProsima Fast RTPS to send data from said sensors to an automation computer which
makes decisions based on the temperature distribution. We would group all sensors within one single topic,
Reliability: Reliable. We want to make sure samples are not lost. Furthermore, since reliable more ensures data delivery, it allows us to detect hardware problems when a sensor becomes silent
Keys: We use a separate key for each sensor. That way new messages from one sensor dont affect the storage of past samples from another sensor.
Durability: Transient Local. We dont want to lose samples due a sensor losing connection temporarily.
History: Keep-Last with High Depth. We want to have access to past samples in order to be able to compute delta values.
- Event-based transmission
In some cases, you may want to transmit information only under certain circumstances that happen in your system, for example a photo from a surveillance camera when it detects movement.
In these cases and due to the low it is important that all datagrams reach their destination
Reliability: Reliable. All samples must reach their destination.
Durability: Volatile. Since corrective actions are taken as events come, past triggers provide have no use.
History: Keep-Last. No past alarm information is necessary for present-time transmissions.
Additional Settings: Reduce heartbeat period, which dictates system response velocity when a sample is lost. A lower heartbeat period equals fast response on data delivery.
| 0 |
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/share/fastrtps/examples/C++ | apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/share/fastrtps/examples/C++/SampleConfig_Multimedia/sample.idl | struct sample{
octet index;
@Key octet key_value;
};
| 0 |
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/share/fastrtps/examples/C++ | apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/share/fastrtps/examples/C++/SampleConfig_Multimedia/sample.h | // Copyright 2016 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.
/*!
* @file sample.h
* This header file contains the declaration of the described types in the IDL file.
*
* This file was generated by the tool gen.
*/
#ifndef _sample_H_
#define _sample_H_
// TODO Poner en el contexto.
#include <stdint.h>
#include <array>
#include <string>
#include <vector>
#if defined(_WIN32)
#if defined(EPROSIMA_USER_DLL_EXPORT)
#define eProsima_user_DllExport __declspec( dllexport )
#else
#define eProsima_user_DllExport
#endif
#else
#define eProsima_user_DllExport
#endif
#if defined(_WIN32)
#if defined(EPROSIMA_USER_DLL_EXPORT)
#if defined(sample_SOURCE)
#define sample_DllAPI __declspec( dllexport )
#else
#define sample_DllAPI __declspec( dllimport )
#endif // sample_SOURCE
#else
#define sample_DllAPI
#endif
#else
#define sample_DllAPI
#endif // _WIN32
namespace eprosima
{
namespace fastcdr
{
class Cdr;
}
}
/*!
* @brief This class represents the structure sample defined by the user in the IDL file.
* @ingroup SAMPLE
*/
class sample
{
public:
/*!
* @brief Default constructor.
*/
eProsima_user_DllExport sample();
/*!
* @brief Default destructor.
*/
eProsima_user_DllExport ~sample();
/*!
* @brief Copy constructor.
* @param x Reference to the object sample that will be copied.
*/
eProsima_user_DllExport sample(const sample &x);
/*!
* @brief Move constructor.
* @param x Reference to the object sample that will be copied.
*/
eProsima_user_DllExport sample(sample &&x);
/*!
* @brief Copy assignment.
* @param x Reference to the object sample that will be copied.
*/
eProsima_user_DllExport sample& operator=(const sample &x);
/*!
* @brief Move assignment.
* @param x Reference to the object sample that will be copied.
*/
eProsima_user_DllExport sample& operator=(sample &&x);
/*!
* @brief This function sets a value in member index
* @param _index New value for member index
*/
inline eProsima_user_DllExport void index(uint8_t _index)
{
m_index = _index;
}
/*!
* @brief This function returns the value of member index
* @return Value of member index
*/
inline eProsima_user_DllExport uint8_t index() const
{
return m_index;
}
/*!
* @brief This function returns a reference to member index
* @return Reference to member index
*/
inline eProsima_user_DllExport uint8_t& index()
{
return m_index;
}
/*!
* @brief This function sets a value in member key_value
* @param _key_value New value for member key_value
*/
inline eProsima_user_DllExport void key_value(uint8_t _key_value)
{
m_key_value = _key_value;
}
/*!
* @brief This function returns the value of member key_value
* @return Value of member key_value
*/
inline eProsima_user_DllExport uint8_t key_value() const
{
return m_key_value;
}
/*!
* @brief This function returns a reference to member key_value
* @return Reference to member key_value
*/
inline eProsima_user_DllExport uint8_t& key_value()
{
return m_key_value;
}
/*!
* @brief This function returns the maximum serialized size of an object
* depending on the buffer alignment.
* @param current_alignment Buffer alignment.
* @return Maximum serialized size.
*/
eProsima_user_DllExport static size_t getMaxCdrSerializedSize(size_t current_alignment = 0);
/*!
* @brief This function returns the serialized size of a data depending on the buffer alignment.
* @param data Data which is calculated its serialized size.
* @param current_alignment Buffer alignment.
* @return Serialized size.
*/
eProsima_user_DllExport static size_t getCdrSerializedSize(const sample& data, size_t current_alignment = 0);
/*!
* @brief This function serializes an object using CDR serialization.
* @param cdr CDR serialization object.
*/
eProsima_user_DllExport void serialize(eprosima::fastcdr::Cdr &cdr) const;
/*!
* @brief This function deserializes an object using CDR serialization.
* @param cdr CDR serialization object.
*/
eProsima_user_DllExport void deserialize(eprosima::fastcdr::Cdr &cdr);
/*!
* @brief This function returns the maximum serialized size of the Key of an object
* depending on the buffer alignment.
* @param current_alignment Buffer alignment.
* @return Maximum serialized size.
*/
eProsima_user_DllExport static size_t getKeyMaxCdrSerializedSize(size_t current_alignment = 0);
/*!
* @brief This function tells you if the Key has been defined for this type
*/
eProsima_user_DllExport static bool isKeyDefined();
/*!
* @brief This function serializes the key members of an object using CDR serialization.
* @param cdr CDR serialization object.
*/
eProsima_user_DllExport void serializeKey(eprosima::fastcdr::Cdr &cdr) const;
private:
uint8_t m_index;
uint8_t m_key_value;
};
#endif // _sample_H_ | 0 |
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/share/fastrtps/examples/C++ | apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/share/fastrtps/examples/C++/SampleConfig_Multimedia/samplePubSubTypes.cxx | // Copyright 2016 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.
/*!
* @file samplePubSubTypes.cpp
* This header file contains the implementation of the serialization functions.
*
* This file was generated by the tool fastcdrgen.
*/
#include <fastcdr/FastBuffer.h>
#include <fastcdr/Cdr.h>
#include "samplePubSubTypes.h"
samplePubSubType::samplePubSubType() {
setName("sample");
m_typeSize = (uint32_t)sample::getMaxCdrSerializedSize() + 4 /*encapsulation*/;
m_isGetKeyDefined = sample::isKeyDefined();
m_keyBuffer = (unsigned char*)malloc(sample::getKeyMaxCdrSerializedSize()>16 ? sample::getKeyMaxCdrSerializedSize() : 16);
}
samplePubSubType::~samplePubSubType() {
if(m_keyBuffer!=nullptr)
free(m_keyBuffer);
}
bool samplePubSubType::serialize(void *data, SerializedPayload_t *payload) {
sample *p_type = (sample*) data;
eprosima::fastcdr::FastBuffer fastbuffer((char*) payload->data, payload->max_size); // Object that manages the raw buffer.
eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN,
eprosima::fastcdr::Cdr::DDS_CDR);
payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE;
// Serialize encapsulation
ser.serialize_encapsulation();
p_type->serialize(ser); // Serialize the object:
payload->length = (uint32_t)ser.getSerializedDataLength(); //Get the serialized length
return true;
}
bool samplePubSubType::deserialize(SerializedPayload_t* payload, void* data) {
sample* p_type = (sample*) data; //Convert DATA to pointer of your type
eprosima::fastcdr::FastBuffer fastbuffer((char*)payload->data, payload->length); // Object that manages the raw buffer.
eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN,
eprosima::fastcdr::Cdr::DDS_CDR); // Object that deserializes the data.
// Deserialize encapsulation.
deser.read_encapsulation();
payload->encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE;
p_type->deserialize(deser); //Deserialize the object:
return true;
}
std::function<uint32_t()> samplePubSubType::getSerializedSizeProvider(void* data) {
return [data]() -> uint32_t {
return (uint32_t)type::getCdrSerializedSize(*static_cast<sample*>(data)) + 4 /*encapsulation*/;
};
}
void* samplePubSubType::createData() {
return (void*)new sample();
}
void samplePubSubType::deleteData(void* data) {
delete((sample*)data);
}
bool samplePubSubType::getKey(void *data, InstanceHandle_t* handle) {
if(!m_isGetKeyDefined)
return false;
sample* p_type = (sample*) data;
eprosima::fastcdr::FastBuffer fastbuffer((char*)m_keyBuffer,sample::getKeyMaxCdrSerializedSize()); // Object that manages the raw buffer.
eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS); // Object that serializes the data.
p_type->serializeKey(ser);
if(sample::getKeyMaxCdrSerializedSize()>16) {
m_md5.init();
m_md5.update(m_keyBuffer,(unsigned int)ser.getSerializedDataLength());
m_md5.finalize();
for(uint8_t i = 0;i<16;++i) {
handle->value[i] = m_md5.digest[i];
}
}
else {
for(uint8_t i = 0;i<16;++i) {
handle->value[i] = m_keyBuffer[i];
}
}
return true;
}
| 0 |
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/share/fastrtps/examples/C++ | apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/share/fastrtps/examples/C++/ClientServerTest/CMakeLists.txt | # Copyright 2016 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.
cmake_minimum_required(VERSION 2.8.12)
project("ClientServerTest")
# Find requirements
find_package(fastcdr REQUIRED)
find_package(fastrtps REQUIRED)
# Set C++11
include(CheckCXXCompilerFlag)
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_CLANG OR
CMAKE_CXX_COMPILER_ID MATCHES "Clang")
check_cxx_compiler_flag(--std=c++11 SUPPORTS_CXX11)
if(SUPPORTS_CXX11)
add_compile_options(--std=c++11)
else()
message(FATAL_ERROR "Compiler doesn't support C++11")
endif()
endif()
message(STATUS "Configuring ClientServerTest...")
file(GLOB CLIENTSERVERTEST_SOURCES "*.cpp")
add_executable(ClientServerTest ${CLIENTSERVERTEST_SOURCES})
target_link_libraries(ClientServerTest fastrtps fastcdr)
install(TARGETS ClientServerTest
RUNTIME DESTINATION examples/C++/ClientServerTest/${BIN_INSTALL_DIR}
)
| 0 |
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/share/fastrtps/examples/C++ | apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/share/fastrtps/examples/C++/ClientServerTest/EprosimaServer.cpp | // Copyright 2016 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.
/**
* @file EprosimaServer.cpp
*
*/
#include "EprosimaServer.h"
#include "fastrtps/fastrtps_all.h"
EprosimaServer::EprosimaServer():
mp_operation_sub(nullptr),
mp_result_pub(nullptr),
mp_participant(nullptr),
mp_resultdatatype(nullptr),
mp_operationdatatype(nullptr),
m_n_served(0),
m_operationsListener(nullptr),
m_resultsListener(nullptr)
{
m_operationsListener.mp_up = this;
m_resultsListener.mp_up = this;
}
EprosimaServer::~EprosimaServer()
{
if(mp_participant!=nullptr)
{
Domain::removeParticipant(mp_participant);
}
if(mp_resultdatatype!=nullptr)
delete(mp_resultdatatype);
if(mp_operationdatatype!=nullptr)
delete(mp_operationdatatype);
}
void EprosimaServer::serve()
{
cout << "Enter a number to stop the server: ";
int aux;
std::cin >> aux;
}
void EprosimaServer::serve(uint32_t samples)
{
while(m_n_served < samples)
eClock::my_sleep(100);
}
bool EprosimaServer::init()
{
//CREATE RTPSParticipant
ParticipantAttributes PParam;
PParam.rtps.defaultSendPort = 10042;
PParam.rtps.builtin.domainId = 80;
PParam.rtps.builtin.use_SIMPLE_EndpointDiscoveryProtocol = true;
PParam.rtps.builtin.use_SIMPLE_RTPSParticipantDiscoveryProtocol = true;
PParam.rtps.builtin.m_simpleEDP.use_PublicationReaderANDSubscriptionWriter = true;
PParam.rtps.builtin.m_simpleEDP.use_PublicationWriterANDSubscriptionReader = true;
PParam.rtps.builtin.leaseDuration = c_TimeInfinite;
PParam.rtps.setName("server_RTPSParticipant");
mp_participant = Domain::createParticipant(PParam);
if(mp_participant == nullptr)
return false;
//REGISTER TYPES
mp_resultdatatype = new ResultDataType();
mp_operationdatatype = new OperationDataType();
Domain::registerType(mp_participant,mp_resultdatatype);
Domain::registerType(mp_participant,mp_operationdatatype);
// DATA PUBLISHER
PublisherAttributes PubDataparam;
PubDataparam.topic.topicDataType = "Result";
PubDataparam.topic.topicKind = NO_KEY;
PubDataparam.topic.topicName = "Results";
PubDataparam.topic.historyQos.kind = KEEP_LAST_HISTORY_QOS;
PubDataparam.topic.historyQos.depth = 1000;
PubDataparam.topic.resourceLimitsQos.max_samples = 1500;
PubDataparam.topic.resourceLimitsQos.allocated_samples = 1000;
PubDataparam.qos.m_reliability.kind = RELIABLE_RELIABILITY_QOS;
mp_result_pub = Domain::createPublisher(mp_participant,PubDataparam,(PublisherListener*)&this->m_resultsListener);
if(mp_result_pub == nullptr)
return false;
//DATA SUBSCRIBER
SubscriberAttributes SubDataparam;
Locator_t loc;
loc.port = 7555;
PubDataparam.unicastLocatorList.push_back(loc);
SubDataparam.topic.topicDataType = "Operation";
SubDataparam.topic.topicKind = NO_KEY;
SubDataparam.topic.topicName = "Operations";
SubDataparam.topic.historyQos.kind = KEEP_LAST_HISTORY_QOS;
SubDataparam.topic.historyQos.depth = 1000;
SubDataparam.topic.resourceLimitsQos.max_samples = 1500;
SubDataparam.topic.resourceLimitsQos.allocated_samples = 1000;
mp_operation_sub = Domain::createSubscriber(mp_participant,SubDataparam,(SubscriberListener*)&this->m_operationsListener);
if(mp_operation_sub == nullptr)
return false;
return true;
}
Result::RESULTTYPE EprosimaServer::calculate(Operation::OPERATIONTYPE type,
int32_t num1, int32_t num2, int32_t* result)
{
switch(type)
{
case Operation::SUBTRACTION:
{
*result = num1-num2;
break;
}
case Operation::ADDITION:
{
*result = num1+num2;
break;
}
case Operation::MULTIPLICATION:
{
*result = num1*num2;
break;
}
case Operation::DIVISION:
{
if(num2 == 0)
return Result::ERROR_RESULT;
break;
}
}
return Result::GOOD_RESULT;
}
void EprosimaServer::OperationListener::onNewDataMessage(Subscriber* sub)
{
mp_up->mp_operation_sub->takeNextData((void*)&m_operation,&m_sampleInfo);
if(m_sampleInfo.sampleKind == ALIVE)
{
++mp_up->m_n_served;
m_result.m_guid = m_operation.m_guid;
m_result.m_operationId = m_operation.m_operationId;
m_result.m_result = 0;
m_result.m_resultType = mp_up->calculate(m_operation.m_operationType,
m_operation.m_num1,m_operation.m_num2,&m_result.m_result);
mp_up->mp_result_pub->write((void*)&m_result);
}
}
void EprosimaServer::OperationListener::onSubscriptionMatched(Subscriber* sub,MatchingInfo& info)
{
}
void EprosimaServer::ResultListener::onPublicationMatched(Publisher* pub,MatchingInfo& info)
{
}
| 0 |
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/share/fastrtps/examples/C++ | apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/share/fastrtps/examples/C++/ClientServerTest/ClientServerTypes.h | // Copyright 2016 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.
/**
* @file ClientServerTypes.h
*
*/
#ifndef CLIENTSERVERTYPES_H_
#define CLIENTSERVERTYPES_H_
#include "fastrtps/TopicDataType.h"
#include "fastrtps/rtps/common/all_common.h"
using namespace eprosima;
using namespace fastrtps;
using namespace rtps;
namespace clientserver{
class Operation
{
public:
enum OPERATIONTYPE:uint32_t{
ADDITION,
SUBTRACTION,
MULTIPLICATION,
DIVISION,
};
GUID_t m_guid;
uint32_t m_operationId;
OPERATIONTYPE m_operationType;
int32_t m_num1;
int32_t m_num2;
Operation():m_operationId(0),m_operationType(ADDITION),
m_num1(0),m_num2(0){}
~Operation(){}
};
class OperationDataType:public TopicDataType
{
public:
OperationDataType()
{
setName("Operation");
m_typeSize = 16+4+4+2*sizeof(int32_t);
m_isGetKeyDefined = false;
};
~OperationDataType(){};
bool serialize(void*data,SerializedPayload_t* payload);
bool deserialize(SerializedPayload_t* payload,void * data);
std::function<uint32_t()> getSerializedSizeProvider(void* data);
void* createData();
void deleteData(void* data);
};
class Result
{
public:
enum RESULTTYPE:uint32_t
{
GOOD_RESULT,
ERROR_RESULT,
SERVER_NOT_READY
};
GUID_t m_guid;
uint32_t m_operationId;
RESULTTYPE m_resultType;
int32_t m_result;
Result():m_operationId(0),m_resultType(GOOD_RESULT),m_result(0){}
~Result(){}
};
class ResultDataType:public TopicDataType
{
public:
ResultDataType()
{
setName("Result");
m_typeSize = 16+4+4+sizeof(int32_t);
m_isGetKeyDefined = false;
};
~ResultDataType(){};
bool serialize(void*data,SerializedPayload_t* payload);
bool deserialize(SerializedPayload_t* payload,void * data);
std::function<uint32_t()> getSerializedSizeProvider(void* data);
void* createData();
void deleteData(void* data);
};
}
#endif /* CLIENTSERVERTYPES_H_ */
| 0 |
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/share/fastrtps/examples/C++ | apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/share/fastrtps/examples/C++/ClientServerTest/Makefile | # Copyright 2016 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.
CPP=g++
LN=g++
AR=ar
CP=cp
SYSLIBS= -ldl -lnsl -lm -lpthread -lrt
DEFINES=
COMMON_CFLAGS= -c -Wall -D__LITTLE_ENDIAN__ -std=c++11
## CHOOSE HERE BETWEEN 32 and 64 bit architecture
##32 BIT ARCH:
#COMMON_CFLAGS+= -m32 -fpic
#LDFLAGS=-m32
#64BIT ARCH:
COMMON_CFLAGS+= -m64 -fpic
LDFLAGS=-m64
CFLAGS = $(COMMON_CFLAGS) -O2
INCLUDES= -I.
LIBS = -lfastcdr -lfastrtps $(SYSLIBS)
DIRECTORIES= output.dir bin.dir
all: $(DIRECTORIES) ClientServerTest
CLIENTSERVERTEST_TARGET= bin/ClientServerTest
CLIENTSERVERTEST_SRC_CXXFILES=
CLIENTSERVERTEST_SRC_CPPFILES= ClientServerTest/EprosimaServer.cpp \
ClientServerTest/ClientServerTypes.cpp \
ClientServerTest/EprosimaClient.cpp \
ClientServerTest/EprosimaClientTest.cpp \
ClientServerTest/main_ClientServerTestFastRTPS.cpp
# Project sources are copied to the current directory
CLIENTSERVERTEST_SRCS= $(CLIENTSERVERTEST_SRC_CXXFILES) $(CLIENTSERVERTEST_SRC_CPPFILES)
# Source directories
CLIENTSERVERTEST_SOURCES_DIRS_AUX= $(foreach srcdir, $(dir $(CLIENTSERVERTEST_SRCS)), $(srcdir))
CLIENTSERVERTEST_SOURCES_DIRS= $(shell echo $(CLIENTSERVERTEST_SOURCES_DIRS_AUX) | tr " " "\n" | sort | uniq | tr "\n" " ")
CLIENTSERVERTEST_OBJS = $(foreach obj,$(notdir $(addsuffix .o, $(CLIENTSERVERTEST_SRCS))), output/$(obj))
CLIENTSERVERTEST_DEPS = $(foreach dep,$(notdir $(addsuffix .d, $(CLIENTSERVERTEST_SRCS))), output/$(dep))
OBJS+= $(CLIENTSERVERTEST_OBJS)
DEPS+= $(CLIENTSERVERTEST_DEPS)
ClientServerTest: $(CLIENTSERVERTEST_TARGET)
$(CLIENTSERVERTEST_TARGET): $(CLIENTSERVERTEST_OBJS)
$(LN) $(LDFLAGS) -o $(CLIENTSERVERTEST_TARGET) $(CLIENTSERVERTEST_OBJS) $(LIBS)
vpath %.cxx $(CLIENTSERVERTEST_SOURCES_DIRS)
vpath %.cpp $(CLIENTSERVERTEST_SOURCES_DIRS)
output/%.cxx.o:%.cxx
@echo Calculating dependencies $<
@$(CC) $(CFLAGS) -MM $(CFLAGS) $(INCLUDES) $< | sed "s/^.*:/output\/&/g" > $(@:%.cxx.o=%.cxx.d)
@echo Compiling $<
@$(CC) $(CFLAGS) $(INCLUDES) $< -o $@
output/%.cpp.o:%.cpp
@echo Calculating dependencies $<
@$(CPP) $(CFLAGS) -MM $(CFLAGS) $(INCLUDES) $< | sed "s/^.*:/output\/&/g" > $(@:%.cpp.o=%.cpp.d)
@echo Compiling $<
@$(CPP) $(CFLAGS) $(INCLUDES) $< -o $@
.PHONY: ClientServerTest
clean:
@rm -f $(OBJS)
@rm -f $(DEPS)
ifneq ($(MAKECMDGOALS), clean)
-include $(DEPS)
endif
%.dir :
@echo "Checking directory $*"
@if [ ! -d $* ]; then \
echo "Making directory $*"; \
mkdir -p $* ; \
fi;
| 0 |
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/share/fastrtps/examples/C++ | apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/share/fastrtps/examples/C++/ClientServerTest/EprosimaClientTest.cpp | // Copyright 2016 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.
/**
* @file EprosimaClientTest.cpp
*
*/
#include "EprosimaClientTest.h"
#include "fastrtps/utils/TimeConversion.h"
EprosimaClientTest::EprosimaClientTest():m_overhead(0) {
// TODO Auto-generated constructor stub
m_client.init();
m_clock.setTimeNow(&m_t1);
for(int i=0;i<1000;i++)
m_clock.setTimeNow(&m_t2);
m_overhead = (TimeConv::Time_t2MicroSecondsDouble(m_t2)-TimeConv::Time_t2MicroSecondsDouble(m_t1))/1001;
std::cout << "Overhead " << m_overhead << std::endl;
}
EprosimaClientTest::~EprosimaClientTest() {
// TODO Auto-generated destructor stub
}
double EprosimaClientTest::run(int samples)
{
while(!m_client.isReady())
{
eClock::my_sleep(100);
}
int32_t res;
m_clock.setTimeNow(&m_t1);
int isam = 0;
for(isam = 0;isam<samples;++isam)
{
if(m_client.calculate(Operation::ADDITION,10,20,&res) != Result::GOOD_RESULT)
break;
}
m_clock.setTimeNow(&m_t2);
if(isam == samples)
{
return (TimeConv::Time_t2MicroSecondsDouble(m_t2)-
TimeConv::Time_t2MicroSecondsDouble(m_t1)-
m_overhead)/samples;
}
return -1;
}
| 0 |
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/share/fastrtps/examples/C++ | apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/share/fastrtps/examples/C++/ClientServerTest/EprosimaServer.h | // Copyright 2016 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.
/**
* @file EprosimaServer.h
*
*/
#ifndef EPROSIMASERVER_H_
#define EPROSIMASERVER_H_
#include "ClientServerTypes.h"
#include "fastrtps/fastrtps_fwd.h"
#include "fastrtps/subscriber/SampleInfo.h"
#include "fastrtps/publisher/PublisherListener.h"
#include "fastrtps/subscriber/SubscriberListener.h"
using namespace eprosima;
using namespace fastrtps;
using namespace clientserver;
class EprosimaServer {
friend class OperationListener;
friend class ResultListener;
public:
EprosimaServer();
virtual ~EprosimaServer();
bool init();
//Serve indefinitely.
void serve();
//Serve for samples operations.
void serve(uint32_t samples);
private:
Subscriber* mp_operation_sub;
Publisher* mp_result_pub;
Participant* mp_participant;
Result::RESULTTYPE calculate(Operation::OPERATIONTYPE type, int32_t num1,int32_t num2,int32_t* result);
ResultDataType* mp_resultdatatype;
OperationDataType* mp_operationdatatype;
public:
uint32_t m_n_served;
class OperationListener:public SubscriberListener
{
public:
OperationListener(EprosimaServer* up):mp_up(up){}
~OperationListener(){}
EprosimaServer* mp_up;
void onSubscriptionMatched(Subscriber* sub,MatchingInfo& info);
void onNewDataMessage(Subscriber*sub);
Operation m_operation;
SampleInfo_t m_sampleInfo;
Result m_result;
}m_operationsListener;
class ResultListener:public PublisherListener
{
public:
ResultListener(EprosimaServer* up):mp_up(up){}
~ResultListener(){}
EprosimaServer* mp_up;
void onPublicationMatched(Publisher* pub,MatchingInfo& info);
}m_resultsListener;
};
#endif /* EPROSIMASERVER_H_ */
| 0 |
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/share/fastrtps/examples/C++ | apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/share/fastrtps/examples/C++/ClientServerTest/EprosimaClient.h | // Copyright 2016 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.
/**
* @file EprosimaClient.h
*
*/
#ifndef EPROSIMACLIENT_H_
#define EPROSIMACLIENT_H_
#include "ClientServerTypes.h"
#include "fastrtps/fastrtps_fwd.h"
#include "fastrtps/subscriber/SampleInfo.h"
#include "fastrtps/publisher/PublisherListener.h"
#include "fastrtps/subscriber/SubscriberListener.h"
using namespace eprosima;
using namespace fastrtps;
using namespace clientserver;
class EprosimaClient {
public:
EprosimaClient();
virtual ~EprosimaClient();
Publisher* mp_operation_pub;
Subscriber* mp_result_sub;
Participant* mp_participant;
bool init();
Result::RESULTTYPE calculate(Operation::OPERATIONTYPE type, int32_t num1,int32_t num2,int32_t* result);
bool isReady();
private:
Operation m_operation;
Result m_result;
SampleInfo_t m_sampleInfo;
void resetResult();
ResultDataType* mp_resultdatatype;
OperationDataType* mp_operationdatatype;
class OperationListener:public PublisherListener
{
public:
OperationListener(EprosimaClient* up):mp_up(up){}
~OperationListener(){}
EprosimaClient* mp_up;
void onPublicationMatched(Publisher* pub,MatchingInfo& info);
}m_operationsListener;
class ResultListener:public SubscriberListener
{
public:
ResultListener(EprosimaClient* up):mp_up(up){}
~ResultListener(){}
EprosimaClient* mp_up;
void onSubscriptionMatched(Subscriber* sub,MatchingInfo& info);
void onNewDataMessage(Subscriber* sub);
}m_resultsListener;
bool m_isReady;
int m_operationMatched;
int m_resultMatched;
};
#endif /* EPROSIMACLIENT_H_ */
| 0 |
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/share/fastrtps/examples/C++ | apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/share/fastrtps/examples/C++/ClientServerTest/EprosimaClientTest.h | // Copyright 2016 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.
/**
* @file EprosimaClientTest.h
*
*/
#ifndef EPROSIMACLIENTTEST_H_
#define EPROSIMACLIENTTEST_H_
#include "EprosimaClient.h"
#include "fastrtps/utils/eClock.h"
using namespace eprosima::fastrtps;
class EprosimaClientTest {
public:
EprosimaClientTest();
virtual ~EprosimaClientTest();
EprosimaClient m_client;
double run(int samples);
eClock m_clock;
Time_t m_t1,m_t2;
double m_overhead;
};
#endif /* EPROSIMACLIENTTEST_H_ */
| 0 |
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/share/fastrtps/examples/C++ | apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/share/fastrtps/examples/C++/ClientServerTest/main_ClientServerTestFastRTPS.cpp | // Copyright 2016 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.
/**
* @file main_ClientServerTest.cpp
*
*/
#include <stdio.h>
#include <string>
#include <iostream>
#include <iomanip>
#include <bitset>
#include <cstdint>
#include <sstream>
#include "EprosimaServer.h"
#include "EprosimaClientTest.h"
#include "fastrtps/log/Log.h"
#include "fastrtps/Domain.h"
using namespace eprosima;
using namespace fastrtps;
using std::cout;
using std::endl;
#if defined(__LITTLE_ENDIAN__)
const Endianness_t DEFAULT_ENDIAN = LITTLEEND;
#elif defined (__BIG_ENDIAN__)
const Endianness_t DEFAULT_ENDIAN = BIGEND;
#endif
#if defined(_WIN32)
#define COPYSTR strcpy_s
#else
#define COPYSTR strcpy
#endif
enum E_SIDE
{
CLIENT,
SERVER
};
int main(int argc, char** argv){
cout << "Starting "<< endl;
E_SIDE side;
int samples = 10000;
if(argc > 1)
{
if(strcmp(argv[1],"client")==0)
side = CLIENT;
else if(strcmp(argv[1],"server")==0)
side = SERVER;
else
{
cout << "Argument 1 needs to be client OR server"<<endl;
return 0;
}
if(argc > 3)
{
std::istringstream iss( argv[3] );
if (!(iss >> samples))
{
cout << "Problem reading samples number,using default 10000 samples "<< endl;
samples = 10000;
}
}
}
else
{
cout << "Client Server Test needs 1 arguments: (client/server)"<<endl;
return 0;
}
if(side == SERVER)
{
EprosimaServer server;
server.init();
server.serve();
}
if(side == CLIENT)
{
EprosimaClientTest clienttest;
double result = clienttest.run(samples);
if(result > 0)
cout << "Mean Time of " << samples << " samples: " << result << " us" << endl;
else
cout << "Some problem with the test "<<endl;
}
cout << "EVERYTHING STOPPED FINE"<<endl;
return 0;
}
| 0 |
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/share/fastrtps/examples/C++ | apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/share/fastrtps/examples/C++/ClientServerTest/ClientServerTypes.cpp | // Copyright 2016 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.
/**
* @file ClientServerTypes.cpp
*
*/
#include "ClientServerTypes.h"
namespace clientserver{
bool OperationDataType::serialize(void* data, SerializedPayload_t* payload)
{
Operation* op = (Operation*)data;
payload->length = this->m_typeSize;
uint32_t pos = 0;
memcpy(payload->data,op->m_guid.guidPrefix.value,12);pos+=12;
memcpy(payload->data+pos,op->m_guid.entityId.value,4);pos+=4;
*(uint32_t*)(payload->data+pos) = (uint32_t)op->m_operationId;pos+=4;
*(Operation::OPERATIONTYPE*)(payload->data+pos) = op->m_operationType;pos+=4;
*(int32_t*)(payload->data+pos) = op->m_num1;pos+=sizeof(int32_t);
*(int32_t*)(payload->data+pos) = op->m_num2;pos+=sizeof(int32_t);
return true;
}
bool OperationDataType::deserialize(SerializedPayload_t* payload, void* data)
{
Operation* op = (Operation*)data;
if(payload->length == this->m_typeSize)
{
uint32_t pos = 0;
memcpy(op->m_guid.guidPrefix.value,payload->data,12);pos+=12;
memcpy(op->m_guid.entityId.value,payload->data+pos,4);pos+=4;
op->m_operationId = *(uint32_t*)(payload->data+pos);pos+=4;
op->m_operationType = *(Operation::OPERATIONTYPE*)(payload->data+pos);pos+=4;
op->m_num1 = *(int32_t*)(payload->data+pos);pos+=sizeof(int32_t);
op->m_num2 = *(int32_t*)(payload->data+pos);pos+=sizeof(int32_t);
return true;
}
return false;
}
std::function<uint32_t()> OperationDataType::getSerializedSizeProvider(void* data)
{
return [data]() -> uint32_t { return 16 + 4 + 4 + 4 + 4; };
}
void* OperationDataType::createData()
{
return (void*)new Operation();
}
void OperationDataType::deleteData(void* data)
{
delete((Operation*)data);
}
bool ResultDataType::serialize(void* data, SerializedPayload_t* payload)
{
Result* res = (Result*)data;
payload->length = this->m_typeSize;
uint32_t pos = 0;
memcpy(payload->data,res->m_guid.guidPrefix.value,12);pos+=12;
memcpy(payload->data+pos,res->m_guid.entityId.value,4);pos+=4;
*(uint32_t*)(payload->data+pos) = (uint32_t)res->m_operationId;pos+=4;
*(Result::RESULTTYPE*)(payload->data+pos) = res->m_resultType;pos+=4;
*(int32_t*)(payload->data+pos) = res->m_result;
return true;
}
bool ResultDataType::deserialize(SerializedPayload_t* payload, void* data)
{
Result* res = (Result*)data;
if(payload->length == this->m_typeSize)
{
uint32_t pos = 0;
memcpy(res->m_guid.guidPrefix.value,payload->data,12);pos+=12;
memcpy(res->m_guid.entityId.value,payload->data+pos,4);pos+=4;
res->m_operationId = *(uint32_t*)(payload->data+pos);pos+=4;
res->m_resultType = *(Result::RESULTTYPE*)(payload->data+pos);pos+=4;
res->m_result = *(int32_t*)(payload->data+pos);
return true;
}
return false;
}
std::function<uint32_t()> ResultDataType::getSerializedSizeProvider(void* data)
{
return [data]() -> uint32_t { return 16 + 4 + 4 + 4; };
}
void* ResultDataType::createData()
{
return (void*)new Result();
}
void ResultDataType::deleteData(void* data)
{
delete((Result*)data);
}
}
| 0 |
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/share/fastrtps/examples/C++ | apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/share/fastrtps/examples/C++/ClientServerTest/EprosimaClient.cpp | // Copyright 2016 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.
/**
* @file EprosimaClient.cpp
*
*/
#include "EprosimaClient.h"
#include "fastrtps/fastrtps_all.h"
EprosimaClient::EprosimaClient():
mp_operation_pub(nullptr),
mp_result_sub(nullptr),
mp_participant(nullptr),
mp_resultdatatype(nullptr),
mp_operationdatatype(nullptr),
m_operationsListener(nullptr),
m_resultsListener(nullptr),
m_isReady(false),
m_operationMatched(0),
m_resultMatched(0)
{
m_operationsListener.mp_up = this;
m_resultsListener.mp_up = this;
}
EprosimaClient::~EprosimaClient()
{
Domain::removeParticipant(mp_participant);
if(mp_resultdatatype!=nullptr)
delete(mp_resultdatatype);
if(mp_operationdatatype!=nullptr)
delete(mp_operationdatatype);
}
bool EprosimaClient::init()
{
//CREATE RTPSParticipant
ParticipantAttributes PParam;
PParam.rtps.defaultSendPort = 10042;
PParam.rtps.builtin.domainId = 80;
PParam.rtps.builtin.use_SIMPLE_EndpointDiscoveryProtocol = true;
PParam.rtps.builtin.use_SIMPLE_RTPSParticipantDiscoveryProtocol = true;
PParam.rtps.builtin.m_simpleEDP.use_PublicationReaderANDSubscriptionWriter = true;
PParam.rtps.builtin.m_simpleEDP.use_PublicationWriterANDSubscriptionReader = true;
PParam.rtps.builtin.leaseDuration = c_TimeInfinite;
PParam.rtps.setName( "client_RTPSParticipant");
mp_participant = Domain::createParticipant(PParam);
if(mp_participant == nullptr)
return false;
//REGISTER TYPES
mp_resultdatatype = new ResultDataType();
mp_operationdatatype = new OperationDataType();
Domain::registerType(mp_participant,mp_resultdatatype);
Domain::registerType(mp_participant,mp_operationdatatype);
// DATA PUBLISHER
PublisherAttributes PubDataparam;
PubDataparam.topic.topicDataType = "Operation";
PubDataparam.topic.topicKind = NO_KEY;
PubDataparam.topic.topicName = "Operations";
PubDataparam.topic.historyQos.kind = KEEP_LAST_HISTORY_QOS;
PubDataparam.topic.historyQos.depth = 2;
PubDataparam.topic.resourceLimitsQos.max_samples = 50;
PubDataparam.topic.resourceLimitsQos.allocated_samples = 50;
PubDataparam.qos.m_reliability.kind = RELIABLE_RELIABILITY_QOS;
mp_operation_pub = Domain::createPublisher(mp_participant,PubDataparam,(PublisherListener*)&this->m_operationsListener);
if(mp_operation_pub == nullptr)
return false;
//DATA SUBSCRIBER
SubscriberAttributes SubDataparam;
Locator_t loc;
loc.port = 7555;
PubDataparam.unicastLocatorList.push_back(loc);
SubDataparam.topic.topicDataType = "Result";
SubDataparam.topic.topicKind = NO_KEY;
SubDataparam.topic.topicName = "Results";
SubDataparam.topic.historyQos.kind = KEEP_LAST_HISTORY_QOS;
SubDataparam.topic.historyQos.depth = 100;
SubDataparam.topic.resourceLimitsQos.max_samples = 100;
SubDataparam.topic.resourceLimitsQos.allocated_samples = 100;
mp_result_sub = Domain::createSubscriber(mp_participant,SubDataparam,(SubscriberListener*)&this->m_resultsListener);
if(mp_result_sub == nullptr)
return false;
return true;
}
Result::RESULTTYPE EprosimaClient::calculate(Operation::OPERATIONTYPE type, int32_t num1,int32_t num2,int32_t* result)
{
if(!m_isReady)
return Result::SERVER_NOT_READY;
m_operation.m_operationId++;
m_operation.m_operationType = type;
m_operation.m_num1 = num1;
m_operation.m_num2 = num2;
mp_operation_pub->write((void*)&m_operation);
do{
resetResult();
mp_result_sub->waitForUnreadMessage();
mp_result_sub->takeNextData((void*)&m_result,&m_sampleInfo);
}while(m_sampleInfo.sampleKind !=ALIVE ||
m_result.m_guid != m_operation.m_guid ||
m_result.m_operationId != m_operation.m_operationId);
if(m_result.m_resultType == Result::GOOD_RESULT)
{
*result = m_result.m_result;
}
return m_result.m_resultType;
}
void EprosimaClient::resetResult()
{
m_result.m_guid = c_Guid_Unknown;
m_result.m_operationId = 0;
m_result.m_result = 0;
}
void EprosimaClient::OperationListener::onPublicationMatched(Publisher* pub,MatchingInfo& info)
{
if(info.status == MATCHED_MATCHING)
{
mp_up->m_operationMatched++;
}
else
mp_up->m_operationMatched--;
mp_up->isReady();
}
void EprosimaClient::ResultListener::onSubscriptionMatched(Subscriber* sub,MatchingInfo& info)
{
if(info.status == MATCHED_MATCHING)
{
mp_up->m_resultMatched++;
}
else
mp_up->m_resultMatched--;
mp_up->isReady();
}
void EprosimaClient::ResultListener::onNewDataMessage(Subscriber* sub)
{
}
bool EprosimaClient::isReady()
{
if(m_operationMatched == 1 && m_resultMatched == 1)
m_isReady = true;
else
m_isReady = false;
return m_isReady;
}
| 0 |
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/share/fastrtps/examples/C++ | apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/share/fastrtps/examples/C++/SampleConfig_Controller/CMakeLists.txt | # Copyright 2016 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.
cmake_minimum_required(VERSION 2.8.12)
project("UseCaseDemonstrator")
# Find requirements
find_package(fastcdr REQUIRED)
find_package(fastrtps REQUIRED)
# Set C++11
include(CheckCXXCompilerFlag)
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_CLANG OR
CMAKE_CXX_COMPILER_ID MATCHES "Clang")
check_cxx_compiler_flag(--std=c++11 SUPPORTS_CXX11)
if(SUPPORTS_CXX11)
add_compile_options(--std=c++11)
else()
message(FATAL_ERROR "Compiler doesn't support C++11")
endif()
endif()
message(STATUS "Configuring UseCaseDemonstrator example...")
file(GLOB USECASEDEMONSTRATOR_EXAMPLE_SOURCES "*.cxx")
add_executable(sampleconfig_controller ${USECASEDEMONSTRATOR_EXAMPLE_SOURCES} sampleconfig_safest.cpp)
target_link_libraries(sampleconfig_controller fastrtps fastcdr)
install(TARGETS sampleconfig_controller
RUNTIME DESTINATION examples/C++/UseCaseDemonstrator/${BIN_INSTALL_DIR}
)
| 0 |
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/share/fastrtps/examples/C++ | apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/share/fastrtps/examples/C++/SampleConfig_Controller/samplePubSubTypes.h | // Copyright 2016 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.
/*!
* @file samplePubSubTypes.h
* This header file contains the declaration of the serialization functions.
*
* This file was generated by the tool fastcdrgen.
*/
#ifndef _SAMPLE_PUBSUBTYPES_H_
#define _SAMPLE_PUBSUBTYPES_H_
#include <fastrtps/TopicDataType.h>
using namespace eprosima::fastrtps;
#include "sample.h"
/*!
* @brief This class represents the TopicDataType of the type sample defined by the user in the IDL file.
* @ingroup SAMPLE
*/
class samplePubSubType : public TopicDataType {
public:
typedef sample type;
samplePubSubType();
virtual ~samplePubSubType();
bool serialize(void *data, SerializedPayload_t *payload);
bool deserialize(SerializedPayload_t *payload, void *data);
std::function<uint32_t()> getSerializedSizeProvider(void* data);
bool getKey(void *data, InstanceHandle_t *ihandle);
void* createData();
void deleteData(void * data);
MD5 m_md5;
unsigned char* m_keyBuffer;
};
#endif // _sample_PUBSUBTYPE_H_ | 0 |
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/share/fastrtps/examples/C++ | apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/share/fastrtps/examples/C++/SampleConfig_Controller/Makefile | # Copyright 2016 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.
CPP=g++
LN=g++
AR=ar
CP=cp
SYSLIBS= -ldl -lnsl -lm -lpthread -lrt
DEFINES=
COMMON_CFLAGS= -c -Wall -D__LITTLE_ENDIAN__ -std=c++11
## CHOOSE HERE BETWEEN 32 and 64 bit architecture
##32 BIT ARCH:
#COMMON_CFLAGS+= -m32 -fpic
#LDFLAGS=-m32
#64BIT ARCH:
COMMON_CFLAGS+= -m64 -fpic
LDFLAGS=-m64
CFLAGS = $(COMMON_CFLAGS) -O2
INCLUDES= -I.
LIBS = -lfastcdr -lfastrtps $(SYSLIBS)
DIRECTORIES= output.dir bin.dir
all: $(DIRECTORIES) SampleConfig_Controller
SAMPLECONFIG_CONTROLLER_TARGET= bin/SampleConfig_Controller
SAMPLECONFIG_CONTROLLER_SRC_CXXFILES=
SAMPLECONFIG_CONTROLLER_SRC_CPPFILES= SampleConfig_Controller/sampleconfig_safest.cpp \
SampleConfig_Controller/sample.cxx \
SampleConfig_Controller/samplePubSubTypes.cxx
# Project sources are copied to the current directory
SAMPLECONFIG_CONTROLLER_SRCS= $(SAMPLECONFIG_CONTROLLER_SRC_CXXFILES) $(SAMPLECONFIG_CONTROLLER_SRC_CPPFILES)
# Source directories
SAMPLECONFIG_CONTROLLER_SOURCES_DIRS_AUX= $(foreach srcdir, $(dir $(SAMPLECONFIG_CONTROLLER_SRCS)), $(srcdir))
SAMPLECONFIG_CONTROLLER_SOURCES_DIRS= $(shell echo $(SAMPLECONFIG_CONTROLLER_SOURCES_DIRS_AUX) | tr " " "\n" | sort | uniq | tr "\n" " ")
SAMPLECONFIG_CONTROLLER_OBJS = $(foreach obj,$(notdir $(addsuffix .o, $(SAMPLECONFIG_CONTROLLER_SRCS))), output/$(obj))
SAMPLECONFIG_CONTROLLER_DEPS = $(foreach dep,$(notdir $(addsuffix .d, $(SAMPLECONFIG_CONTROLLER_SRCS))), output/$(dep))
OBJS+= $(SAMPLECONFIG_CONTROLLER_OBJS)
DEPS+= $(SAMPLECONFIG_CONTROLLER_DEPS)
SampleConfig_Controller: $(SAMPLECONFIG_CONTROLLER_TARGET)
$(SAMPLECONFIG_CONTROLLER_TARGET): $(SAMPLECONFIG_CONTROLLER_OBJS)
$(LN) $(LDFLAGS) -o $(SAMPLECONFIG_CONTROLLER_TARGET) $(SAMPLECONFIG_CONTROLLER_OBJS) $(LIBS)
vpath %.cxx $(SAMPLECONFIG_CONTROLLER_SOURCES_DIRS)
vpath %.cpp $(SAMPLECONFIG_CONTROLLER_SOURCES_DIRS)
output/%.cxx.o:%.cxx
@echo Calculating dependencies $<
@$(CC) $(CFLAGS) -MM $(CFLAGS) $(INCLUDES) $< | sed "s/^.*:/output\/&/g" > $(@:%.cxx.o=%.cxx.d)
@echo Compiling $<
@$(CC) $(CFLAGS) $(INCLUDES) $< -o $@
output/%.cpp.o:%.cpp
@echo Calculating dependencies $<
@$(CPP) $(CFLAGS) -MM $(CFLAGS) $(INCLUDES) $< | sed "s/^.*:/output\/&/g" > $(@:%.cpp.o=%.cpp.d)
@echo Compiling $<
@$(CPP) $(CFLAGS) $(INCLUDES) $< -o $@
.PHONY: SampleConfig_Controller
clean:
@rm -f $(OBJS)
@rm -f $(DEPS)
ifneq ($(MAKECMDGOALS), clean)
-include $(DEPS)
endif
%.dir :
@echo "Checking directory $*"
@if [ ! -d $* ]; then \
echo "Making directory $*"; \
mkdir -p $* ; \
fi;
| 0 |
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/share/fastrtps/examples/C++ | apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/share/fastrtps/examples/C++/SampleConfig_Controller/sampleconfig_safest.cpp | #include <iostream>
#include <string>
#include <fastrtps/participant/Participant.h>
#include <fastrtps/attributes/ParticipantAttributes.h>
#include <fastrtps/subscriber/Subscriber.h>
#include <fastrtps/attributes/SubscriberAttributes.h>
#include <fastrtps/publisher/Publisher.h>
#include <fastrtps/attributes/PublisherAttributes.h>
#include <fastrtps/Domain.h>
#include <fastrtps/subscriber/SampleInfo.h>
#include <fastrtps/utils/eClock.h>
#include "samplePubSubTypes.h"
//Enums and configuration structure
enum Reliability_type { Best_Effort, Reliable };
enum Durability_type { Transient_Local, Volatile };
enum HistoryKind_type { Keep_Last, Keep_All };
enum Key_type { No_Key, With_Key};
typedef struct{
Reliability_type reliability;
Durability_type durability;
HistoryKind_type historykind;
Key_type keys;
uint16_t history_size;
uint8_t depth;
uint8_t no_keys;
uint16_t max_samples_per_key;
} example_configuration;
void safest();
int main(){
safest();
return 0;
}
void safest(){
samplePubSubType sampleType;
sample my_sample;
SampleInfo_t sample_info;
ParticipantAttributes PparamPub;
PparamPub.rtps.builtin.domainId = 0;
PparamPub.rtps.builtin.leaseDuration = c_TimeInfinite;
PparamPub.rtps.setName("PublisherParticipant");
Participant *PubParticipant = Domain::createParticipant(PparamPub);
if(PubParticipant == nullptr){
std::cout << " Something went wrong while creating the Publisher Participant..." << std::endl;
return;
}
Domain::registerType(PubParticipant,(TopicDataType*) &sampleType);
//Publisher config
PublisherAttributes Pparam;
Pparam.topic.topicDataType = sampleType.getName();
Pparam.topic.topicName = "samplePubSubTopic";
Pparam.historyMemoryPolicy = DYNAMIC_RESERVE_MEMORY_MODE;
Pparam.topic.topicKind = NO_KEY;
Pparam.topic.historyQos.kind = KEEP_ALL_HISTORY_QOS;
Pparam.qos.m_durability.kind = TRANSIENT_LOCAL_DURABILITY_QOS;
Pparam.qos.m_reliability.kind = RELIABLE_RELIABILITY_QOS;
Pparam.topic.historyQos.depth = 50;
Pparam.topic.resourceLimitsQos.max_samples = 100;
Pparam.topic.resourceLimitsQos.max_instances = 1;
Pparam.topic.resourceLimitsQos.max_samples_per_instance = 100;
std::cout << "Creating Best-Effort Publisher..." << std::endl;
Publisher *myPub= Domain::createPublisher(PubParticipant, Pparam, nullptr);
if(myPub == nullptr){
std::cout << "Something went wrong while creating the Publisher..." << std::endl;
return;
}
ParticipantAttributes PparamSub;
PparamSub.rtps.builtin.domainId = 0;
PparamSub.rtps.builtin.leaseDuration = c_TimeInfinite;
PparamSub.rtps.setName("SubscriberParticipant");
Participant *SubParticipant = Domain::createParticipant(PparamSub);
if(SubParticipant == nullptr){
std::cout << " Something went wrong while creating the Subscriber Participant..." << std::endl;
return;
}
Domain::registerType(SubParticipant,(TopicDataType*) &sampleType);
// Sub
SubscriberAttributes Rparam;
Rparam.topic.topicDataType = sampleType.getName();
Rparam.topic.topicName = "samplePubSubTopic";
Rparam.historyMemoryPolicy = DYNAMIC_RESERVE_MEMORY_MODE;
Rparam.topic.topicKind = NO_KEY;
Rparam.topic.historyQos.kind = KEEP_ALL_HISTORY_QOS;
Rparam.qos.m_durability.kind = TRANSIENT_LOCAL_DURABILITY_QOS;
Rparam.qos.m_reliability.kind = RELIABLE_RELIABILITY_QOS;
Rparam.topic.historyQos.depth = 50;
Rparam.topic.resourceLimitsQos.max_samples = 100;
Rparam.topic.resourceLimitsQos.max_instances = 1;
Rparam.topic.resourceLimitsQos.max_samples_per_instance = 100;
std::cout << "Creating Subscriber..." << std::endl;
Subscriber *mySub1= Domain::createSubscriber(PubParticipant, Rparam, nullptr);
if(myPub == nullptr){
std::cout << "something went wrong while creating the Subscriber..." << std::endl;
return;
}
//Send 20 samples
std::cout << "Publishing 10 samples on the topic..." << std::endl;
for(uint8_t j=0; j < 10; j++){
my_sample.index(j+1);
my_sample.key_value(1);
myPub->write(&my_sample);
}
eClock::my_sleep(1500);
//Read the contents of both histories:
std::cout << "The Reliable Subscriber holds: " << std::endl;
while(mySub1->readNextData(&my_sample, &sample_info)){
std::cout << std::to_string(my_sample.index()) << " ";
}
std::cout << std::endl;
}
| 0 |
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/share/fastrtps/examples/C++ | apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/share/fastrtps/examples/C++/SampleConfig_Controller/sample.cxx | // Copyright 2016 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.
/*!
* @file sample.cpp
* This source file contains the definition of the described types in the IDL file.
*
* This file was generated by the tool gen.
*/
#ifdef _WIN32
// Remove linker warning LNK4221 on Visual Studio
namespace { char dummy; }
#endif
#include "sample.h"
#include <fastcdr/Cdr.h>
#include <fastcdr/exceptions/BadParamException.h>
using namespace eprosima::fastcdr::exception;
#include <utility>
sample::sample()
{
m_index = 0;
m_key_value = 0;
}
sample::~sample()
{
}
sample::sample(const sample &x)
{
m_index = x.m_index;
m_key_value = x.m_key_value;
}
sample::sample(sample &&x)
{
m_index = x.m_index;
m_key_value = x.m_key_value;
}
sample& sample::operator=(const sample &x)
{
m_index = x.m_index;
m_key_value = x.m_key_value;
return *this;
}
sample& sample::operator=(sample &&x)
{
m_index = x.m_index;
m_key_value = x.m_key_value;
return *this;
}
size_t sample::getMaxCdrSerializedSize(size_t current_alignment)
{
size_t initial_alignment = current_alignment;
current_alignment += 1 + eprosima::fastcdr::Cdr::alignment(current_alignment, 1);
current_alignment += 1 + eprosima::fastcdr::Cdr::alignment(current_alignment, 1);
return current_alignment - initial_alignment;
}
size_t sample::getCdrSerializedSize(const sample& data, size_t current_alignment)
{
size_t initial_alignment = current_alignment;
current_alignment += 1 + eprosima::fastcdr::Cdr::alignment(current_alignment, 1);
current_alignment += 1 + eprosima::fastcdr::Cdr::alignment(current_alignment, 1);
return current_alignment - initial_alignment;
}
void sample::serialize(eprosima::fastcdr::Cdr &scdr) const
{
scdr << m_index;
scdr << m_key_value;
}
void sample::deserialize(eprosima::fastcdr::Cdr &dcdr)
{
dcdr >> m_index;
dcdr >> m_key_value;
}
size_t sample::getKeyMaxCdrSerializedSize(size_t current_alignment)
{
size_t current_align = current_alignment;
current_align += 1 + eprosima::fastcdr::Cdr::alignment(current_align, 1);
return current_align;
}
bool sample::isKeyDefined()
{
return true;
}
void sample::serializeKey(eprosima::fastcdr::Cdr &scdr) const
{
scdr << m_key_value;
} | 0 |
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/share/fastrtps/examples/C++ | apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/share/fastrtps/examples/C++/SampleConfig_Controller/README.txt | ------------------------------------------------
- Use Case Sample Configuration: Controller for eProsima Fast RTPS -
------------------------------------------------
1 - Application description
---------------------------
eProsima Fast RTPS provides users with a wide range of configuration options. This example has the objective of providing a testing ground where you can experiment and see the influence different combinations of parameters can have on the behaviours on the Publisher/Subscriber scheme.
This example is a supplement to the UseCaseLauncher example, consisting on a sample Publisher-Subscriber application with a configuration optimized to perform secure data transmission where not only the samples but the historic tendency matters.
2 - Configuration options
--------------------------
These are the main parameters that affect the behaviour of eProsima Fast RTPS and that are used in the Use Case set of example:
- Reliability Kind
Defines how eProsima Fast RTPS deals upon possible packet loss during data exchanges.
+ Best Effort: No arrival confirmation. It is fast but lost samples are not re-sent.
+ Reliable: With arrival confirmation. It is slower but provides guarantee that all lost samples are re-sent and eventually received by the subscriber.
Since this application runs the Publisher and Subscriber on the same machine, data loss is highly unlikely. Therefore this option will not play a relevant role on the application behaviour.
- Durability Kind
Defines what to do with samples that exist prior to the existence of the Subscriber.
+ Volatile: Past samples are ignored, the Subscriber starts to receive data generated after it has joined the network.
+ Transient Local: Past samples are sent.
- History Kind
Defines the storage policy for past samples.
+ Keep Last: The History will save and give access to the alst "k" received samples. This "k" number is called the History Depth and can be manually set too by the user.
+ Keep All: The History will save and give access to all received samples until the maximum samples size of the History is reached.
This parameter affects cases of "late-joining" Subscribers: Subscribers that come online after data transfers on a topic have started.
- Keys
Keys allow to have multiple data endpoints within a topic as opposed to all data published in a topic going into the same "inbox".
+ On a topic without keys, all pieces of data go into a single endpoint.
+ On a topic without keys, the key field is used to determine which of the multiple endpoints the data goes into. If, for example, a history is set to transient local with depth=3 (the last three samples are stores) then eProsima FastRTPS will ensure that 3 samples per data endpoint are stored. This means that three samples are stored for each unique key instead of three samples total.
It is important to note that even if you configure a Topic and your History to be able to hold items from multiple keys, this configuration does not take effect unless you explicitly enable Keys.
- Depth
The depth is the amount of past samples that are stored in the history before starting to overwrite. Only takes effect when the History is on "Keep Last" mode.
- History Size
This accounts for the total number of samples that can be stored in the history, regardless of any other configuration option.
- Instances
Instances are the different data sinks the History is divided and act as receptors of the Keys.
- Instance size
As it happens with depth, you can define a maximun number of past samples to be stored. If you set one Instance and an instance size more restrictive than the depth, the instance size will be the limiting factor.
5. Application examples
----------------------
The following list provides examples configurations for real-life scenarios, including the present example.
- Multimedia feed
Audio and Video transmission have a common characteristic: Having a stable, high datarate feed is more important than having a 100% lossless transmission.
Reliability: Best-Effort. We want to have a fast tranmission. If a sample is lost, it can be recovered via error-correcting algorithms.
Durability: Volatile. We do not mind data from the past, we want to stream what is happening in the present.
History: Keep-Last with Low Depth. Once displayed or recorded on the receiving application, they are not needed in the History.
note: In the case of video, depth can be as low as 1. A missing sample of a 50 frames per second stream represents virtually no information loss.
- Distributed measurement: Controllers
Lets say we have a factory with a network of distributed temperature sensors and we want to use eProsima Fast RTPS to send data from said sensors to an automation computer which
makes decisions based on the temperature distribution. We would group all sensors within one single topic,
Reliability: Reliable. We want to make sure samples are not lost. Furthermore, since reliable more ensures data delivery, it allows us to detect hardware problems when a sensor becomes silent
Keys: We use a separate key for each sensor. That way new messages from one sensor dont affect the storage of past samples from another sensor.
Durability: Transient Local. We dont want to lose samples due a sensor losing connection temporarily.
History: Keep-Last with High Depth. We want to have access to past samples in order to be able to compute delta values.
- Event-based transmission
In some cases, you may want to transmit information only under certain circumstances that happen in your system, for example a photo from a surveillance camera when it detects movement.
In these cases and due to the low it is important that all datagrams reach their destination
Reliability: Reliable. All samples must reach their destination.
Durability: Volatile. Since corrective actions are taken as events come, past triggers provide have no use.
History: Keep-Last. No past alarm information is necessary for present-time transmissions.
Additional Settings: Reduce heartbeat period, which dictates system response velocity when a sample is lost. A lower heartbeat period equals fast response on data delivery.
| 0 |
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/share/fastrtps/examples/C++ | apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/share/fastrtps/examples/C++/SampleConfig_Controller/sample.idl | struct sample{
octet index;
@Key octet key_value;
};
| 0 |
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/share/fastrtps/examples/C++ | apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/share/fastrtps/examples/C++/SampleConfig_Controller/sample.h | // Copyright 2016 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.
/*!
* @file sample.h
* This header file contains the declaration of the described types in the IDL file.
*
* This file was generated by the tool gen.
*/
#ifndef _sample_H_
#define _sample_H_
// TODO Poner en el contexto.
#include <stdint.h>
#include <array>
#include <string>
#include <vector>
#if defined(_WIN32)
#if defined(EPROSIMA_USER_DLL_EXPORT)
#define eProsima_user_DllExport __declspec( dllexport )
#else
#define eProsima_user_DllExport
#endif
#else
#define eProsima_user_DllExport
#endif
#if defined(_WIN32)
#if defined(EPROSIMA_USER_DLL_EXPORT)
#if defined(sample_SOURCE)
#define sample_DllAPI __declspec( dllexport )
#else
#define sample_DllAPI __declspec( dllimport )
#endif // sample_SOURCE
#else
#define sample_DllAPI
#endif
#else
#define sample_DllAPI
#endif // _WIN32
namespace eprosima
{
namespace fastcdr
{
class Cdr;
}
}
/*!
* @brief This class represents the structure sample defined by the user in the IDL file.
* @ingroup SAMPLE
*/
class sample
{
public:
/*!
* @brief Default constructor.
*/
eProsima_user_DllExport sample();
/*!
* @brief Default destructor.
*/
eProsima_user_DllExport ~sample();
/*!
* @brief Copy constructor.
* @param x Reference to the object sample that will be copied.
*/
eProsima_user_DllExport sample(const sample &x);
/*!
* @brief Move constructor.
* @param x Reference to the object sample that will be copied.
*/
eProsima_user_DllExport sample(sample &&x);
/*!
* @brief Copy assignment.
* @param x Reference to the object sample that will be copied.
*/
eProsima_user_DllExport sample& operator=(const sample &x);
/*!
* @brief Move assignment.
* @param x Reference to the object sample that will be copied.
*/
eProsima_user_DllExport sample& operator=(sample &&x);
/*!
* @brief This function sets a value in member index
* @param _index New value for member index
*/
inline eProsima_user_DllExport void index(uint8_t _index)
{
m_index = _index;
}
/*!
* @brief This function returns the value of member index
* @return Value of member index
*/
inline eProsima_user_DllExport uint8_t index() const
{
return m_index;
}
/*!
* @brief This function returns a reference to member index
* @return Reference to member index
*/
inline eProsima_user_DllExport uint8_t& index()
{
return m_index;
}
/*!
* @brief This function sets a value in member key_value
* @param _key_value New value for member key_value
*/
inline eProsima_user_DllExport void key_value(uint8_t _key_value)
{
m_key_value = _key_value;
}
/*!
* @brief This function returns the value of member key_value
* @return Value of member key_value
*/
inline eProsima_user_DllExport uint8_t key_value() const
{
return m_key_value;
}
/*!
* @brief This function returns a reference to member key_value
* @return Reference to member key_value
*/
inline eProsima_user_DllExport uint8_t& key_value()
{
return m_key_value;
}
/*!
* @brief This function returns the maximum serialized size of an object
* depending on the buffer alignment.
* @param current_alignment Buffer alignment.
* @return Maximum serialized size.
*/
eProsima_user_DllExport static size_t getMaxCdrSerializedSize(size_t current_alignment = 0);
/*!
* @brief This function returns the serialized size of a data depending on the buffer alignment.
* @param data Data which is calculated its serialized size.
* @param current_alignment Buffer alignment.
* @return Serialized size.
*/
eProsima_user_DllExport static size_t getCdrSerializedSize(const sample& data, size_t current_alignment = 0);
/*!
* @brief This function serializes an object using CDR serialization.
* @param cdr CDR serialization object.
*/
eProsima_user_DllExport void serialize(eprosima::fastcdr::Cdr &cdr) const;
/*!
* @brief This function deserializes an object using CDR serialization.
* @param cdr CDR serialization object.
*/
eProsima_user_DllExport void deserialize(eprosima::fastcdr::Cdr &cdr);
/*!
* @brief This function returns the maximum serialized size of the Key of an object
* depending on the buffer alignment.
* @param current_alignment Buffer alignment.
* @return Maximum serialized size.
*/
eProsima_user_DllExport static size_t getKeyMaxCdrSerializedSize(size_t current_alignment = 0);
/*!
* @brief This function tells you if the Key has been defined for this type
*/
eProsima_user_DllExport static bool isKeyDefined();
/*!
* @brief This function serializes the key members of an object using CDR serialization.
* @param cdr CDR serialization object.
*/
eProsima_user_DllExport void serializeKey(eprosima::fastcdr::Cdr &cdr) const;
private:
uint8_t m_index;
uint8_t m_key_value;
};
#endif // _sample_H_ | 0 |
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/share/fastrtps/examples/C++ | apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/share/fastrtps/examples/C++/SampleConfig_Controller/samplePubSubTypes.cxx | // Copyright 2016 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.
/*!
* @file samplePubSubTypes.cpp
* This header file contains the implementation of the serialization functions.
*
* This file was generated by the tool fastcdrgen.
*/
#include <fastcdr/FastBuffer.h>
#include <fastcdr/Cdr.h>
#include "samplePubSubTypes.h"
samplePubSubType::samplePubSubType() {
setName("sample");
m_typeSize = (uint32_t)sample::getMaxCdrSerializedSize() + 4 /*encapsulation*/;
m_isGetKeyDefined = sample::isKeyDefined();
m_keyBuffer = (unsigned char*)malloc(sample::getKeyMaxCdrSerializedSize()>16 ? sample::getKeyMaxCdrSerializedSize() : 16);
}
samplePubSubType::~samplePubSubType() {
if(m_keyBuffer!=nullptr)
free(m_keyBuffer);
}
bool samplePubSubType::serialize(void *data, SerializedPayload_t *payload) {
sample *p_type = (sample*) data;
eprosima::fastcdr::FastBuffer fastbuffer((char*) payload->data, payload->max_size); // Object that manages the raw buffer.
eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN,
eprosima::fastcdr::Cdr::DDS_CDR);
payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE;
// Serialize encapsulation
ser.serialize_encapsulation();
p_type->serialize(ser); // Serialize the object:
payload->length = (uint32_t)ser.getSerializedDataLength(); //Get the serialized length
return true;
}
bool samplePubSubType::deserialize(SerializedPayload_t* payload, void* data) {
sample* p_type = (sample*) data; //Convert DATA to pointer of your type
eprosima::fastcdr::FastBuffer fastbuffer((char*)payload->data, payload->length); // Object that manages the raw buffer.
eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN,
eprosima::fastcdr::Cdr::DDS_CDR); // Object that deserializes the data.
// Deserialize encapsulation.
deser.read_encapsulation();
payload->encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE;
p_type->deserialize(deser); //Deserialize the object:
return true;
}
std::function<uint32_t()> samplePubSubType::getSerializedSizeProvider(void* data) {
return [data]() -> uint32_t {
return (uint32_t)type::getCdrSerializedSize(*static_cast<sample*>(data)) + 4 /*encapsulation*/;
};
}
void* samplePubSubType::createData() {
return (void*)new sample();
}
void samplePubSubType::deleteData(void* data) {
delete((sample*)data);
}
bool samplePubSubType::getKey(void *data, InstanceHandle_t* handle) {
if(!m_isGetKeyDefined)
return false;
sample* p_type = (sample*) data;
eprosima::fastcdr::FastBuffer fastbuffer((char*)m_keyBuffer,sample::getKeyMaxCdrSerializedSize()); // Object that manages the raw buffer.
eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS); // Object that serializes the data.
p_type->serializeKey(ser);
if(sample::getKeyMaxCdrSerializedSize()>16) {
m_md5.init();
m_md5.update(m_keyBuffer,(unsigned int)ser.getSerializedDataLength());
m_md5.finalize();
for(uint8_t i = 0;i<16;++i) {
handle->value[i] = m_md5.digest[i];
}
}
else {
for(uint8_t i = 0;i<16;++i) {
handle->value[i] = m_keyBuffer[i];
}
}
return true;
}
| 0 |
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/share/fastrtps/examples/C++ | apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/share/fastrtps/examples/C++/SampleConfig_Events/CMakeLists.txt | # Copyright 2016 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.
cmake_minimum_required(VERSION 2.8.12)
project("UseCaseDemonstrator")
# Find requirements
find_package(fastcdr REQUIRED)
find_package(fastrtps REQUIRED)
# Set C++11
include(CheckCXXCompilerFlag)
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_CLANG OR
CMAKE_CXX_COMPILER_ID MATCHES "Clang")
check_cxx_compiler_flag(--std=c++11 SUPPORTS_CXX11)
if(SUPPORTS_CXX11)
add_compile_options(--std=c++11)
else()
message(FATAL_ERROR "Compiler doesn't support C++11")
endif()
endif()
message(STATUS "Configuring UseCaseDemonstrator example...")
file(GLOB USECASEDEMONSTRATOR_EXAMPLE_SOURCES "*.cxx")
add_executable(sampleconfig_events ${USECASEDEMONSTRATOR_EXAMPLE_SOURCES} sampleconfig_triggers.cpp)
target_link_libraries(sampleconfig_events fastrtps fastcdr)
install(TARGETS sampleconfig_events
RUNTIME DESTINATION examples/C++/UseCaseDemonstrator/${BIN_INSTALL_DIR}
)
| 0 |
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/share/fastrtps/examples/C++ | apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/share/fastrtps/examples/C++/SampleConfig_Events/samplePubSubTypes.h | // Copyright 2016 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.
/*!
* @file samplePubSubTypes.h
* This header file contains the declaration of the serialization functions.
*
* This file was generated by the tool fastcdrgen.
*/
#ifndef _SAMPLE_PUBSUBTYPES_H_
#define _SAMPLE_PUBSUBTYPES_H_
#include <fastrtps/TopicDataType.h>
using namespace eprosima::fastrtps;
#include "sample.h"
/*!
* @brief This class represents the TopicDataType of the type sample defined by the user in the IDL file.
* @ingroup SAMPLE
*/
class samplePubSubType : public TopicDataType {
public:
typedef sample type;
samplePubSubType();
virtual ~samplePubSubType();
bool serialize(void *data, SerializedPayload_t *payload);
bool deserialize(SerializedPayload_t *payload, void *data);
std::function<uint32_t()> getSerializedSizeProvider(void* data);
bool getKey(void *data, InstanceHandle_t *ihandle);
void* createData();
void deleteData(void * data);
MD5 m_md5;
unsigned char* m_keyBuffer;
};
#endif // _sample_PUBSUBTYPE_H_ | 0 |
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/share/fastrtps/examples/C++ | apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/share/fastrtps/examples/C++/SampleConfig_Events/Makefile | # Copyright 2016 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.
CPP=g++
LN=g++
AR=ar
CP=cp
SYSLIBS= -ldl -lnsl -lm -lpthread -lrt
DEFINES=
COMMON_CFLAGS= -c -Wall -D__LITTLE_ENDIAN__ -std=c++11
## CHOOSE HERE BETWEEN 32 and 64 bit architecture
##32 BIT ARCH:
#COMMON_CFLAGS+= -m32 -fpic
#LDFLAGS=-m32
#64BIT ARCH:
COMMON_CFLAGS+= -m64 -fpic
LDFLAGS=-m64
CFLAGS = $(COMMON_CFLAGS) -O2
INCLUDES= -I.
LIBS = -lfastcdr -lfastrtps $(SYSLIBS)
DIRECTORIES= output.dir bin.dir
all: $(DIRECTORIES) SampleConfig_Events
SAMPLECONFIG_EVENTS_TARGET= bin/SampleConfig_Events
SAMPLECONFIG_EVENTS_SRC_CXXFILES=
SAMPLECONFIG_EVENTS_SRC_CPPFILES= SampleConfig_Events/sampleconfig_triggers.cpp \
SampleConfig_Events/sample.cxx \
SampleConfig_Events/samplePubSubTypes.cxx
# Project sources are copied to the current directory
SAMPLECONFIG_EVENTS_SRCS= $(SAMPLECONFIG_EVENTS_SRC_CXXFILES) $(SAMPLECONFIG_EVENTS_SRC_CPPFILES)
# Source directories
SAMPLECONFIG_EVENTS_SOURCES_DIRS_AUX= $(foreach srcdir, $(dir $(SAMPLECONFIG_EVENTS_SRCS)), $(srcdir))
SAMPLECONFIG_EVENTS_SOURCES_DIRS= $(shell echo $(SAMPLECONFIG_EVENTS_SOURCES_DIRS_AUX) | tr " " "\n" | sort | uniq | tr "\n" " ")
SAMPLECONFIG_EVENTS_OBJS = $(foreach obj,$(notdir $(addsuffix .o, $(SAMPLECONFIG_EVENTS_SRCS))), output/$(obj))
SAMPLECONFIG_EVENTS_DEPS = $(foreach dep,$(notdir $(addsuffix .d, $(SAMPLECONFIG_EVENTS_SRCS))), output/$(dep))
OBJS+= $(SAMPLECONFIG_EVENTS_OBJS)
DEPS+= $(SAMPLECONFIG_EVENTS_DEPS)
SampleConfig_Events: $(SAMPLECONFIG_EVENTS_TARGET)
$(SAMPLECONFIG_EVENTS_TARGET): $(SAMPLECONFIG_EVENTS_OBJS)
$(LN) $(LDFLAGS) -o $(SAMPLECONFIG_EVENTS_TARGET) $(SAMPLECONFIG_EVENTS_OBJS) $(LIBS)
vpath %.cxx $(SAMPLECONFIG_EVENTS_SOURCES_DIRS)
vpath %.cpp $(SAMPLECONFIG_EVENTS_SOURCES_DIRS)
output/%.cxx.o:%.cxx
@echo Calculating dependencies $<
@$(CC) $(CFLAGS) -MM $(CFLAGS) $(INCLUDES) $< | sed "s/^.*:/output\/&/g" > $(@:%.cxx.o=%.cxx.d)
@echo Compiling $<
@$(CC) $(CFLAGS) $(INCLUDES) $< -o $@
output/%.cpp.o:%.cpp
@echo Calculating dependencies $<
@$(CPP) $(CFLAGS) -MM $(CFLAGS) $(INCLUDES) $< | sed "s/^.*:/output\/&/g" > $(@:%.cpp.o=%.cpp.d)
@echo Compiling $<
@$(CPP) $(CFLAGS) $(INCLUDES) $< -o $@
.PHONY: SampleConfig_Events
clean:
@rm -f $(OBJS)
@rm -f $(DEPS)
ifneq ($(MAKECMDGOALS), clean)
-include $(DEPS)
endif
%.dir :
@echo "Checking directory $*"
@if [ ! -d $* ]; then \
echo "Making directory $*"; \
mkdir -p $* ; \
fi;
| 0 |
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/share/fastrtps/examples/C++ | apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/share/fastrtps/examples/C++/SampleConfig_Events/sample.cxx | // Copyright 2016 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.
/*!
* @file sample.cpp
* This source file contains the definition of the described types in the IDL file.
*
* This file was generated by the tool gen.
*/
#ifdef _WIN32
// Remove linker warning LNK4221 on Visual Studio
namespace { char dummy; }
#endif
#include "sample.h"
#include <fastcdr/Cdr.h>
#include <fastcdr/exceptions/BadParamException.h>
using namespace eprosima::fastcdr::exception;
#include <utility>
sample::sample()
{
m_index = 0;
m_key_value = 0;
}
sample::~sample()
{
}
sample::sample(const sample &x)
{
m_index = x.m_index;
m_key_value = x.m_key_value;
}
sample::sample(sample &&x)
{
m_index = x.m_index;
m_key_value = x.m_key_value;
}
sample& sample::operator=(const sample &x)
{
m_index = x.m_index;
m_key_value = x.m_key_value;
return *this;
}
sample& sample::operator=(sample &&x)
{
m_index = x.m_index;
m_key_value = x.m_key_value;
return *this;
}
size_t sample::getMaxCdrSerializedSize(size_t current_alignment)
{
size_t initial_alignment = current_alignment;
current_alignment += 1 + eprosima::fastcdr::Cdr::alignment(current_alignment, 1);
current_alignment += 1 + eprosima::fastcdr::Cdr::alignment(current_alignment, 1);
return current_alignment - initial_alignment;
}
size_t sample::getCdrSerializedSize(const sample& data, size_t current_alignment)
{
size_t initial_alignment = current_alignment;
current_alignment += 1 + eprosima::fastcdr::Cdr::alignment(current_alignment, 1);
current_alignment += 1 + eprosima::fastcdr::Cdr::alignment(current_alignment, 1);
return current_alignment - initial_alignment;
}
void sample::serialize(eprosima::fastcdr::Cdr &scdr) const
{
scdr << m_index;
scdr << m_key_value;
}
void sample::deserialize(eprosima::fastcdr::Cdr &dcdr)
{
dcdr >> m_index;
dcdr >> m_key_value;
}
size_t sample::getKeyMaxCdrSerializedSize(size_t current_alignment)
{
size_t current_align = current_alignment;
current_align += 1 + eprosima::fastcdr::Cdr::alignment(current_align, 1);
return current_align;
}
bool sample::isKeyDefined()
{
return true;
}
void sample::serializeKey(eprosima::fastcdr::Cdr &scdr) const
{
scdr << m_key_value;
} | 0 |
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/share/fastrtps/examples/C++ | apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/share/fastrtps/examples/C++/SampleConfig_Events/README.txt | ----------------------------------------------------------------
- Use Case Sample Configuration: Events for eProsima Fast RTPS -
----------------------------------------------------------------
1 - Application description
---------------------------
eProsima Fast RTPS provides users with a wide range of configuration options. This example has the objective of providing a testing ground where you can experiment and see the influence different combinations of parameters can have on the behaviours on the Publisher/Subscriber scheme.
This example is a supplement to the UseCaseLauncher example, consisting on a sample Publisher-Subscriber application with a configuration optimized to perform secure event-based transmissions.
2 - Configuration options
--------------------------
These are the main parameters that affect the behaviour of eProsima Fast RTPS and that are used in the Use Case set of example:
- Reliability Kind
Defines how eProsima Fast RTPS deals upon possible packet loss during data exchanges.
+ Best Effort: No arrival confirmation. It is fast but lost samples are not re-sent.
+ Reliable: With arrival confirmation. It is slower but provides guarantee that all lost samples are re-sent and eventually received by the subscriber.
Since this application runs the Publisher and Subscriber on the same machine, data loss is highly unlikely. Therefore this option will not play a relevant role on the application behaviour.
- Durability Kind
Defines what to do with samples that exist prior to the existence of the Subscriber.
+ Volatile: Past samples are ignored, the Subscriber starts to receive data generated after it has joined the network.
+ Transient Local: Past samples are sent.
- History Kind
Defines the storage policy for past samples.
+ Keep Last: The History will save and give access to the alst "k" received samples. This "k" number is called the History Depth and can be manually set too by the user.
+ Keep All: The History will save and give access to all received samples until the maximum samples size of the History is reached.
This parameter affects cases of "late-joining" Subscribers: Subscribers that come online after data transfers on a topic have started.
- Keys
Keys allow to have multiple data endpoints within a topic as opposed to all data published in a topic going into the same "inbox".
+ On a topic without keys, all pieces of data go into a single endpoint.
+ On a topic without keys, the key field is used to determine which of the multiple endpoints the data goes into. If, for example, a history is set to transient local with depth=3 (the last three samples are stores) then eProsima FastRTPS will ensure that 3 samples per data endpoint are stored. This means that three samples are stored for each unique key instead of three samples total.
It is important to note that even if you configure a Topic and your History to be able to hold items from multiple keys, this configuration does not take effect unless you explicitly enable Keys.
- Depth
The depth is the amount of past samples that are stored in the history before starting to overwrite. Only takes effect when the History is on "Keep Last" mode.
- History Size
This accounts for the total number of samples that can be stored in the history, regardless of any other configuration option.
- Instances
Instances are the different data sinks the History is divided and act as receptors of the Keys.
- Instance size
As it happens with depth, you can define a maximun number of past samples to be stored. If you set one Instance and an instance size more restrictive than the depth, the instance size will be the limiting factor.
5. Application examples
----------------------
The following list provides examples configurations for real-life scenarios, including the present example.
- Multimedia feed
Audio and Video transmission have a common characteristic: Having a stable, high datarate feed is more important than having a 100% lossless transmission.
Reliability: Best-Effort. We want to have a fast tranmission. If a sample is lost, it can be recovered via error-correcting algorithms.
Durability: Volatile. We do not mind data from the past, we want to stream what is happening in the present.
History: Keep-Last with Low Depth. Once displayed or recorded on the receiving application, they are not needed in the History.
note: In the case of video, depth can be as low as 1. A missing sample of a 50 frames per second stream represents virtually no information loss.
- Distributed measurement: Controllers
Lets say we have a factory with a network of distributed temperature sensors and we want to use eProsima Fast RTPS to send data from said sensors to an automation computer which
makes decisions based on the temperature distribution. We would group all sensors within one single topic,
Reliability: Reliable. We want to make sure samples are not lost. Furthermore, since reliable more ensures data delivery, it allows us to detect hardware problems when a sensor becomes silent
Keys: We use a separate key for each sensor. That way new messages from one sensor dont affect the storage of past samples from another sensor.
Durability: Transient Local. We dont want to lose samples due a sensor losing connection temporarily.
History: Keep-Last with High Depth. We want to have access to past samples in order to be able to compute delta values.
- Event-based transmission
In some cases, you may want to transmit information only under certain circumstances that happen in your system, for example a photo from a surveillance camera when it detects movement.
In these cases and due to the low it is important that all datagrams reach their destination
Reliability: Reliable. All samples must reach their destination.
Durability: Volatile. Since corrective actions are taken as events come, past triggers provide have no use.
History: Keep-Last. No past alarm information is necessary for present-time transmissions.
Additional Settings: Reduce heartbeat period, which dictates system response velocity when a sample is lost. A lower heartbeat period equals fast response on data delivery.
| 0 |
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/share/fastrtps/examples/C++ | apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/share/fastrtps/examples/C++/SampleConfig_Events/sample.idl | struct sample{
octet index;
@Key octet key_value;
};
| 0 |
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/share/fastrtps/examples/C++ | apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/share/fastrtps/examples/C++/SampleConfig_Events/sample.h | // Copyright 2016 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.
/*!
* @file sample.h
* This header file contains the declaration of the described types in the IDL file.
*
* This file was generated by the tool gen.
*/
#ifndef _sample_H_
#define _sample_H_
// TODO Poner en el contexto.
#include <stdint.h>
#include <array>
#include <string>
#include <vector>
#if defined(_WIN32)
#if defined(EPROSIMA_USER_DLL_EXPORT)
#define eProsima_user_DllExport __declspec( dllexport )
#else
#define eProsima_user_DllExport
#endif
#else
#define eProsima_user_DllExport
#endif
#if defined(_WIN32)
#if defined(EPROSIMA_USER_DLL_EXPORT)
#if defined(sample_SOURCE)
#define sample_DllAPI __declspec( dllexport )
#else
#define sample_DllAPI __declspec( dllimport )
#endif // sample_SOURCE
#else
#define sample_DllAPI
#endif
#else
#define sample_DllAPI
#endif // _WIN32
namespace eprosima
{
namespace fastcdr
{
class Cdr;
}
}
/*!
* @brief This class represents the structure sample defined by the user in the IDL file.
* @ingroup SAMPLE
*/
class sample
{
public:
/*!
* @brief Default constructor.
*/
eProsima_user_DllExport sample();
/*!
* @brief Default destructor.
*/
eProsima_user_DllExport ~sample();
/*!
* @brief Copy constructor.
* @param x Reference to the object sample that will be copied.
*/
eProsima_user_DllExport sample(const sample &x);
/*!
* @brief Move constructor.
* @param x Reference to the object sample that will be copied.
*/
eProsima_user_DllExport sample(sample &&x);
/*!
* @brief Copy assignment.
* @param x Reference to the object sample that will be copied.
*/
eProsima_user_DllExport sample& operator=(const sample &x);
/*!
* @brief Move assignment.
* @param x Reference to the object sample that will be copied.
*/
eProsima_user_DllExport sample& operator=(sample &&x);
/*!
* @brief This function sets a value in member index
* @param _index New value for member index
*/
inline eProsima_user_DllExport void index(uint8_t _index)
{
m_index = _index;
}
/*!
* @brief This function returns the value of member index
* @return Value of member index
*/
inline eProsima_user_DllExport uint8_t index() const
{
return m_index;
}
/*!
* @brief This function returns a reference to member index
* @return Reference to member index
*/
inline eProsima_user_DllExport uint8_t& index()
{
return m_index;
}
/*!
* @brief This function sets a value in member key_value
* @param _key_value New value for member key_value
*/
inline eProsima_user_DllExport void key_value(uint8_t _key_value)
{
m_key_value = _key_value;
}
/*!
* @brief This function returns the value of member key_value
* @return Value of member key_value
*/
inline eProsima_user_DllExport uint8_t key_value() const
{
return m_key_value;
}
/*!
* @brief This function returns a reference to member key_value
* @return Reference to member key_value
*/
inline eProsima_user_DllExport uint8_t& key_value()
{
return m_key_value;
}
/*!
* @brief This function returns the maximum serialized size of an object
* depending on the buffer alignment.
* @param current_alignment Buffer alignment.
* @return Maximum serialized size.
*/
eProsima_user_DllExport static size_t getMaxCdrSerializedSize(size_t current_alignment = 0);
/*!
* @brief This function returns the serialized size of a data depending on the buffer alignment.
* @param data Data which is calculated its serialized size.
* @param current_alignment Buffer alignment.
* @return Serialized size.
*/
eProsima_user_DllExport static size_t getCdrSerializedSize(const sample& data, size_t current_alignment = 0);
/*!
* @brief This function serializes an object using CDR serialization.
* @param cdr CDR serialization object.
*/
eProsima_user_DllExport void serialize(eprosima::fastcdr::Cdr &cdr) const;
/*!
* @brief This function deserializes an object using CDR serialization.
* @param cdr CDR serialization object.
*/
eProsima_user_DllExport void deserialize(eprosima::fastcdr::Cdr &cdr);
/*!
* @brief This function returns the maximum serialized size of the Key of an object
* depending on the buffer alignment.
* @param current_alignment Buffer alignment.
* @return Maximum serialized size.
*/
eProsima_user_DllExport static size_t getKeyMaxCdrSerializedSize(size_t current_alignment = 0);
/*!
* @brief This function tells you if the Key has been defined for this type
*/
eProsima_user_DllExport static bool isKeyDefined();
/*!
* @brief This function serializes the key members of an object using CDR serialization.
* @param cdr CDR serialization object.
*/
eProsima_user_DllExport void serializeKey(eprosima::fastcdr::Cdr &cdr) const;
private:
uint8_t m_index;
uint8_t m_key_value;
};
#endif // _sample_H_ | 0 |
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/share/fastrtps/examples/C++ | apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/share/fastrtps/examples/C++/SampleConfig_Events/sampleconfig_triggers.cpp | #include <iostream>
#include <string>
#include <fastrtps/participant/Participant.h>
#include <fastrtps/attributes/ParticipantAttributes.h>
#include <fastrtps/subscriber/Subscriber.h>
#include <fastrtps/attributes/SubscriberAttributes.h>
#include <fastrtps/publisher/Publisher.h>
#include <fastrtps/attributes/PublisherAttributes.h>
#include <fastrtps/Domain.h>
#include <fastrtps/subscriber/SampleInfo.h>
#include <fastrtps/utils/eClock.h>
#include "samplePubSubTypes.h"
//Enums and configuration structure
enum Reliability_type { Best_Effort, Reliable };
enum Durability_type { Transient_Local, Volatile };
enum HistoryKind_type { Keep_Last, Keep_All };
enum Key_type { No_Key, With_Key};
typedef struct{
Reliability_type reliability;
Durability_type durability;
HistoryKind_type historykind;
Key_type keys;
uint16_t history_size;
uint8_t depth;
uint8_t no_keys;
uint16_t max_samples_per_key;
} example_configuration;
void triggers();
int main(){
triggers();
return 0;
}
void triggers(){
samplePubSubType sampleType;
sample my_sample;
SampleInfo_t sample_info;
ParticipantAttributes PparamPub;
PparamPub.rtps.builtin.domainId = 0;
PparamPub.rtps.builtin.leaseDuration = c_TimeInfinite;
PparamPub.rtps.setName("PublisherParticipant");
Participant *PubParticipant = Domain::createParticipant(PparamPub);
if(PubParticipant == nullptr){
std::cout << " Something went wrong while creating the Publisher Participant..." << std::endl;
return;
}
Domain::registerType(PubParticipant,(TopicDataType*) &sampleType);
//Publisher config
PublisherAttributes Pparam;
Pparam.topic.topicDataType = sampleType.getName();
Pparam.topic.topicName = "samplePubSubTopic";
Pparam.historyMemoryPolicy = DYNAMIC_RESERVE_MEMORY_MODE;
Pparam.topic.topicKind = NO_KEY;
Pparam.topic.historyQos.kind = KEEP_LAST_HISTORY_QOS;
Pparam.qos.m_durability.kind = VOLATILE_DURABILITY_QOS;
Pparam.qos.m_reliability.kind = RELIABLE_RELIABILITY_QOS;
Pparam.topic.historyQos.depth = 50;
Pparam.topic.resourceLimitsQos.max_samples = 100;
Pparam.topic.resourceLimitsQos.max_instances = 1;
Pparam.topic.resourceLimitsQos.max_samples_per_instance = 100;
std::cout << "Creating Best-Effort Publisher..." << std::endl;
Publisher *myPub= Domain::createPublisher(PubParticipant, Pparam, nullptr);
if(myPub == nullptr){
std::cout << "Something went wrong while creating the Publisher..." << std::endl;
return;
}
ParticipantAttributes PparamSub;
PparamSub.rtps.builtin.domainId = 0;
PparamSub.rtps.builtin.leaseDuration = c_TimeInfinite;
PparamSub.rtps.setName("SubscriberParticipant");
Participant *SubParticipant = Domain::createParticipant(PparamSub);
if(SubParticipant == nullptr){
std::cout << " Something went wrong while creating the Subscriber Participant..." << std::endl;
return;
}
Domain::registerType(SubParticipant,(TopicDataType*) &sampleType);
// Sub
SubscriberAttributes Rparam;
Rparam.topic.topicDataType = sampleType.getName();
Rparam.topic.topicName = "samplePubSubTopic";
Rparam.historyMemoryPolicy = DYNAMIC_RESERVE_MEMORY_MODE;
Rparam.topic.topicKind = NO_KEY;
Rparam.topic.historyQos.kind = KEEP_LAST_HISTORY_QOS;
Rparam.qos.m_durability.kind = VOLATILE_DURABILITY_QOS;
Rparam.qos.m_reliability.kind = RELIABLE_RELIABILITY_QOS;
Rparam.topic.historyQos.depth = 50;
Rparam.topic.resourceLimitsQos.max_samples = 100;
Rparam.topic.resourceLimitsQos.max_instances = 1;
Rparam.topic.resourceLimitsQos.max_samples_per_instance = 100;
std::cout << "Creating Subscriber..." << std::endl;
Subscriber *mySub1= Domain::createSubscriber(PubParticipant, Rparam, nullptr);
if(myPub == nullptr){
std::cout << "something went wrong while creating the Subscriber..." << std::endl;
return;
}
//Send 20 samples
std::cout << "Publishing 10 samples on the topic..." << std::endl;
for(uint8_t j=0; j < 10; j++){
my_sample.index(j+1);
my_sample.key_value(1);
myPub->write(&my_sample);
}
eClock::my_sleep(1500);
//Read the contents of both histories:
std::cout << "The Subscriber holds: " << std::endl;
while(mySub1->readNextData(&my_sample, &sample_info)){
std::cout << std::to_string(my_sample.index()) << " ";
}
std::cout << std::endl;
}
| 0 |
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/share/fastrtps/examples/C++ | apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/share/fastrtps/examples/C++/SampleConfig_Events/samplePubSubTypes.cxx | // Copyright 2016 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.
/*!
* @file samplePubSubTypes.cpp
* This header file contains the implementation of the serialization functions.
*
* This file was generated by the tool fastcdrgen.
*/
#include <fastcdr/FastBuffer.h>
#include <fastcdr/Cdr.h>
#include "samplePubSubTypes.h"
samplePubSubType::samplePubSubType() {
setName("sample");
m_typeSize = (uint32_t)sample::getMaxCdrSerializedSize() + 4 /*encapsulation*/;
m_isGetKeyDefined = sample::isKeyDefined();
m_keyBuffer = (unsigned char*)malloc(sample::getKeyMaxCdrSerializedSize()>16 ? sample::getKeyMaxCdrSerializedSize() : 16);
}
samplePubSubType::~samplePubSubType() {
if(m_keyBuffer!=nullptr)
free(m_keyBuffer);
}
bool samplePubSubType::serialize(void *data, SerializedPayload_t *payload) {
sample *p_type = (sample*) data;
eprosima::fastcdr::FastBuffer fastbuffer((char*) payload->data, payload->max_size); // Object that manages the raw buffer.
eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN,
eprosima::fastcdr::Cdr::DDS_CDR);
payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE;
// Serialize encapsulation
ser.serialize_encapsulation();
p_type->serialize(ser); // Serialize the object:
payload->length = (uint32_t)ser.getSerializedDataLength(); //Get the serialized length
return true;
}
bool samplePubSubType::deserialize(SerializedPayload_t* payload, void* data) {
sample* p_type = (sample*) data; //Convert DATA to pointer of your type
eprosima::fastcdr::FastBuffer fastbuffer((char*)payload->data, payload->length); // Object that manages the raw buffer.
eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN,
eprosima::fastcdr::Cdr::DDS_CDR); // Object that deserializes the data.
// Deserialize encapsulation.
deser.read_encapsulation();
payload->encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE;
p_type->deserialize(deser); //Deserialize the object:
return true;
}
std::function<uint32_t()> samplePubSubType::getSerializedSizeProvider(void* data) {
return [data]() -> uint32_t {
return (uint32_t)type::getCdrSerializedSize(*static_cast<sample*>(data)) + 4 /*encapsulation*/;
};
}
void* samplePubSubType::createData() {
return (void*)new sample();
}
void samplePubSubType::deleteData(void* data) {
delete((sample*)data);
}
bool samplePubSubType::getKey(void *data, InstanceHandle_t* handle) {
if(!m_isGetKeyDefined)
return false;
sample* p_type = (sample*) data;
eprosima::fastcdr::FastBuffer fastbuffer((char*)m_keyBuffer,sample::getKeyMaxCdrSerializedSize()); // Object that manages the raw buffer.
eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS); // Object that serializes the data.
p_type->serializeKey(ser);
if(sample::getKeyMaxCdrSerializedSize()>16) {
m_md5.init();
m_md5.update(m_keyBuffer,(unsigned int)ser.getSerializedDataLength());
m_md5.finalize();
for(uint8_t i = 0;i<16;++i) {
handle->value[i] = m_md5.digest[i];
}
}
else {
for(uint8_t i = 0;i<16;++i) {
handle->value[i] = m_keyBuffer[i];
}
}
return true;
}
| 0 |
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/share/fastrtps/examples/C++ | apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/share/fastrtps/examples/C++/RTPSTest_as_socket/TestWriterSocket.cpp | // Copyright 2016 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.
/**
* @file TestWriterSocket.cpp
*
*/
#include "TestWriterSocket.h"
#include "fastrtps/rtps/writer/RTPSWriter.h"
#include "fastrtps/rtps/participant/RTPSParticipant.h"
#include "fastrtps/rtps/RTPSDomain.h"
#include "fastrtps/rtps/attributes/RTPSParticipantAttributes.h"
#include "fastrtps/rtps/attributes/WriterAttributes.h"
#include "fastrtps/rtps/attributes/HistoryAttributes.h"
#include "fastrtps/rtps/history/WriterHistory.h"
TestWriterSocket::TestWriterSocket():
mp_participant(nullptr),
mp_writer(nullptr),
mp_history(nullptr)
{
}
TestWriterSocket::~TestWriterSocket()
{
RTPSDomain::removeRTPSParticipant(mp_participant);
delete(mp_history);
}
bool TestWriterSocket::init(std::string ip, uint32_t port)
{
//CREATE PARTICIPANT
RTPSParticipantAttributes PParam;
PParam.builtin.use_SIMPLE_RTPSParticipantDiscoveryProtocol = false;
PParam.builtin.use_WriterLivelinessProtocol = false;
mp_participant = RTPSDomain::createParticipant(PParam);
if(mp_participant==nullptr)
return false;
//CREATE WRITERHISTORY
HistoryAttributes hatt;
hatt.payloadMaxSize = 255;
mp_history = new WriterHistory(hatt);
//CREATE WRITER
WriterAttributes watt;
watt.endpoint.reliabilityKind = BEST_EFFORT;
mp_writer = RTPSDomain::createRTPSWriter(mp_participant,watt,mp_history);
if(mp_writer == nullptr)
return false;
//ADD REMOTE READER (IN THIS CASE A READER IN THE SAME MACHINE)
RemoteReaderAttributes ratt;
Locator_t loc;
loc.set_IP4_address(ip);
loc.port = port;
ratt.endpoint.multicastLocatorList.push_back(loc);
mp_writer->matched_reader_add(ratt);
return true;
}
void TestWriterSocket::run(uint16_t nmsgs)
{
for(int i = 0;i<nmsgs;++i )
{
CacheChange_t * ch = mp_writer->new_change([]() -> uint32_t { return 255; }, ALIVE);
#if defined(_WIN32)
ch->serializedPayload.length =
sprintf_s((char*)ch->serializedPayload.data,255, "My example string %d", i)+1;
#else
ch->serializedPayload.length =
sprintf((char*)ch->serializedPayload.data,"My example string %d",i)+1;
#endif
printf("Sending: %s\n",(char*)ch->serializedPayload.data);
mp_history->add_change(ch);
}
}
| 0 |
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/share/fastrtps/examples/C++ | apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/share/fastrtps/examples/C++/RTPSTest_as_socket/CMakeLists.txt | # Copyright 2016 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.
cmake_minimum_required(VERSION 2.8.12)
project("RTPSTest_as_socket")
# Find requirements
find_package(fastcdr REQUIRED)
find_package(fastrtps REQUIRED)
# Set C++11
include(CheckCXXCompilerFlag)
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_CLANG OR
CMAKE_CXX_COMPILER_ID MATCHES "Clang")
check_cxx_compiler_flag(--std=c++11 SUPPORTS_CXX11)
if(SUPPORTS_CXX11)
add_compile_options(--std=c++11)
else()
message(FATAL_ERROR "Compiler doesn't support C++11")
endif()
endif()
message(STATUS "Configuring RTPSTest_as_socket...")
file(GLOB RTPSTESTASSOCKET_SOURCES "*.cpp")
add_executable(RTPSTest_as_socket ${RTPSTESTASSOCKET_SOURCES})
target_link_libraries(RTPSTest_as_socket fastrtps fastcdr)
install(TARGETS RTPSTest_as_socket
RUNTIME DESTINATION examples/C++/RTPSTest_as_socket/${BIN_INSTALL_DIR}
)
| 0 |
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/share/fastrtps/examples/C++ | apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/share/fastrtps/examples/C++/RTPSTest_as_socket/TestReaderSocket.h | // Copyright 2016 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.
/**
* @file TestReaderSocket.h
*
*/
#ifndef TESTREADERSOCKET_H_
#define TESTREADERSOCKET_H_
#include "fastrtps/rtps/rtps_fwd.h"
using namespace eprosima::fastrtps::rtps;
#include "fastrtps/rtps/reader/ReaderListener.h"
class TestReaderSocket {
public:
TestReaderSocket();
virtual ~TestReaderSocket();
RTPSParticipant* mp_participant;
RTPSReader* mp_reader;
ReaderHistory* mp_history;
bool init(std::string ip,uint32_t port);
void run();
class MyListener:public ReaderListener
{
public:
MyListener():m_received(0){};
~MyListener(){};
void onNewCacheChangeAdded(RTPSReader* reader,const CacheChange_t* const change);
uint32_t m_received;
}m_listener;
};
#endif /* TESTREADER_H_ */
| 0 |
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/share/fastrtps/examples/C++ | apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/share/fastrtps/examples/C++/RTPSTest_as_socket/Makefile | # Copyright 2016 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.
CPP=g++
LN=g++
AR=ar
CP=cp
SYSLIBS= -ldl -lnsl -lm -lpthread -lrt
DEFINES=
COMMON_CFLAGS= -c -Wall -D__LITTLE_ENDIAN__ -std=c++11
## CHOOSE HERE BETWEEN 32 and 64 bit architecture
##32 BIT ARCH:
#COMMON_CFLAGS+= -m32 -fpic
#LDFLAGS=-m32
#64BIT ARCH:
COMMON_CFLAGS+= -m64 -fpic
LDFLAGS=-m64
CFLAGS = $(COMMON_CFLAGS) -O2
INCLUDES= -I.
LIBS = -lfastcdr -lfastrtps $(SYSLIBS)
DIRECTORIES= output.dir bin.dir
all: $(DIRECTORIES) RTPSTest_as_socket
RTPSTESTASSOCKET_TARGET= bin/RTPSTest_as_socket
RTPSTESTASSOCKET_SRC_CXXFILES=
RTPSTESTASSOCKET_SRC_CPPFILES= RTPSTest_as_socket/TestReaderSocket.cpp \
RTPSTest_as_socket/TestWriterSocket.cpp \
RTPSTest_as_socket/main_RTPSTest.cpp
# Project sources are copied to the current directory
RTPSTESTASSOCKET_SRCS= $(RTPSTESTASSOCKET_SRC_CXXFILES) $(RTPSTESTASSOCKET_SRC_CPPFILES)
# Source directories
RTPSTESTASSOCKET_SOURCES_DIRS_AUX= $(foreach srcdir, $(dir $(RTPSTESTASSOCKET_SRCS)), $(srcdir))
RTPSTESTASSOCKET_SOURCES_DIRS= $(shell echo $(RTPSTESTASSOCKET_SOURCES_DIRS_AUX) | tr " " "\n" | sort | uniq | tr "\n" " ")
RTPSTESTASSOCKET_OBJS = $(foreach obj,$(notdir $(addsuffix .o, $(RTPSTESTASSOCKET_SRCS))), output/$(obj))
RTPSTESTASSOCKET_DEPS = $(foreach dep,$(notdir $(addsuffix .d, $(RTPSTESTASSOCKET_SRCS))), output/$(dep))
OBJS+= $(RTPSTESTASSOCKET_OBJS)
DEPS+= $(RTPSTESTASSOCKET_DEPS)
RTPSTest_as_socket: $(RTPSTESTASSOCKET_TARGET)
$(RTPSTESTASSOCKET_TARGET): $(RTPSTESTASSOCKET_OBJS)
$(LN) $(LDFLAGS) -o $(RTPSTESTASSOCKET_TARGET) $(RTPSTESTASSOCKET_OBJS) $(LIBS)
vpath %.cxx $(RTPSTESTASSOCKET_SOURCES_DIRS)
vpath %.cpp $(RTPSTESTASSOCKET_SOURCES_DIRS)
output/%.cxx.o:%.cxx
@echo Calculating dependencies $<
@$(CC) $(CFLAGS) -MM $(CFLAGS) $(INCLUDES) $< | sed "s/^.*:/output\/&/g" > $(@:%.cxx.o=%.cxx.d)
@echo Compiling $<
@$(CC) $(CFLAGS) $(INCLUDES) $< -o $@
output/%.cpp.o:%.cpp
@echo Calculating dependencies $<
@$(CPP) $(CFLAGS) -MM $(CFLAGS) $(INCLUDES) $< | sed "s/^.*:/output\/&/g" > $(@:%.cpp.o=%.cpp.d)
@echo Compiling $<
@$(CPP) $(CFLAGS) $(INCLUDES) $< -o $@
.PHONY: RTPSTest_as_socket
clean:
@rm -f $(OBJS)
@rm -f $(DEPS)
ifneq ($(MAKECMDGOALS), clean)
-include $(DEPS)
endif
%.dir :
@echo "Checking directory $*"
@if [ ! -d $* ]; then \
echo "Making directory $*"; \
mkdir -p $* ; \
fi;
| 0 |
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/share/fastrtps/examples/C++ | apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/share/fastrtps/examples/C++/RTPSTest_as_socket/TestReaderSocket.cpp | // Copyright 2016 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.
/**
* @file TestReaderSocket.cpp
*
*/
#include "TestReaderSocket.h"
#include "fastrtps/rtps/reader/RTPSReader.h"
#include "fastrtps/rtps/participant/RTPSParticipant.h"
#include "fastrtps/rtps/RTPSDomain.h"
#include "fastrtps/rtps/attributes/RTPSParticipantAttributes.h"
#include "fastrtps/rtps/attributes/ReaderAttributes.h"
#include "fastrtps/rtps/attributes/HistoryAttributes.h"
#include "fastrtps/rtps/history/ReaderHistory.h"
TestReaderSocket::TestReaderSocket():
mp_participant(nullptr),
mp_reader(nullptr),
mp_history(nullptr)
{
}
TestReaderSocket::~TestReaderSocket()
{
RTPSDomain::removeRTPSParticipant(mp_participant);
delete(mp_history);
}
bool TestReaderSocket::init(std::string ip, uint32_t port)
{
//CREATE PARTICIPANT
RTPSParticipantAttributes PParam;
PParam.builtin.use_SIMPLE_RTPSParticipantDiscoveryProtocol = false;
PParam.builtin.use_WriterLivelinessProtocol = false;
mp_participant = RTPSDomain::createParticipant(PParam);
if(mp_participant==nullptr)
return false;
//CREATE READERHISTORY
HistoryAttributes hatt;
hatt.payloadMaxSize = 255;
mp_history = new ReaderHistory(hatt);
//CREATE READER
ReaderAttributes ratt;
Locator_t loc;
loc.set_IP4_address(ip);
loc.port = port;
ratt.endpoint.multicastLocatorList.push_back(loc);
mp_reader = RTPSDomain::createRTPSReader(mp_participant,ratt,mp_history,&m_listener);
if(mp_reader == nullptr)
return false;
return true;
}
void TestReaderSocket::run()
{
printf("Enter number to stop reader.\n");
int aux;
std::cin >> aux;
}
void TestReaderSocket::MyListener::onNewCacheChangeAdded(RTPSReader* reader,const CacheChange_t* const change)
{
printf("Received: %s\n",change->serializedPayload.data);
reader->getHistory()->remove_change((CacheChange_t*)change);
m_received++;
}
| 0 |
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/share/fastrtps/examples/C++ | apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/share/fastrtps/examples/C++/RTPSTest_as_socket/TestWriterSocket.h | // Copyright 2016 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.
/**
* @file TestWriterSocket.h
*
*/
#ifndef TESTWRITERSOCKET_H_
#define TESTWRITERSOCKET_H_
#include "fastrtps/rtps/rtps_fwd.h"
using namespace eprosima::fastrtps::rtps;
#include <string>
#include <cstdio>
#include <cstdint>
class TestWriterSocket {
public:
TestWriterSocket();
virtual ~TestWriterSocket();
RTPSParticipant* mp_participant;
RTPSWriter* mp_writer;
WriterHistory* mp_history;
bool init(std::string ip,uint32_t port);
void run(uint16_t nmsgs);
};
#endif /* TESTWRITER_H_ */
| 0 |
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/share/fastrtps/examples/C++ | apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/share/fastrtps/examples/C++/RTPSTest_as_socket/main_RTPSTest.cpp | // Copyright 2016 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.
#include <stdio.h>
#include <cstring>
#include <iostream>
#include <iomanip>
#include <bitset>
#include <cstdint>
#include <sstream>
#include "fastrtps/log/Log.h"
#include "fastrtps/rtps/RTPSDomain.h"
#include "TestWriterSocket.h"
#include "TestReaderSocket.h"
using namespace eprosima;
using namespace fastrtps;
using namespace rtps;
using namespace std;
int main(int argc, char** argv){
std::cout << "Starting" << std::endl;
int type;
if(argc > 1)
{
if(strcmp(argv[1],"writer")==0)
type = 1;
else if(strcmp(argv[1],"reader")==0)
type = 2;
else
{
std::cout << "NEEDS writer OR reader as first argument"<<std::endl;
return 0;
}
}
else
{
std::cout << "NEEDS writer OR reader ARGUMENT"<<std::endl;
std::cout << "RTPSTest writer"<<std::endl;
std::cout << "RTPSTest reader" <<std::endl;
return 0;
}
switch (type)
{
case 1:
{
TestWriterSocket TW;
if(TW.init("239.255.1.4",22222))
TW.run(10);
break;
}
case 2:
{
TestReaderSocket TR;
if(TR.init("239.255.1.4",22222))
TR.run();
break;
}
}
RTPSDomain::stopAll();
std::cout << "EVERYTHING STOPPED FINE"<<std::endl;
return 0;
}
| 0 |
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/share/fastrtps/examples/C++ | apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/share/fastrtps/examples/C++/Filtering/FilteringExample.idl | struct FilteringExample
{
long sampleNumber;
}; | 0 |
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/share/fastrtps/examples/C++ | apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/share/fastrtps/examples/C++/Filtering/FilteringExamplePubSubTypes.cxx | // Copyright 2016 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.
/*!
* @file FilteringExamplePubSubTypes.cpp
* This header file contains the implementation of the serialization functions.
*
* This file was generated by the tool fastcdrgen.
*/
#include <fastcdr/FastBuffer.h>
#include <fastcdr/Cdr.h>
#include "FilteringExamplePubSubTypes.h"
FilteringExamplePubSubType::FilteringExamplePubSubType() {
setName("FilteringExample");
m_typeSize = (uint32_t)FilteringExample::getMaxCdrSerializedSize() + 4 /*encapsulation*/;
m_isGetKeyDefined = FilteringExample::isKeyDefined();
m_keyBuffer = (unsigned char*)malloc(FilteringExample::getKeyMaxCdrSerializedSize()>16 ? FilteringExample::getKeyMaxCdrSerializedSize() : 16);
}
FilteringExamplePubSubType::~FilteringExamplePubSubType() {
if(m_keyBuffer!=nullptr)
free(m_keyBuffer);
}
bool FilteringExamplePubSubType::serialize(void *data, SerializedPayload_t *payload) {
FilteringExample *p_type = (FilteringExample*) data;
eprosima::fastcdr::FastBuffer fastbuffer((char*) payload->data, payload->max_size); // Object that manages the raw buffer.
eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN,
eprosima::fastcdr::Cdr::DDS_CDR);
payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE;
// Serialize encapsulation
ser.serialize_encapsulation();
p_type->serialize(ser); // Serialize the object:
payload->length = (uint32_t)ser.getSerializedDataLength(); //Get the serialized length
return true;
}
bool FilteringExamplePubSubType::deserialize(SerializedPayload_t* payload, void* data) {
FilteringExample* p_type = (FilteringExample*) data; //Convert DATA to pointer of your type
eprosima::fastcdr::FastBuffer fastbuffer((char*)payload->data, payload->length); // Object that manages the raw buffer.
eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN,
eprosima::fastcdr::Cdr::DDS_CDR); // Object that deserializes the data.
// Deserialize encapsulation.
deser.read_encapsulation();
payload->encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE;
p_type->deserialize(deser); //Deserialize the object:
return true;
}
std::function<uint32_t()> FilteringExamplePubSubType::getSerializedSizeProvider(void* data) {
return [data]() -> uint32_t {
return (uint32_t)type::getCdrSerializedSize(*static_cast<FilteringExample*>(data)) + 4 /*encapsulation*/;
};
}
void* FilteringExamplePubSubType::createData() {
return (void*)new FilteringExample();
}
void FilteringExamplePubSubType::deleteData(void* data) {
delete((FilteringExample*)data);
}
bool FilteringExamplePubSubType::getKey(void *data, InstanceHandle_t* handle) {
if(!m_isGetKeyDefined)
return false;
FilteringExample* p_type = (FilteringExample*) data;
eprosima::fastcdr::FastBuffer fastbuffer((char*)m_keyBuffer,FilteringExample::getKeyMaxCdrSerializedSize()); // Object that manages the raw buffer.
eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS); // Object that serializes the data.
p_type->serializeKey(ser);
if(FilteringExample::getKeyMaxCdrSerializedSize()>16) {
m_md5.init();
m_md5.update(m_keyBuffer,(unsigned int)ser.getSerializedDataLength());
m_md5.finalize();
for(uint8_t i = 0;i<16;++i) {
handle->value[i] = m_md5.digest[i];
}
}
else {
for(uint8_t i = 0;i<16;++i) {
handle->value[i] = m_keyBuffer[i];
}
}
return true;
}
| 0 |
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/share/fastrtps/examples/C++ | apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/share/fastrtps/examples/C++/Filtering/CMakeLists.txt | # Copyright 2016 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.
cmake_minimum_required(VERSION 2.8.12)
project("FilteringExample")
# Find requirements
find_package(fastcdr REQUIRED)
find_package(fastrtps REQUIRED)
# Set C++11
include(CheckCXXCompilerFlag)
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_CLANG OR
CMAKE_CXX_COMPILER_ID MATCHES "Clang")
check_cxx_compiler_flag(--std=c++11 SUPPORTS_CXX11)
if(SUPPORTS_CXX11)
add_compile_options(--std=c++11)
else()
message(FATAL_ERROR "Compiler doesn't support C++11")
endif()
endif()
message(STATUS "Configuring Filtering example...")
file(GLOB DEADLINEQOS_EXAMPLE_SOURCES "*.cxx")
add_executable(FilteringExample ${DEADLINEQOS_EXAMPLE_SOURCES})
target_link_libraries(FilteringExample fastrtps fastcdr)
install(TARGETS FilteringExample
RUNTIME DESTINATION examples/C++/FilteringExample/${BIN_INSTALL_DIR}
)
| 0 |
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/share/fastrtps/examples/C++ | apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/share/fastrtps/examples/C++/Filtering/FilteringExamplePublisher.h | // Copyright 2016 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 _FILTERINGEXAMPLE_PUBLISHER_H_
#define _FILTERINGEXAMPLE_PUBLISHER_H_
#include <fastrtps/fastrtps_fwd.h>
#include <fastrtps/publisher/PublisherListener.h>
#include "FilteringExamplePubSubTypes.h"
using namespace eprosima::fastrtps;
class FilteringExamplePublisher
{
public:
FilteringExamplePublisher();
virtual ~FilteringExamplePublisher();
bool init();
void run();
private:
Participant *mp_participant;
Publisher *mp_fast_publisher;
Publisher *mp_slow_publisher;
class PubListener : public PublisherListener
{
public:
PubListener() : n_matched(0){};
~PubListener(){};
void onPublicationMatched(Publisher* pub,MatchingInfo& info);
int n_matched;
} m_listener;
FilteringExamplePubSubType myType;
};
#endif // _FILTERINGEXAMPLE_PUBLISHER_H_
| 0 |
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/share/fastrtps/examples/C++ | apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/share/fastrtps/examples/C++/Filtering/Makefile | # Copyright 2016 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.
CPP=g++
LN=g++
AR=ar
CP=cp
SYSLIBS= -ldl -lnsl -lm -lpthread -lrt
DEFINES=
COMMON_CFLAGS= -c -Wall -D__LITTLE_ENDIAN__ -std=c++11
## CHOOSE HERE BETWEEN 32 and 64 bit architecture
##32 BIT ARCH:
#COMMON_CFLAGS+= -m32 -fpic
#LDFLAGS=-m32
#64BIT ARCH:
COMMON_CFLAGS+= -m64 -fpic
LDFLAGS=-m64
CFLAGS = $(COMMON_CFLAGS) -O2
INCLUDES= -I.
LIBS = -lfastcdr -lfastrtps $(SYSLIBS)
DIRECTORIES= output.dir bin.dir
all: $(DIRECTORIES) Filtering
FILTERINGEXAMPLE_TARGET= bin/Filtering
FILTERINGEXAMPLE_SRC_CXXFILES=
FILTERINGEXAMPLE_SRC_CPPFILES= Filtering/FilteringExample.cxx \
Filtering/FilteringExamplePubSubTypes.cxx \
Filtering/FilteringExamplePublisher.cxx \
Filtering/FilteringExampleSubscriber.cxx \
Filtering/FilteringExamplePubSubMain.cxx
# Project sources are copied to the current directory
FILTERINGEXAMPLE_SRCS= $(FILTERINGEXAMPLE_SRC_CXXFILES) $(FILTERINGEXAMPLE_SRC_CPPFILES)
# Source directories
FILTERINGEXAMPLE_SOURCES_DIRS_AUX= $(foreach srcdir, $(dir $(FILTERINGEXAMPLE_SRCS)), $(srcdir))
FILTERINGEXAMPLE_SOURCES_DIRS= $(shell echo $(FILTERINGEXAMPLE_SOURCES_DIRS_AUX) | tr " " "\n" | sort | uniq | tr "\n" " ")
FILTERINGEXAMPLE_OBJS = $(foreach obj,$(notdir $(addsuffix .o, $(FILTERINGEXAMPLE_SRCS))), output/$(obj))
FILTERINGEXAMPLE_DEPS = $(foreach dep,$(notdir $(addsuffix .d, $(FILTERINGEXAMPLE_SRCS))), output/$(dep))
OBJS+= $(FILTERINGEXAMPLE_OBJS)
DEPS+= $(FILTERINGEXAMPLE_DEPS)
Filtering: $(FILTERINGEXAMPLE_TARGET)
$(FILTERINGEXAMPLE_TARGET): $(FILTERINGEXAMPLE_OBJS)
$(LN) $(LDFLAGS) -o $(FILTERINGEXAMPLE_TARGET) $(FILTERINGEXAMPLE_OBJS) $(LIBS)
vpath %.cxx $(FILTERINGEXAMPLE_SOURCES_DIRS)
vpath %.cpp $(FILTERINGEXAMPLE_SOURCES_DIRS)
output/%.cxx.o:%.cxx
@echo Calculating dependencies $<
@$(CC) $(CFLAGS) -MM $(CFLAGS) $(INCLUDES) $< | sed "s/^.*:/output\/&/g" > $(@:%.cxx.o=%.cxx.d)
@echo Compiling $<
@$(CC) $(CFLAGS) $(INCLUDES) $< -o $@
output/%.cpp.o:%.cpp
@echo Calculating dependencies $<
@$(CPP) $(CFLAGS) -MM $(CFLAGS) $(INCLUDES) $< | sed "s/^.*:/output\/&/g" > $(@:%.cpp.o=%.cpp.d)
@echo Compiling $<
@$(CPP) $(CFLAGS) $(INCLUDES) $< -o $@
.PHONY: Filtering
clean:
@rm -f $(OBJS)
@rm -f $(DEPS)
ifneq ($(MAKECMDGOALS), clean)
-include $(DEPS)
endif
%.dir :
@echo "Checking directory $*"
@if [ ! -d $* ]; then \
echo "Making directory $*"; \
mkdir -p $* ; \
fi;
| 0 |
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/share/fastrtps/examples/C++ | apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/share/fastrtps/examples/C++/Filtering/FilteringExample.cxx | // Copyright 2016 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.
/*!
* @file FilteringExample.cpp
* This source file contains the definition of the described types in the IDL file.
*
* This file was generated by the tool gen.
*/
#ifdef _WIN32
// Remove linker warning LNK4221 on Visual Studio
namespace { char dummy; }
#endif
#include "FilteringExample.h"
#include <fastcdr/Cdr.h>
#include <fastcdr/exceptions/BadParamException.h>
using namespace eprosima::fastcdr::exception;
#include <utility>
FilteringExample::FilteringExample()
{
m_sampleNumber = 0;
}
FilteringExample::~FilteringExample()
{
}
FilteringExample::FilteringExample(const FilteringExample &x)
{
m_sampleNumber = x.m_sampleNumber;
}
FilteringExample::FilteringExample(FilteringExample &&x)
{
m_sampleNumber = x.m_sampleNumber;
}
FilteringExample& FilteringExample::operator=(const FilteringExample &x)
{
m_sampleNumber = x.m_sampleNumber;
return *this;
}
FilteringExample& FilteringExample::operator=(FilteringExample &&x)
{
m_sampleNumber = x.m_sampleNumber;
return *this;
}
size_t FilteringExample::getMaxCdrSerializedSize(size_t current_alignment)
{
size_t initial_alignment = current_alignment;
current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4);
return current_alignment - initial_alignment;
}
size_t FilteringExample::getCdrSerializedSize(const FilteringExample& data, size_t current_alignment)
{
size_t initial_alignment = current_alignment;
current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4);
return current_alignment - initial_alignment;
}
void FilteringExample::serialize(eprosima::fastcdr::Cdr &scdr) const
{
scdr << m_sampleNumber;
}
void FilteringExample::deserialize(eprosima::fastcdr::Cdr &dcdr)
{
dcdr >> m_sampleNumber;
}
size_t FilteringExample::getKeyMaxCdrSerializedSize(size_t current_alignment)
{
size_t current_align = current_alignment;
return current_align;
}
bool FilteringExample::isKeyDefined()
{
return false;
}
void FilteringExample::serializeKey(eprosima::fastcdr::Cdr &scdr) const
{
} | 0 |
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/share/fastrtps/examples/C++ | apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/share/fastrtps/examples/C++/Filtering/FilteringExampleSubscriber.h | // Copyright 2016 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 _FILTERINGEXAMPLE_SUBSCRIBER_H_
#define _FILTERINGEXAMPLE_SUBSCRIBER_H_
#include <fastrtps/fastrtps_fwd.h>
#include <fastrtps/subscriber/SubscriberListener.h>
#include <fastrtps/subscriber/SampleInfo.h>
#include "FilteringExamplePubSubTypes.h"
using namespace eprosima::fastrtps;
class FilteringExampleSubscriber
{
public:
FilteringExampleSubscriber();
virtual ~FilteringExampleSubscriber();
bool init(int type);
void run();
private:
Participant *mp_participant;
Subscriber *mp_subscriber;
class SubListener : public SubscriberListener
{
public:
SubListener() : n_matched(0),n_msg(0){};
~SubListener(){};
void onSubscriptionMatched(Subscriber* sub,MatchingInfo& info);
void onNewDataMessage(Subscriber* sub);
SampleInfo_t m_info;
int n_matched;
int n_msg;
} m_listener;
FilteringExamplePubSubType myType;
};
#endif // _FilteringExample_SUBSCRIBER_H_
| 0 |
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/share/fastrtps/examples/C++ | apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/share/fastrtps/examples/C++/Filtering/FilteringExample.h | // Copyright 2016 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.
/*!
* @file FilteringExample.h
* This header file contains the declaration of the described types in the IDL file.
*
* This file was generated by the tool gen.
*/
#ifndef _FilteringExample_H_
#define _FilteringExample_H_
// TODO Poner en el contexto.
#include <stdint.h>
#include <array>
#include <string>
#include <vector>
#if defined(_WIN32)
#if defined(EPROSIMA_USER_DLL_EXPORT)
#define eProsima_user_DllExport __declspec( dllexport )
#else
#define eProsima_user_DllExport
#endif
#else
#define eProsima_user_DllExport
#endif
#if defined(_WIN32)
#if defined(EPROSIMA_USER_DLL_EXPORT)
#if defined(FilteringExample_SOURCE)
#define FilteringExample_DllAPI __declspec( dllexport )
#else
#define FilteringExample_DllAPI __declspec( dllimport )
#endif // FilteringExample_SOURCE
#else
#define FilteringExample_DllAPI
#endif
#else
#define FilteringExample_DllAPI
#endif // _WIN32
namespace eprosima
{
namespace fastcdr
{
class Cdr;
}
}
/*!
* @brief This class represents the structure FilteringExample defined by the user in the IDL file.
* @ingroup FILTERINGEXAMPLE
*/
class FilteringExample
{
public:
/*!
* @brief Default constructor.
*/
eProsima_user_DllExport FilteringExample();
/*!
* @brief Default destructor.
*/
eProsima_user_DllExport ~FilteringExample();
/*!
* @brief Copy constructor.
* @param x Reference to the object FilteringExample that will be copied.
*/
eProsima_user_DllExport FilteringExample(const FilteringExample &x);
/*!
* @brief Move constructor.
* @param x Reference to the object FilteringExample that will be copied.
*/
eProsima_user_DllExport FilteringExample(FilteringExample &&x);
/*!
* @brief Copy assignment.
* @param x Reference to the object FilteringExample that will be copied.
*/
eProsima_user_DllExport FilteringExample& operator=(const FilteringExample &x);
/*!
* @brief Move assignment.
* @param x Reference to the object FilteringExample that will be copied.
*/
eProsima_user_DllExport FilteringExample& operator=(FilteringExample &&x);
/*!
* @brief This function sets a value in member sampleNumber
* @param _sampleNumber New value for member sampleNumber
*/
inline eProsima_user_DllExport void sampleNumber(int32_t _sampleNumber)
{
m_sampleNumber = _sampleNumber;
}
/*!
* @brief This function returns the value of member sampleNumber
* @return Value of member sampleNumber
*/
inline eProsima_user_DllExport int32_t sampleNumber() const
{
return m_sampleNumber;
}
/*!
* @brief This function returns a reference to member sampleNumber
* @return Reference to member sampleNumber
*/
inline eProsima_user_DllExport int32_t& sampleNumber()
{
return m_sampleNumber;
}
/*!
* @brief This function returns the maximum serialized size of an object
* depending on the buffer alignment.
* @param current_alignment Buffer alignment.
* @return Maximum serialized size.
*/
eProsima_user_DllExport static size_t getMaxCdrSerializedSize(size_t current_alignment = 0);
/*!
* @brief This function returns the serialized size of a data depending on the buffer alignment.
* @param data Data which is calculated its serialized size.
* @param current_alignment Buffer alignment.
* @return Serialized size.
*/
eProsima_user_DllExport static size_t getCdrSerializedSize(const FilteringExample& data, size_t current_alignment = 0);
/*!
* @brief This function serializes an object using CDR serialization.
* @param cdr CDR serialization object.
*/
eProsima_user_DllExport void serialize(eprosima::fastcdr::Cdr &cdr) const;
/*!
* @brief This function deserializes an object using CDR serialization.
* @param cdr CDR serialization object.
*/
eProsima_user_DllExport void deserialize(eprosima::fastcdr::Cdr &cdr);
/*!
* @brief This function returns the maximum serialized size of the Key of an object
* depending on the buffer alignment.
* @param current_alignment Buffer alignment.
* @return Maximum serialized size.
*/
eProsima_user_DllExport static size_t getKeyMaxCdrSerializedSize(size_t current_alignment = 0);
/*!
* @brief This function tells you if the Key has been defined for this type
*/
eProsima_user_DllExport static bool isKeyDefined();
/*!
* @brief This function serializes the key members of an object using CDR serialization.
* @param cdr CDR serialization object.
*/
eProsima_user_DllExport void serializeKey(eprosima::fastcdr::Cdr &cdr) const;
private:
int32_t m_sampleNumber;
};
#endif // _FilteringExample_H_ | 0 |
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/share/fastrtps/examples/C++ | apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/share/fastrtps/examples/C++/Filtering/FilteringExamplePubSubMain.cxx | // Copyright 2016 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.
#include "FilteringExamplePublisher.h"
#include "FilteringExampleSubscriber.h"
#include <fastrtps/Domain.h>
#include <fastrtps/log/Log.h>
using namespace eprosima;
using namespace eprosima::fastrtps;
int main(int argc, char** argv)
{
std::cout << "Starting " << std::endl;
int type = 1;
int subscriberType = 1;
if (argc > 1)
{
if (strcmp(argv[1], "publisher") == 0)
{
type = 1;
}
else if (strcmp(argv[1], "subscriber") == 0)
{
type = 2;
}
}
else
{
std::cout << "publisher OR subscriber argument needed" << std::endl;
return 0;
}
if (type == 2) // get the subscriber type (fast or slow)
{
if (argc > 2) {
if (strcmp(argv[2], "fast") == 0)
{
subscriberType = 1;
}
else if (strcmp(argv[2], "slow") == 0)
{
subscriberType = 2;
}
}
else
{
std::cout << "subscriber type argument needed (fast or slow)" << std::endl;
return 0;
}
}
// Register the type being used
switch(type)
{
case 1:
{
FilteringExamplePublisher mypub;
if (mypub.init())
{
mypub.run();
}
break;
}
case 2:
{
FilteringExampleSubscriber mysub;
if (mysub.init(subscriberType))
{
mysub.run();
}
break;
}
}
return 0;
}
| 0 |
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/share/fastrtps/examples/C++ | apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/share/fastrtps/examples/C++/Filtering/FilteringExamplePubSubTypes.h | // Copyright 2016 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.
/*!
* @file FilteringExamplePubSubTypes.h
* This header file contains the declaration of the serialization functions.
*
* This file was generated by the tool fastcdrgen.
*/
#ifndef _FILTERINGEXAMPLE_PUBSUBTYPES_H_
#define _FILTERINGEXAMPLE_PUBSUBTYPES_H_
#include <fastrtps/TopicDataType.h>
using namespace eprosima::fastrtps;
#include "FilteringExample.h"
/*!
* @brief This class represents the TopicDataType of the type FilteringExample defined by the user in the IDL file.
* @ingroup FILTERINGEXAMPLE
*/
class FilteringExamplePubSubType : public TopicDataType {
public:
typedef FilteringExample type;
FilteringExamplePubSubType();
virtual ~FilteringExamplePubSubType();
bool serialize(void *data, SerializedPayload_t *payload);
bool deserialize(SerializedPayload_t *payload, void *data);
std::function<uint32_t()> getSerializedSizeProvider(void* data);
bool getKey(void *data, InstanceHandle_t *ihandle);
void* createData();
void deleteData(void * data);
MD5 m_md5;
unsigned char* m_keyBuffer;
};
#endif // _FilteringExample_PUBSUBTYPE_H_ | 0 |
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/share/fastrtps/examples/C++ | apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/share/fastrtps/examples/C++/Filtering/FilteringExamplePublisher.cxx | // Copyright 2016 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.
#include <fastrtps/participant/Participant.h>
#include <fastrtps/attributes/ParticipantAttributes.h>
#include <fastrtps/publisher/Publisher.h>
#include <fastrtps/attributes/PublisherAttributes.h>
#include <fastrtps/Domain.h>
#include <fastrtps/utils/eClock.h>
#include "FilteringExamplePublisher.h"
FilteringExamplePublisher::FilteringExamplePublisher() : mp_participant(nullptr), mp_fast_publisher(nullptr), mp_slow_publisher(nullptr) {}
FilteringExamplePublisher::~FilteringExamplePublisher() { Domain::removeParticipant(mp_participant);}
bool FilteringExamplePublisher::init()
{
// Create RTPSParticipant
ParticipantAttributes PParam;
PParam.rtps.builtin.domainId = 0;
PParam.rtps.builtin.leaseDuration = c_TimeInfinite;
PParam.rtps.setName("Participant_publisher"); //You can put here the name you want
mp_participant = Domain::createParticipant(PParam);
if(mp_participant == nullptr)
return false;
//Register the type
Domain::registerType(mp_participant,(TopicDataType*) &myType);
// Create Publishers
// Create "Fast" Publisher
PublisherAttributes Wparam_fast;
Wparam_fast.topic.topicKind = NO_KEY;
Wparam_fast.topic.topicDataType = myType.getName(); //This type MUST be registered
Wparam_fast.topic.topicName = "FilteringExamplePubSubTopic";
Wparam_fast.qos.m_partition.push_back("Fast_Partition");
mp_fast_publisher = Domain::createPublisher(mp_participant, Wparam_fast, (PublisherListener*)&m_listener);
if (mp_fast_publisher == nullptr)
return false;
std::cout << "Fast Publisher created, waiting for Subscribers." << std::endl;
// Create "Slow" Publisher
PublisherAttributes Wparam_slow;
Wparam_slow.topic.topicKind = NO_KEY;
Wparam_slow.topic.topicDataType = myType.getName(); //This type MUST be registered
Wparam_slow.topic.topicName = "FilteringExamplePubSubTopic";
Wparam_slow.qos.m_partition.push_back("Slow_Partition");
mp_slow_publisher = Domain::createPublisher(mp_participant, Wparam_slow, (PublisherListener*)&m_listener);
if (mp_slow_publisher == nullptr)
return false;
std::cout << "Slow Publisher created, waiting for Subscribers." << std::endl;
return true;
}
void FilteringExamplePublisher::PubListener::onPublicationMatched(Publisher* pub,MatchingInfo& info)
{
if (info.status == MATCHED_MATCHING)
{
n_matched++;
std::cout << "Publisher matched" << std::endl;
}
else
{
n_matched--;
std::cout << "Publisher unmatched" << std::endl;
}
}
void FilteringExamplePublisher::run()
{
while(m_listener.n_matched == 0)
{
eClock::my_sleep(250); // Sleep 250 ms
}
// Publication code
FilteringExample st;
int sampleNumber = 0;
while (1) {
sampleNumber++;
st.sampleNumber(sampleNumber);
mp_fast_publisher->write(&st);
if (sampleNumber % 5 == 0) { // slow publisher writes every 5 secs.
mp_slow_publisher->write(&st);
}
eClock::my_sleep(1000);
}
}
| 0 |
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/share/fastrtps/examples/C++ | apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/share/fastrtps/examples/C++/Filtering/FilteringExampleSubscriber.cxx | // Copyright 2016 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.
#include <fastrtps/participant/Participant.h>
#include <fastrtps/attributes/ParticipantAttributes.h>
#include <fastrtps/subscriber/Subscriber.h>
#include <fastrtps/attributes/SubscriberAttributes.h>
#include <fastrtps/Domain.h>
#include "FilteringExampleSubscriber.h"
FilteringExampleSubscriber::FilteringExampleSubscriber() : mp_participant(nullptr), mp_subscriber(nullptr) {}
FilteringExampleSubscriber::~FilteringExampleSubscriber() { Domain::removeParticipant(mp_participant);}
bool FilteringExampleSubscriber::init(int type)
{
// Create RTPSParticipant
ParticipantAttributes PParam;
PParam.rtps.builtin.domainId = 0; //MUST BE THE SAME AS IN THE PUBLISHER
PParam.rtps.builtin.leaseDuration = c_TimeInfinite;
PParam.rtps.setName("Participant_subscriber"); //You can put the name you want
mp_participant = Domain::createParticipant(PParam);
if(mp_participant == nullptr)
return false;
//Register the type
Domain::registerType(mp_participant,(TopicDataType*) &myType);
// Create Subscriber
SubscriberAttributes Rparam;
Rparam.topic.topicKind = NO_KEY;
Rparam.topic.topicDataType = myType.getName(); //Must be registered before the creation of the subscriber
Rparam.topic.topicName = "FilteringExamplePubSubTopic";
if (type == 1)
{
Rparam.qos.m_partition.push_back("Fast_Partition");
}
else //2 = slow
{
Rparam.qos.m_partition.push_back("Slow_Partition");
}
mp_subscriber = Domain::createSubscriber(mp_participant, Rparam, (SubscriberListener*)&m_listener);
if (mp_subscriber == nullptr)
return false;
return true;
}
void FilteringExampleSubscriber::SubListener::onSubscriptionMatched(Subscriber* sub,MatchingInfo& info)
{
if (info.status == MATCHED_MATCHING)
{
n_matched++;
std::cout << "Subscriber matched" << std::endl;
}
else
{
n_matched--;
std::cout << "Subscriber unmatched" << std::endl;
}
}
void FilteringExampleSubscriber::SubListener::onNewDataMessage(Subscriber* sub)
{
// Take data
FilteringExample st;
if(sub->takeNextData(&st, &m_info))
{
if(m_info.sampleKind == ALIVE)
{
// Print your structure data here.
++n_msg;
std::cout << "Sample received, count=" << n_msg << std::endl;
std::cout << " sampleNumber=" << st.sampleNumber() << std::endl;
}
}
}
void FilteringExampleSubscriber::run()
{
std::cout << "Waiting for Data, press Enter to stop the Subscriber. "<<std::endl;
std::cin.ignore();
std::cout << "Shutting down the Subscriber." << std::endl;
}
| 0 |
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/share/fastrtps/examples/C++ | apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/share/fastrtps/examples/C++/FlowControlExample/FlowControlExamplePublisher.cxx | // Copyright 2016 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.
/*************************************************************************
* @file FlowControlExamplePublisher.cpp
* This file contains the implementation of the publisher functions.
*
* This file was generated by the tool fastcdrgen.
*/
#include <fastrtps/participant/Participant.h>
#include <fastrtps/attributes/ParticipantAttributes.h>
#include <fastrtps/publisher/Publisher.h>
#include <fastrtps/attributes/PublisherAttributes.h>
#include <fastrtps/rtps/flowcontrol/ThroughputController.h>
#include <fastrtps/Domain.h>
#include <fastrtps/utils/eClock.h>
#include "FlowControlExamplePublisher.h"
FlowControlExamplePublisher::FlowControlExamplePublisher() : mp_participant(nullptr),
mp_fast_publisher(nullptr),
mp_slow_publisher(nullptr){}
FlowControlExamplePublisher::~FlowControlExamplePublisher() { Domain::removeParticipant(mp_participant);}
bool FlowControlExamplePublisher::init()
{
// Create RTPSParticipant
ParticipantAttributes PParam;
PParam.rtps.builtin.domainId = 0;
PParam.rtps.builtin.leaseDuration = c_TimeInfinite;
PParam.rtps.setName("Participant_publisher"); //You can put here the name you want
mp_participant = Domain::createParticipant(PParam);
if(mp_participant == nullptr)
return false;
//Register the type
Domain::registerType(mp_participant,(TopicDataType*) &myType);
// Create fast publisher, which has no controller of its own.
PublisherAttributes WparamFast;
WparamFast.topic.topicKind = NO_KEY;
WparamFast.topic.topicDataType = myType.getName(); //This type MUST be registered
WparamFast.topic.topicName = "FlowControlExamplePubSubTopic";
WparamFast.qos.m_publishMode.kind = ASYNCHRONOUS_PUBLISH_MODE;
mp_fast_publisher = Domain::createPublisher(mp_participant,WparamFast,(PublisherListener*)&m_listener);
if(mp_fast_publisher == nullptr)
return false;
std::cout << "Fast publisher created, waiting for Subscribers." << std::endl;
// Create slow publisher, with its own controller
PublisherAttributes WparamSlow;
WparamSlow.topic.topicKind = NO_KEY;
WparamSlow.topic.topicDataType = myType.getName(); //This type MUST be registered
WparamSlow.topic.topicName = "FlowControlExamplePubSubTopic";
WparamSlow.qos.m_publishMode.kind = ASYNCHRONOUS_PUBLISH_MODE;
// This controller allows 300kb per second.
ThroughputControllerDescriptor slowPublisherThroughputController{300000, 1000};
WparamSlow.throughputController = slowPublisherThroughputController;
mp_slow_publisher = Domain::createPublisher(mp_participant,WparamSlow,(PublisherListener*)&m_listener);
if(mp_slow_publisher == nullptr)
return false;
std::cout << "Slow publisher created, waiting for Subscribers." << std::endl;
return true;
}
void FlowControlExamplePublisher::PubListener::onPublicationMatched(Publisher* pub,MatchingInfo& info)
{
if (info.status == MATCHED_MATCHING)
{
n_matched++;
std::cout << "Publisher matched" << std::endl;
}
else
{
n_matched--;
std::cout << "Publisher unmatched" << std::endl;
}
}
void FlowControlExamplePublisher::run()
{
while(m_listener.n_matched == 0)
{
eClock::my_sleep(250); // Sleep 250 ms
}
// Publication code
FlowControlExample st;
/* Initialize your structure here */
int msgsent_fast = 0;
int msgsent_slow = 0;
char ch;
std::cout << "Flow Control example." << std::endl;
std::cout << "Press \"f\" to send a sample through the fast writer, which has unlimited bandwidth" << std::endl;
std::cout << "Press \"s\" to send a sample through the slow writer, which is also limited by its own Flow Controller" << std::endl;
std::cout << "Press \"q\" quit" << std::endl;
while(std::cin >> ch)
{
if(ch == 'f')
{
st.wasFast(true);
mp_fast_publisher->write(&st); ++msgsent_fast;
std::cout << "Sending sample, count=" << msgsent_fast << " through the fast writer. Send another sample? (f-fast,s-slow,q-quit): ";
}
else if(ch == 's')
{
st.wasFast(false);
mp_slow_publisher->write(&st); ++msgsent_slow;
std::cout << "Sending sample, count=" << msgsent_slow << " through the slow writer. Send another sample? (f-fast,s-slow,q-quit): ";
}
else if (ch == 'q')
{
std::cout << "Finishing Flow Control example" << std::endl;
break;
}
else
{
std::cout << "Command " << ch << " not recognized, please enter \"f/s/q\":";
}
}
}
| 0 |
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/share/fastrtps/examples/C++ | apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/share/fastrtps/examples/C++/FlowControlExample/CMakeLists.txt | # Copyright 2016 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.
cmake_minimum_required(VERSION 2.8.12)
project("FlowControlExample")
# Find requirements
find_package(fastcdr REQUIRED)
find_package(fastrtps REQUIRED)
# Set C++11
include(CheckCXXCompilerFlag)
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_CLANG OR
CMAKE_CXX_COMPILER_ID MATCHES "Clang")
check_cxx_compiler_flag(--std=c++11 SUPPORTS_CXX11)
if(SUPPORTS_CXX11)
add_compile_options(--std=c++11)
else()
message(FATAL_ERROR "Compiler doesn't support C++11")
endif()
endif()
message(STATUS "Configuring Flow Control example...")
file(GLOB FLOWCONTROL_EXAMPLE_SOURCES_CXX "*.cxx")
file(GLOB FLOWCONTROL_EXAMPLE_SOURCES_CPP "*.cpp")
add_executable(FlowControlExample ${FLOWCONTROL_EXAMPLE_SOURCES_CXX} ${FLOWCONTROL_EXAMPLE_SOURCES_CPP})
target_link_libraries(FlowControlExample fastrtps fastcdr)
install(TARGETS FlowControlExample
RUNTIME DESTINATION examples/C++/FlowControlExample/${BIN_INSTALL_DIR})
| 0 |
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/share/fastrtps/examples/C++ | apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/share/fastrtps/examples/C++/FlowControlExample/FlowControlExamplePublisher.h | // Copyright 2016 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.
/*************************************************************************
* @file FlowControlExamplePublisher.h
* This header file contains the declaration of the publisher functions.
*
* This file was generated by the tool fastcdrgen.
*/
#ifndef _FLOWCONTROLEXAMPLE_PUBLISHER_H_
#define _FLOWCONTROLEXAMPLE_PUBLISHER_H_
#include <fastrtps/fastrtps_fwd.h>
#include <fastrtps/publisher/PublisherListener.h>
#include "FlowControlExamplePubSubTypes.h"
using namespace eprosima::fastrtps;
class FlowControlExamplePublisher
{
public:
FlowControlExamplePublisher();
virtual ~FlowControlExamplePublisher();
bool init();
void run();
private:
Participant *mp_participant;
Publisher *mp_fast_publisher;
Publisher *mp_slow_publisher;
class PubListener : public PublisherListener
{
public:
PubListener() : n_matched(0){};
~PubListener(){};
void onPublicationMatched(Publisher* pub,MatchingInfo& info);
int n_matched;
} m_listener;
FlowControlExamplePubSubType myType;
};
#endif // _FLOWCONTROLEXAMPLE_PUBLISHER_H_
| 0 |
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/share/fastrtps/examples/C++ | apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/share/fastrtps/examples/C++/FlowControlExample/Makefile | # Copyright 2016 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.
CPP=g++
LN=g++
AR=ar
CP=cp
SYSLIBS= -ldl -lnsl -lm -lpthread -lrt
DEFINES=
COMMON_CFLAGS= -c -Wall -D__LITTLE_ENDIAN__ -std=c++11
## CHOOSE HERE BETWEEN 32 and 64 bit architecture
##32 BIT ARCH:
#COMMON_CFLAGS+= -m32 -fpic
#LDFLAGS=-m32
#64BIT ARCH:
COMMON_CFLAGS+= -m64 -fpic
LDFLAGS=-m64
CFLAGS = $(COMMON_CFLAGS) -O2
INCLUDES= -I.
LIBS = -lfastcdr -lfastrtps $(SYSLIBS)
DIRECTORIES= output.dir bin.dir
all: $(DIRECTORIES) FlowControlExample
FLOWCONTROLEXAMPLE_TARGET= bin/FlowControlExample
FLOWCONTROLEXAMPLE_SRC_CXXFILES=
FLOWCONTROLEXAMPLE_SRC_CPPFILES= FlowControlExample/FlowControlExample.cxx \
FlowControlExample/FlowControlExamplePubSubTypes.cxx \
FlowControlExample/FlowControlExamplePublisher.cxx \
FlowControlExample/FlowControlExampleSubscriber.cxx \
FlowControlExample/FlowControlExamplePubSubMain.cxx
# Project sources are copied to the current directory
FLOWCONTROLEXAMPLE_SRCS= $(FLOWCONTROLEXAMPLE_SRC_CXXFILES) $(FLOWCONTROLEXAMPLE_SRC_CPPFILES)
# Source directories
FLOWCONTROLEXAMPLE_SOURCES_DIRS_AUX= $(foreach srcdir, $(dir $(FLOWCONTROLEXAMPLE_SRCS)), $(srcdir))
FLOWCONTROLEXAMPLE_SOURCES_DIRS= $(shell echo $(FLOWCONTROLEXAMPLE_SOURCES_DIRS_AUX) | tr " " "\n" | sort | uniq | tr "\n" " ")
FLOWCONTROLEXAMPLE_OBJS = $(foreach obj,$(notdir $(addsuffix .o, $(FLOWCONTROLEXAMPLE_SRCS))), output/$(obj))
FLOWCONTROLEXAMPLE_DEPS = $(foreach dep,$(notdir $(addsuffix .d, $(FLOWCONTROLEXAMPLE_SRCS))), output/$(dep))
OBJS+= $(FLOWCONTROLEXAMPLE_OBJS)
DEPS+= $(FLOWCONTROLEXAMPLE_DEPS)
FlowControlExample: $(FLOWCONTROLEXAMPLE_TARGET)
$(FLOWCONTROLEXAMPLE_TARGET): $(FLOWCONTROLEXAMPLE_OBJS)
$(LN) $(LDFLAGS) -o $(FLOWCONTROLEXAMPLE_TARGET) $(FLOWCONTROLEXAMPLE_OBJS) $(LIBS)
vpath %.cxx $(FLOWCONTROLEXAMPLE_SOURCES_DIRS)
vpath %.cpp $(FLOWCONTROLEXAMPLE_SOURCES_DIRS)
output/%.cxx.o:%.cxx
@echo Calculating dependencies $<
@$(CC) $(CFLAGS) -MM $(CFLAGS) $(INCLUDES) $< | sed "s/^.*:/output\/&/g" > $(@:%.cxx.o=%.cxx.d)
@echo Compiling $<
@$(CC) $(CFLAGS) $(INCLUDES) $< -o $@
output/%.cpp.o:%.cpp
@echo Calculating dependencies $<
@$(CPP) $(CFLAGS) -MM $(CFLAGS) $(INCLUDES) $< | sed "s/^.*:/output\/&/g" > $(@:%.cpp.o=%.cpp.d)
@echo Compiling $<
@$(CPP) $(CFLAGS) $(INCLUDES) $< -o $@
.PHONY: FlowControlExample
clean:
@rm -f $(OBJS)
@rm -f $(DEPS)
ifneq ($(MAKECMDGOALS), clean)
-include $(DEPS)
endif
%.dir :
@echo "Checking directory $*"
@if [ ! -d $* ]; then \
echo "Making directory $*"; \
mkdir -p $* ; \
fi;
| 0 |
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/share/fastrtps/examples/C++ | apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/share/fastrtps/examples/C++/FlowControlExample/FlowControlExample.h | // Copyright 2016 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.
/*************************************************************************
* @file FlowControlExample.h
* This header file contains the declaration of the described types in the IDL file.
*
* This file was generated by the tool gen.
*/
#ifndef _FlowControlExample_H_
#define _FlowControlExample_H_
// TODO Poner en el contexto.
#include <stdint.h>
#include <array>
#include <string>
#include <vector>
#if defined(_WIN32)
#if defined(EPROSIMA_USER_DLL_EXPORT)
#define eProsima_user_DllExport __declspec( dllexport )
#else
#define eProsima_user_DllExport
#endif
#else
#define eProsima_user_DllExport
#endif
#if defined(_WIN32)
#if defined(EPROSIMA_USER_DLL_EXPORT)
#if defined(FlowControlExample_SOURCE)
#define FlowControlExample_DllAPI __declspec( dllexport )
#else
#define FlowControlExample_DllAPI __declspec( dllimport )
#endif // FlowControlExample_SOURCE
#else
#define FlowControlExample_DllAPI
#endif
#else
#define FlowControlExample_DllAPI
#endif // _WIN32
namespace eprosima
{
namespace fastcdr
{
class Cdr;
}
}
/*!
* @brief This class represents the structure FlowControlExample defined by the user in the IDL file.
* @ingroup FLOWCONTROLEXAMPLE
*/
class FlowControlExample
{
public:
/*!
* @brief Default constructor.
*/
eProsima_user_DllExport FlowControlExample();
/*!
* @brief Default destructor.
*/
eProsima_user_DllExport ~FlowControlExample();
/*!
* @brief Copy constructor.
* @param x Reference to the object FlowControlExample that will be copied.
*/
eProsima_user_DllExport FlowControlExample(const FlowControlExample &x);
/*!
* @brief Move constructor.
* @param x Reference to the object FlowControlExample that will be copied.
*/
eProsima_user_DllExport FlowControlExample(FlowControlExample &&x);
/*!
* @brief Copy assignment.
* @param x Reference to the object FlowControlExample that will be copied.
*/
eProsima_user_DllExport FlowControlExample& operator=(const FlowControlExample &x);
/*!
* @brief Move assignment.
* @param x Reference to the object FlowControlExample that will be copied.
*/
eProsima_user_DllExport FlowControlExample& operator=(FlowControlExample &&x);
/*!
* @brief This function copies the value in member message
* @param _message New value to be copied in member message
*/
inline eProsima_user_DllExport void message(const std::array<char, 600000> &_message)
{
m_message = _message;
}
/*!
* @brief This function moves the value in member message
* @param _message New value to be moved in member message
*/
inline eProsima_user_DllExport void message(std::array<char, 600000> &&_message)
{
m_message = std::move(_message);
}
/*!
* @brief This function returns a constant reference to member message
* @return Constant reference to member message
*/
inline eProsima_user_DllExport const std::array<char, 600000>& message() const
{
return m_message;
}
/*!
* @brief This function returns a reference to member message
* @return Reference to member message
*/
inline eProsima_user_DllExport std::array<char, 600000>& message()
{
return m_message;
}
/*!
* @brief This function sets a value in member wasFast
* @param _wasFast New value for member wasFast
*/
inline eProsima_user_DllExport void wasFast(char _wasFast)
{
m_wasFast = _wasFast;
}
/*!
* @brief This function returns the value of member wasFast
* @return Value of member wasFast
*/
inline eProsima_user_DllExport char wasFast() const
{
return m_wasFast;
}
/*!
* @brief This function returns a reference to member wasFast
* @return Reference to member wasFast
*/
inline eProsima_user_DllExport char& wasFast()
{
return m_wasFast;
}
/*!
* @brief This function returns the maximum serialized size of an object
* depending on the buffer alignment.
* @param current_alignment Buffer alignment.
* @return Maximum serialized size.
*/
eProsima_user_DllExport static size_t getMaxCdrSerializedSize(size_t current_alignment = 0);
/*!
* @brief This function serializes an object using CDR serialization.
* @param cdr CDR serialization object.
*/
eProsima_user_DllExport void serialize(eprosima::fastcdr::Cdr &cdr) const;
/*!
* @brief This function deserializes an object using CDR serialization.
* @param cdr CDR serialization object.
*/
eProsima_user_DllExport void deserialize(eprosima::fastcdr::Cdr &cdr);
/*!
* @brief This function returns the maximum serialized size of the Key of an object
* depending on the buffer alignment.
* @param current_alignment Buffer alignment.
* @return Maximum serialized size.
*/
eProsima_user_DllExport static size_t getKeyMaxCdrSerializedSize(size_t current_alignment = 0);
/*!
* @brief This function tells you if the Key has been defined for this type
*/
eProsima_user_DllExport static bool isKeyDefined();
/*!
* @brief This function serializes the key members of an object using CDR serialization.
* @param cdr CDR serialization object.
*/
eProsima_user_DllExport void serializeKey(eprosima::fastcdr::Cdr &cdr) const;
private:
std::array<char, 600000> m_message;
char m_wasFast;
};
#endif // _FlowControlExample_H_
| 0 |
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/share/fastrtps/examples/C++ | apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/share/fastrtps/examples/C++/FlowControlExample/FlowControlExamplePubSubTypes.h | // Copyright 2016 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.
/*************************************************************************
* @file FlowControlExamplePubSubTypes.h
* This header file contains the declaration of the serialization functions.
*
* This file was generated by the tool fastcdrgen.
*/
#ifndef _FLOWCONTROLEXAMPLE_PUBSUBTYPES_H_
#define _FLOWCONTROLEXAMPLE_PUBSUBTYPES_H_
#include <fastrtps/TopicDataType.h>
using namespace eprosima::fastrtps;
#include "FlowControlExample.h"
/*!
* @brief This class represents the TopicDataType of the type FlowControlExample defined by the user in the IDL file.
* @ingroup FLOWCONTROLEXAMPLE
*/
class FlowControlExamplePubSubType : public TopicDataType {
public:
FlowControlExamplePubSubType();
virtual ~FlowControlExamplePubSubType();
bool serialize(void *data, SerializedPayload_t *payload);
bool deserialize(SerializedPayload_t *payload, void *data);
std::function<uint32_t()> getSerializedSizeProvider(void* data);
bool getKey(void *data, InstanceHandle_t *ihandle);
void* createData();
void deleteData(void * data);
MD5 m_md5;
unsigned char* m_keyBuffer;
};
#endif // _FlowControlExample_PUBSUBTYPE_H_
| 0 |
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/share/fastrtps/examples/C++ | apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/share/fastrtps/examples/C++/FlowControlExample/FlowControlExampleSubscriber.h | // Copyright 2016 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.
/*************************************************************************
* @file FlowControlExampleSubscriber.h
* This header file contains the declaration of the subscriber functions.
*
* This file was generated by the tool fastcdrgen.
*/
#ifndef _FLOWCONTROLEXAMPLE_SUBSCRIBER_H_
#define _FLOWCONTROLEXAMPLE_SUBSCRIBER_H_
#include <fastrtps/fastrtps_fwd.h>
#include <fastrtps/subscriber/SubscriberListener.h>
#include <fastrtps/subscriber/SampleInfo.h>
#include "FlowControlExamplePubSubTypes.h"
using namespace eprosima::fastrtps;
class FlowControlExampleSubscriber
{
public:
FlowControlExampleSubscriber();
virtual ~FlowControlExampleSubscriber();
bool init();
void run();
private:
Participant *mp_participant;
Subscriber *mp_subscriber;
class SubListener : public SubscriberListener
{
public:
SubListener() : n_matched(0),n_msg(0){};
~SubListener(){};
void onSubscriptionMatched(Subscriber* sub,MatchingInfo& info);
void onNewDataMessage(Subscriber* sub);
SampleInfo_t m_info;
int n_matched;
int n_msg;
} m_listener;
FlowControlExamplePubSubType myType;
};
#endif // _FlowControlExample_SUBSCRIBER_H_
| 0 |
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/share/fastrtps/examples/C++ | apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/share/fastrtps/examples/C++/FlowControlExample/FlowControlExample.cxx | // Copyright 2016 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.
/*************************************************************************
* @file FlowControlExample.cpp
* This source file contains the definition of the described types in the IDL file.
*
* This file was generated by the tool gen.
*/
#ifdef _WIN32
// Remove linker warning LNK4221 on Visual Studio
namespace { char dummy; }
#endif
#include "FlowControlExample.h"
#include <fastcdr/Cdr.h>
#include <fastcdr/exceptions/BadParamException.h>
using namespace eprosima::fastcdr::exception;
#include <utility>
FlowControlExample::FlowControlExample()
{
m_wasFast = 0;
}
FlowControlExample::~FlowControlExample()
{
}
FlowControlExample::FlowControlExample(const FlowControlExample &x)
{
m_message = x.m_message;
m_wasFast = x.m_wasFast;
}
FlowControlExample::FlowControlExample(FlowControlExample &&x)
{
m_message = std::move(x.m_message);
m_wasFast = x.m_wasFast;
}
FlowControlExample& FlowControlExample::operator=(const FlowControlExample &x)
{
m_message = x.m_message;
m_wasFast = x.m_wasFast;
return *this;
}
FlowControlExample& FlowControlExample::operator=(FlowControlExample &&x)
{
m_message = std::move(x.m_message);
m_wasFast = x.m_wasFast;
return *this;
}
size_t FlowControlExample::getMaxCdrSerializedSize(size_t current_alignment)
{
size_t initial_alignment = current_alignment;
current_alignment += ((600000) * 1) + eprosima::fastcdr::Cdr::alignment(current_alignment, 1);
current_alignment += 1 + eprosima::fastcdr::Cdr::alignment(current_alignment, 1);
return current_alignment - initial_alignment;
}
void FlowControlExample::serialize(eprosima::fastcdr::Cdr &scdr) const
{
scdr << m_message;
scdr << m_wasFast;
}
void FlowControlExample::deserialize(eprosima::fastcdr::Cdr &dcdr)
{
dcdr >> m_message;
dcdr >> m_wasFast;
}
size_t FlowControlExample::getKeyMaxCdrSerializedSize(size_t current_alignment)
{
size_t current_align = current_alignment;
return current_align;
}
bool FlowControlExample::isKeyDefined()
{
return false;
}
void FlowControlExample::serializeKey(eprosima::fastcdr::Cdr &scdr) const
{
}
| 0 |
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/share/fastrtps/examples/C++ | apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/share/fastrtps/examples/C++/FlowControlExample/FlowControlExampleSubscriber.cxx | // Copyright 2016 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.
/*************************************************************************
* @file FlowControlExampleSubscriber.cpp
* This file contains the implementation of the subscriber functions.
*
* This file was generated by the tool fastcdrgen.
*/
#include <fastrtps/participant/Participant.h>
#include <fastrtps/attributes/ParticipantAttributes.h>
#include <fastrtps/subscriber/Subscriber.h>
#include <fastrtps/attributes/SubscriberAttributes.h>
#include <fastrtps/Domain.h>
#include "FlowControlExampleSubscriber.h"
FlowControlExampleSubscriber::FlowControlExampleSubscriber() : mp_participant(nullptr), mp_subscriber(nullptr) {}
FlowControlExampleSubscriber::~FlowControlExampleSubscriber() { Domain::removeParticipant(mp_participant);}
bool FlowControlExampleSubscriber::init()
{
// Create RTPSParticipant
ParticipantAttributes PParam;
PParam.rtps.builtin.domainId = 0; //MUST BE THE SAME AS IN THE PUBLISHER
PParam.rtps.builtin.leaseDuration = c_TimeInfinite;
PParam.rtps.setName("Participant_subscriber"); //You can put the name you want
mp_participant = Domain::createParticipant(PParam);
if(mp_participant == nullptr)
return false;
//Register the type
Domain::registerType(mp_participant,(TopicDataType*) &myType);
// Create Subscriber
SubscriberAttributes Rparam;
Rparam.topic.topicKind = NO_KEY;
Rparam.topic.topicDataType = myType.getName(); //Must be registered before the creation of the subscriber
Rparam.topic.topicName = "FlowControlExamplePubSubTopic";
mp_subscriber = Domain::createSubscriber(mp_participant,Rparam,(SubscriberListener*)&m_listener);
if(mp_subscriber == nullptr)
return false;
return true;
}
void FlowControlExampleSubscriber::SubListener::onSubscriptionMatched(Subscriber* sub,MatchingInfo& info)
{
if (info.status == MATCHED_MATCHING)
{
n_matched++;
std::cout << "Subscriber matched" << std::endl;
}
else
{
n_matched--;
std::cout << "Subscriber unmatched" << std::endl;
}
}
void FlowControlExampleSubscriber::SubListener::onNewDataMessage(Subscriber* sub)
{
// Take data
FlowControlExample st;
if(sub->takeNextData(&st, &m_info))
{
if(m_info.sampleKind == ALIVE)
{
++n_msg;
static unsigned int fastMessages = 0;
static unsigned int slowMessages = 0;
// Print your structure data here.
if (st.wasFast())
{
fastMessages++;
std::cout << "Sample received from fast writer, count=" << fastMessages << std::endl;
}
else
{
slowMessages++;
std::cout << "Sample received from slow writer, count=" << slowMessages << std::endl;
}
}
}
}
void FlowControlExampleSubscriber::run()
{
std::cout << "Waiting for Data, press Enter to stop the Subscriber. "<<std::endl;
std::cin.ignore();
std::cout << "Shutting down the Subscriber." << std::endl;
}
| 0 |
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/share/fastrtps/examples/C++ | apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/share/fastrtps/examples/C++/FlowControlExample/FlowControlExamplePubSubTypes.cxx | // Copyright 2016 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.
/*************************************************************************
* @file FlowControlExamplePubSubTypes.cpp
* This header file contains the implementation of the serialization functions.
*
* This file was generated by the tool fastcdrgen.
*/
#include <fastcdr/FastBuffer.h>
#include <fastcdr/Cdr.h>
#include "FlowControlExamplePubSubTypes.h"
FlowControlExamplePubSubType::FlowControlExamplePubSubType() {
setName("FlowControlExample");
m_typeSize = (uint32_t)FlowControlExample::getMaxCdrSerializedSize() + 4 /*encapsulation*/;
m_isGetKeyDefined = FlowControlExample::isKeyDefined();
m_keyBuffer = (unsigned char*)malloc(FlowControlExample::getKeyMaxCdrSerializedSize()>16 ? FlowControlExample::getKeyMaxCdrSerializedSize() : 16);
}
FlowControlExamplePubSubType::~FlowControlExamplePubSubType() {
if(m_keyBuffer!=nullptr)
free(m_keyBuffer);
}
bool FlowControlExamplePubSubType::serialize(void *data, SerializedPayload_t *payload) {
FlowControlExample *p_type = (FlowControlExample*) data;
eprosima::fastcdr::FastBuffer fastbuffer((char*) payload->data, payload->max_size); // Object that manages the raw buffer.
eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN,
eprosima::fastcdr::Cdr::DDS_CDR);
payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE;
// Serialize encapsulation
ser.serialize_encapsulation();
p_type->serialize(ser); // Serialize the object:
payload->length = (uint32_t)ser.getSerializedDataLength(); //Get the serialized length
return true;
}
bool FlowControlExamplePubSubType::deserialize(SerializedPayload_t* payload, void* data) {
FlowControlExample* p_type = (FlowControlExample*) data; //Convert DATA to pointer of your type
eprosima::fastcdr::FastBuffer fastbuffer((char*)payload->data, payload->length); // Object that manages the raw buffer.
eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN,
eprosima::fastcdr::Cdr::DDS_CDR); // Object that deserializes the data.
// Deserialize encapsulation.
deser.read_encapsulation();
payload->encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE;
p_type->deserialize(deser); //Deserialize the object:
return true;
}
std::function<uint32_t()> FlowControlExamplePubSubType::getSerializedSizeProvider(void* data)
{
return []() -> uint32_t { return 600000 + 1 + 4 /*encapsulation*/; };
}
void* FlowControlExamplePubSubType::createData() {
return (void*)new FlowControlExample();
}
void FlowControlExamplePubSubType::deleteData(void* data) {
delete((FlowControlExample*)data);
}
bool FlowControlExamplePubSubType::getKey(void *data, InstanceHandle_t* handle) {
if(!m_isGetKeyDefined)
return false;
FlowControlExample* p_type = (FlowControlExample*) data;
eprosima::fastcdr::FastBuffer fastbuffer((char*)m_keyBuffer,FlowControlExample::getKeyMaxCdrSerializedSize()); // Object that manages the raw buffer.
eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS); // Object that serializes the data.
p_type->serializeKey(ser);
if(FlowControlExample::getKeyMaxCdrSerializedSize()>16) {
m_md5.init();
m_md5.update(m_keyBuffer,(unsigned int)ser.getSerializedDataLength());
m_md5.finalize();
for(uint8_t i = 0;i<16;++i) {
handle->value[i] = m_md5.digest[i];
}
}
else {
for(uint8_t i = 0;i<16;++i) {
handle->value[i] = m_keyBuffer[i];
}
}
return true;
}
| 0 |
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/share/fastrtps/examples/C++ | apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/share/fastrtps/examples/C++/FlowControlExample/README.txt | To launch this example open two consoles:
1) "$ FlowControlExample subscriber" (or "FlowControlExample.exe subscriber" in Windows).
2..*) "$ FlowControlExample publisher" (or "FlowControlExample.exe publisher XX" in Windows).
This example illustrates the flow control feature.
================
= Flow Control =
================
In FastRTPS, Flow Control is implemented through objects called Flow Controllers. In
particular, we will be looking at the simplest kind, the Throughput Controller.
A throughput controller is univocally defined by a Throughput Controller Descriptor,
which is a simple struct that includes two values:
-> A size in bytes.
-> A period in milliseconds.
Once instantiated from this descriptor, a throughput controller will make sure there is a
limit on the data it processes, so that no more than the specified size gets
through it in the specified time. In other words, it limits data throughput.
Throughput filters can be placed at different points in the system. In this example, you
can see a controller being placed on a particular Writer. Controllers allocated in this
way display a hierarchical behaviour, so in order for data to be sent, it must clear
both the Participant filter and the Writer filter, if available.
Looking at FlowControlExamplePublisher::init(), you can see the steps involved in
adding a size filter to the publisher parameters.
| 0 |
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/share/fastrtps/examples/C++ | apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/share/fastrtps/examples/C++/FlowControlExample/FlowControlExamplePubSubMain.cxx | // Copyright 2016 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.
/*************************************************************************
* @file FlowControlExamplePubSubMain.cpp
* This file acts as a main entry point to the application.
*
* This file was generated by the tool fastcdrgen.
*/
#include "FlowControlExamplePublisher.h"
#include "FlowControlExampleSubscriber.h"
#include <fastrtps/Domain.h>
#include <fastrtps/log/Log.h>
using namespace eprosima;
using namespace eprosima::fastrtps;
int main(int argc, char** argv)
{
std::cout << "Starting " << std::endl;
int type = 1;
if (argc > 1)
{
if (strcmp(argv[1], "publisher") == 0)
{
type = 1;
}
else if (strcmp(argv[1], "subscriber") == 0)
{
type = 2;
}
}
else
{
std::cout << "publisher OR subscriber argument needed" << std::endl;
return 0;
}
// Register the type being used
switch(type)
{
case 1:
{
FlowControlExamplePublisher mypub;
if (mypub.init())
{
mypub.run();
}
break;
}
case 2:
{
FlowControlExampleSubscriber mysub;
if (mysub.init())
{
mysub.run();
}
break;
}
}
return 0;
}
| 0 |
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/share/fastrtps/examples/C++ | apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/share/fastrtps/examples/C++/FlowControlExample/FlowControlExample.idl | struct FlowControlExample
{
char message[600000];
char wasFast;
};
| 0 |
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/share/fastrtps/examples/C++ | apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/share/fastrtps/examples/C++/LateJoiners/CMakeLists.txt | # Copyright 2016 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.
cmake_minimum_required(VERSION 2.8.12)
project("UseCaseDemonstrator")
# Find requirements
find_package(fastcdr REQUIRED)
find_package(fastrtps REQUIRED)
# Set C++11
include(CheckCXXCompilerFlag)
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_CLANG OR
CMAKE_CXX_COMPILER_ID MATCHES "Clang")
check_cxx_compiler_flag(--std=c++11 SUPPORTS_CXX11)
if(SUPPORTS_CXX11)
add_compile_options(--std=c++11)
else()
message(FATAL_ERROR "Compiler doesn't support C++11")
endif()
endif()
message(STATUS "Configuring UseCaseDemonstrator example...")
file(GLOB USECASEDEMONSTRATOR_EXAMPLE_SOURCES "*.cxx")
add_executable(latejoiners ${USECASEDEMONSTRATOR_EXAMPLE_SOURCES} latejoiners.cpp)
target_link_libraries(latejoiners fastrtps fastcdr)
install(TARGETS latejoiners
RUNTIME DESTINATION examples/C++/UseCaseDemonstrator/${BIN_INSTALL_DIR}
)
| 0 |
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/share/fastrtps/examples/C++ | apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/share/fastrtps/examples/C++/LateJoiners/samplePubSubTypes.h | // Copyright 2016 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.
/*!
* @file samplePubSubTypes.h
* This header file contains the declaration of the serialization functions.
*
* This file was generated by the tool fastcdrgen.
*/
#ifndef _SAMPLE_PUBSUBTYPES_H_
#define _SAMPLE_PUBSUBTYPES_H_
#include <fastrtps/TopicDataType.h>
using namespace eprosima::fastrtps;
#include "sample.h"
/*!
* @brief This class represents the TopicDataType of the type sample defined by the user in the IDL file.
* @ingroup SAMPLE
*/
class samplePubSubType : public TopicDataType {
public:
typedef sample type;
samplePubSubType();
virtual ~samplePubSubType();
bool serialize(void *data, SerializedPayload_t *payload);
bool deserialize(SerializedPayload_t *payload, void *data);
std::function<uint32_t()> getSerializedSizeProvider(void* data);
bool getKey(void *data, InstanceHandle_t *ihandle);
void* createData();
void deleteData(void * data);
MD5 m_md5;
unsigned char* m_keyBuffer;
};
#endif // _sample_PUBSUBTYPE_H_ | 0 |
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/share/fastrtps/examples/C++ | apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/share/fastrtps/examples/C++/LateJoiners/latejoiners.cpp | #include <iostream>
#include <string>
#include <fastrtps/participant/Participant.h>
#include <fastrtps/attributes/ParticipantAttributes.h>
#include <fastrtps/subscriber/Subscriber.h>
#include <fastrtps/attributes/SubscriberAttributes.h>
#include <fastrtps/publisher/Publisher.h>
#include <fastrtps/attributes/PublisherAttributes.h>
#include <fastrtps/Domain.h>
#include <fastrtps/subscriber/SampleInfo.h>
#include <fastrtps/utils/eClock.h>
#include "samplePubSubTypes.h"
//Enums and configuration structure
enum Reliability_type { Best_Effort, Reliable };
enum Durability_type { Transient_Local, Volatile };
enum HistoryKind_type { Keep_Last, Keep_All };
enum Key_type { No_Key, With_Key};
typedef struct{
Reliability_type reliability;
Durability_type durability;
HistoryKind_type historykind;
Key_type keys;
uint16_t history_size;
uint8_t depth;
uint8_t no_keys;
uint16_t max_samples_per_key;
} example_configuration;
void latejoiners();
int main(){
latejoiners();
return 0;
}
void latejoiners(){
samplePubSubType sampleType;
sample my_sample;
SampleInfo_t sample_info;
ParticipantAttributes PparamPub;
PparamPub.rtps.builtin.domainId = 0;
PparamPub.rtps.builtin.leaseDuration = c_TimeInfinite;
PparamPub.rtps.setName("PublisherParticipant");
Participant *PubParticipant = Domain::createParticipant(PparamPub);
if(PubParticipant == nullptr){
std::cout << " Something went wrong while creating the Publisher Participant..." << std::endl;
return;
}
Domain::registerType(PubParticipant,(TopicDataType*) &sampleType);
//Publisher config
PublisherAttributes Pparam;
Pparam.topic.topicDataType = sampleType.getName();
Pparam.topic.topicName = "samplePubSubTopic";
Pparam.historyMemoryPolicy = DYNAMIC_RESERVE_MEMORY_MODE;
Pparam.topic.topicKind = NO_KEY;
Pparam.topic.historyQos.kind = KEEP_ALL_HISTORY_QOS;
Pparam.qos.m_durability.kind = TRANSIENT_LOCAL_DURABILITY_QOS;
Pparam.qos.m_reliability.kind = RELIABLE_RELIABILITY_QOS;
Pparam.topic.historyQos.depth = 50;
Pparam.topic.resourceLimitsQos.max_samples = 100;
Pparam.topic.resourceLimitsQos.max_instances = 1;
Pparam.topic.resourceLimitsQos.max_samples_per_instance = 100;
std::cout << "Creating Publisher..." << std::endl;
Publisher *myPub= Domain::createPublisher(PubParticipant, Pparam, nullptr);
if(myPub == nullptr){
std::cout << "Something went wrong while creating the Publisher..." << std::endl;
return;
}
//Send 20 samples
std::cout << "Publishing 20 samples on the topic" << std::endl;
for(uint8_t j=0; j < 20; j++){
my_sample.index(j+1);
my_sample.key_value(1);
myPub->write(&my_sample);
}
eClock::my_sleep(1500);
ParticipantAttributes PparamSub;
PparamSub.rtps.builtin.domainId = 0;
PparamSub.rtps.builtin.leaseDuration = c_TimeInfinite;
PparamSub.rtps.setName("SubscriberParticipant");
Participant *SubParticipant = Domain::createParticipant(PparamSub);
if(SubParticipant == nullptr){
std::cout << " Something went wrong while creating the Subscriber Participant..." << std::endl;
return;
}
Domain::registerType(SubParticipant,(TopicDataType*) &sampleType);
//Transient Local Sub
SubscriberAttributes Rparam;
Rparam.topic.topicDataType = sampleType.getName();
Rparam.topic.topicName = "samplePubSubTopic";
Rparam.historyMemoryPolicy = DYNAMIC_RESERVE_MEMORY_MODE;
Rparam.topic.topicKind = NO_KEY;
Rparam.topic.historyQos.kind = KEEP_ALL_HISTORY_QOS;
Rparam.qos.m_durability.kind = TRANSIENT_LOCAL_DURABILITY_QOS;
Rparam.qos.m_reliability.kind = RELIABLE_RELIABILITY_QOS;
Rparam.topic.historyQos.depth = 50;
Rparam.topic.resourceLimitsQos.max_samples = 100;
Rparam.topic.resourceLimitsQos.max_instances = 1;
Rparam.topic.resourceLimitsQos.max_samples_per_instance = 100;
std::cout << "Creating Transient Local Subscriber..." << std::endl;
Subscriber *mySub1= Domain::createSubscriber(PubParticipant, Rparam, nullptr);
if(myPub == nullptr){
std::cout << "something went wrong while creating the Transient Local Subscriber..." << std::endl;
return;
}
//Volatile Sub
SubscriberAttributes Rparam2;
Rparam2.topic.topicDataType = sampleType.getName();
Rparam2.topic.topicName = "samplePubSubTopic";
Rparam2.historyMemoryPolicy = DYNAMIC_RESERVE_MEMORY_MODE;
Rparam2.topic.topicKind = NO_KEY;
Rparam2.topic.historyQos.kind = KEEP_ALL_HISTORY_QOS;
Rparam2.qos.m_durability.kind = VOLATILE_DURABILITY_QOS;
Rparam2.qos.m_reliability.kind = RELIABLE_RELIABILITY_QOS;
Rparam2.topic.historyQos.depth = 50;
Rparam2.topic.resourceLimitsQos.max_samples = 100;
Rparam2.topic.resourceLimitsQos.max_instances = 1;
Rparam2.topic.resourceLimitsQos.max_samples_per_instance = 100;
std::cout << "Creating Volatile Subscriber..." << std::endl;
Subscriber *mySub2= Domain::createSubscriber(PubParticipant, Rparam2, nullptr);
if(myPub == nullptr){
std::cout << "something went wrong while creating the Volatile Subscriber..." << std::endl;
return;
}
//Send 20 samples
std::cout << "Publishing 20 samples on the topic..." << std::endl;
for(uint8_t j=0; j < 20; j++){
my_sample.index(j+21);
my_sample.key_value(1);
myPub->write(&my_sample);
}
eClock::my_sleep(1500);
//Read the contents of both histories:
std::cout << "The Transient Local Subscriber holds: " << std::endl;
while(mySub1->readNextData(&my_sample, &sample_info)){
std::cout << std::to_string(my_sample.index()) << " ";
}
std::cout << std::endl;
std::cout << "The Volatile Subscriber holds: " << std::endl;
while(mySub2->readNextData(&my_sample, &sample_info)){
std::cout << std::to_string(my_sample.index()) << " ";
}
std::cout << std::endl;
}
| 0 |
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/share/fastrtps/examples/C++ | apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/share/fastrtps/examples/C++/LateJoiners/Makefile | # Copyright 2016 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.
CPP=g++
LN=g++
AR=ar
CP=cp
SYSLIBS= -ldl -lnsl -lm -lpthread -lrt
DEFINES=
COMMON_CFLAGS= -c -Wall -D__LITTLE_ENDIAN__ -std=c++11
## CHOOSE HERE BETWEEN 32 and 64 bit architecture
##32 BIT ARCH:
#COMMON_CFLAGS+= -m32 -fpic
#LDFLAGS=-m32
#64BIT ARCH:
COMMON_CFLAGS+= -m64 -fpic
LDFLAGS=-m64
CFLAGS = $(COMMON_CFLAGS) -O2
INCLUDES= -I.
LIBS = -lfastcdr -lfastrtps $(SYSLIBS)
DIRECTORIES= output.dir bin.dir
all: $(DIRECTORIES) LateJoiners
LATEJOINERS_TARGET= bin/LateJoiners
LATEJOINERS_SRC_CXXFILES=
LATEJOINERS_SRC_CPPFILES= LateJoiners/latejoiners.cpp \
LateJoiners/samplePubSubTypes.cxx \
LateJoiners/sample.cxx
# Project sources are copied to the current directory
LATEJOINERS_SRCS= $(LATEJOINERS_SRC_CXXFILES) $(LATEJOINERS_SRC_CPPFILES)
# Source directories
LATEJOINERS_SOURCES_DIRS_AUX= $(foreach srcdir, $(dir $(LATEJOINERS_SRCS)), $(srcdir))
LATEJOINERS_SOURCES_DIRS= $(shell echo $(LATEJOINERS_SOURCES_DIRS_AUX) | tr " " "\n" | sort | uniq | tr "\n" " ")
LATEJOINERS_OBJS = $(foreach obj,$(notdir $(addsuffix .o, $(LATEJOINERS_SRCS))), output/$(obj))
LATEJOINERS_DEPS = $(foreach dep,$(notdir $(addsuffix .d, $(LATEJOINERS_SRCS))), output/$(dep))
OBJS+= $(LATEJOINERS_OBJS)
DEPS+= $(LATEJOINERS_DEPS)
LateJoiners: $(LATEJOINERS_TARGET)
$(LATEJOINERS_TARGET): $(LATEJOINERS_OBJS)
$(LN) $(LDFLAGS) -o $(LATEJOINERS_TARGET) $(LATEJOINERS_OBJS) $(LIBS)
vpath %.cxx $(LATEJOINERS_SOURCES_DIRS)
vpath %.cpp $(LATEJOINERS_SOURCES_DIRS)
output/%.cxx.o:%.cxx
@echo Calculating dependencies $<
@$(CC) $(CFLAGS) -MM $(CFLAGS) $(INCLUDES) $< | sed "s/^.*:/output\/&/g" > $(@:%.cxx.o=%.cxx.d)
@echo Compiling $<
@$(CC) $(CFLAGS) $(INCLUDES) $< -o $@
output/%.cpp.o:%.cpp
@echo Calculating dependencies $<
@$(CPP) $(CFLAGS) -MM $(CFLAGS) $(INCLUDES) $< | sed "s/^.*:/output\/&/g" > $(@:%.cpp.o=%.cpp.d)
@echo Compiling $<
@$(CPP) $(CFLAGS) $(INCLUDES) $< -o $@
.PHONY: LateJoiners
clean:
@rm -f $(OBJS)
@rm -f $(DEPS)
ifneq ($(MAKECMDGOALS), clean)
-include $(DEPS)
endif
%.dir :
@echo "Checking directory $*"
@if [ ! -d $* ]; then \
echo "Making directory $*"; \
mkdir -p $* ; \
fi;
| 0 |
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/share/fastrtps/examples/C++ | apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/share/fastrtps/examples/C++/LateJoiners/sample.cxx | // Copyright 2016 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.
/*!
* @file sample.cpp
* This source file contains the definition of the described types in the IDL file.
*
* This file was generated by the tool gen.
*/
#ifdef _WIN32
// Remove linker warning LNK4221 on Visual Studio
namespace { char dummy; }
#endif
#include "sample.h"
#include <fastcdr/Cdr.h>
#include <fastcdr/exceptions/BadParamException.h>
using namespace eprosima::fastcdr::exception;
#include <utility>
sample::sample()
{
m_index = 0;
m_key_value = 0;
}
sample::~sample()
{
}
sample::sample(const sample &x)
{
m_index = x.m_index;
m_key_value = x.m_key_value;
}
sample::sample(sample &&x)
{
m_index = x.m_index;
m_key_value = x.m_key_value;
}
sample& sample::operator=(const sample &x)
{
m_index = x.m_index;
m_key_value = x.m_key_value;
return *this;
}
sample& sample::operator=(sample &&x)
{
m_index = x.m_index;
m_key_value = x.m_key_value;
return *this;
}
size_t sample::getMaxCdrSerializedSize(size_t current_alignment)
{
size_t initial_alignment = current_alignment;
current_alignment += 1 + eprosima::fastcdr::Cdr::alignment(current_alignment, 1);
current_alignment += 1 + eprosima::fastcdr::Cdr::alignment(current_alignment, 1);
return current_alignment - initial_alignment;
}
size_t sample::getCdrSerializedSize(const sample& data, size_t current_alignment)
{
size_t initial_alignment = current_alignment;
current_alignment += 1 + eprosima::fastcdr::Cdr::alignment(current_alignment, 1);
current_alignment += 1 + eprosima::fastcdr::Cdr::alignment(current_alignment, 1);
return current_alignment - initial_alignment;
}
void sample::serialize(eprosima::fastcdr::Cdr &scdr) const
{
scdr << m_index;
scdr << m_key_value;
}
void sample::deserialize(eprosima::fastcdr::Cdr &dcdr)
{
dcdr >> m_index;
dcdr >> m_key_value;
}
size_t sample::getKeyMaxCdrSerializedSize(size_t current_alignment)
{
size_t current_align = current_alignment;
current_align += 1 + eprosima::fastcdr::Cdr::alignment(current_align, 1);
return current_align;
}
bool sample::isKeyDefined()
{
return true;
}
void sample::serializeKey(eprosima::fastcdr::Cdr &scdr) const
{
scdr << m_key_value;
} | 0 |
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/share/fastrtps/examples/C++ | apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/share/fastrtps/examples/C++/LateJoiners/README.txt | ---------------------------------------------------------
- Use Case Example: Late Joiners for eProsima Fast RTPS -
---------------------------------------------------------
1 - Application description
---------------------------
eProsima Fast RTPS provides users with a wide range of configuration options. This example has the objective of providing a testing ground where you can experiment and see the influence different combinations of parameters can have on the behaviours on the Publisher/Subscriber scheme.
This example is a supplement to the UseCaseLauncher example, consisting on an application which ilustrates the effect the different kinds of Subscriber Durability have on sample storage.
2 - Configuration options
--------------------------
These are the main parameters that affect the behaviour of eProsima Fast RTPS and that are used in the Use Case set of example:
- Reliability Kind
Defines how eProsima Fast RTPS deals upon possible packet loss during data exchanges.
+ Best Effort: No arrival confirmation. It is fast but lost samples are not re-sent.
+ Reliable: With arrival confirmation. It is slower but provides guarantee that all lost samples are re-sent and eventually received by the subscriber.
Since this application runs the Publisher and Subscriber on the same machine, data loss is highly unlikely. Therefore this option will not play a relevant role on the application behaviour.
- Durability Kind
Defines what to do with samples that exist prior to the existence of the Subscriber.
+ Volatile: Past samples are ignored, the Subscriber starts to receive data generated after it has joined the network.
+ Transient Local: Past samples are sent.
- History Kind
Defines the storage policy for past samples.
+ Keep Last: The History will save and give access to the alst "k" received samples. This "k" number is called the History Depth and can be manually set too by the user.
+ Keep All: The History will save and give access to all received samples until the maximum samples size of the History is reached.
This parameter affects cases of "late-joining" Subscribers: Subscribers that come online after data transfers on a topic have started.
- Keys
Keys allow to have multiple data endpoints within a topic as opposed to all data published in a topic going into the same "inbox".
+ On a topic without keys, all pieces of data go into a single endpoint.
+ On a topic without keys, the key field is used to determine which of the multiple endpoints the data goes into. If, for example, a history is set to transient local with depth=3 (the last three samples are stores) then eProsima FastRTPS will ensure that 3 samples per data endpoint are stored. This means that three samples are stored for each unique key instead of three samples total.
It is important to note that even if you configure a Topic and your History to be able to hold items from multiple keys, this configuration does not take effect unless you explicitly enable Keys.
- Depth
The depth is the amount of past samples that are stored in the history before starting to overwrite. Only takes effect when the History is on "Keep Last" mode.
- History Size
This accounts for the total number of samples that can be stored in the history, regardless of any other configuration option.
- Instances
Instances are the different data sinks the History is divided and act as receptors of the Keys.
- Instance size
As it happens with depth, you can define a maximun number of past samples to be stored. If you set one Instance and an instance size more restrictive than the depth, the instance size will be the limiting factor.
3. Application behaviour
------------------------
The application creates a Publisher and posts 20 samples on the topic BEFORE creating the subscriber. Then it creates a Transient-Local and a Volatile subscriber and it posts 20 more samples. After analyzing the contexts the subscribers you will see:
* The Volatile Subsciber only holds the las 20 samples sent after its creation.
* The Transient-Local Subscriber holds all samples, including the 20 that were sent before its creation.
4. Built-in tests
-----------------
The use case launcher contains the following built-in examples:
* HistoryKind: Shows how a Keep-All Subscriber stores all samples in its History and a Keep-Last subscriber starts to overwrite when it reacher its depth.
* Keys: Provides a working example of how data can be split into multiple endpoints based of keys.
* SampleConfig: Provides a basic Publish-Subscribe example for the three sample configurations specified in section 5.
| 0 |
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/share/fastrtps/examples/C++ | apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/share/fastrtps/examples/C++/LateJoiners/sample.idl | struct sample{
octet index;
@Key octet key_value;
};
| 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.