Skip to content

Commit

Permalink
New TypeDescriptor (#4074)
Browse files Browse the repository at this point in the history
* Refs 17138. New TypeDescriptor

Signed-off-by: Ricardo González Moreno <[email protected]>

* Refs 17138. Update doxygen.

Signed-off-by: Ricardo González Moreno <[email protected]>

* Refs 17138. Remove forward class not used

Signed-off-by: Ricardo González Moreno <[email protected]>

* Refs 17138. Apply suggestions

Signed-off-by: Ricardo González Moreno <[email protected]>

---------

Signed-off-by: Ricardo González Moreno <[email protected]>
  • Loading branch information
richiware authored and JLBuenoLopez committed Jan 9, 2024
1 parent 6ee3519 commit dcbd61e
Show file tree
Hide file tree
Showing 7 changed files with 584 additions and 9 deletions.
272 changes: 272 additions & 0 deletions include/fastdds/dds/xtypes/dynamic_types/TypeDescriptor.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,272 @@
// Copyright 2023 Proyectos y Sistemas de Mantenimiento SL (eProsima).
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#ifndef FASTDDS_DDS_XTYPES_DYNAMIC_TYPES_TYPE_DESCRIPTOR_HPP
#define FASTDDS_DDS_XTYPES_DYNAMIC_TYPES_TYPE_DESCRIPTOR_HPP

#include <fastdds/dds/core/ReturnCode.hpp>
#include <fastdds/dds/xtypes/dynamic_types/Types.hpp>
#include <fastrtps/fastrtps_dll.h>

namespace eprosima {
namespace fastdds {
namespace dds {

class DynamicType;

/*!
* TypeDescriptor definition according to [standard] section \b 7.5.2.4.
*/
class RTPS_DllAPI TypeDescriptor
{
public:

/*!
* Returns the @ref TypeKind associated.
* @return standard @ref TypeKind.
*/
virtual TypeKind kind() const = 0;

/*!
* Returns the @ref TypeKind associated.
* @return standard @ref TypeKind.
*/
virtual TypeKind& kind() = 0;

/*!
* Modifies the underlying @ref TypeKind.
* @param[in] @ref TypeKind to be set.
*/
virtual void kind(
TypeKind kind) = 0;

/*!
* Returns the fully qualified name of this type.
* @return Fully qualified name.
*/
virtual ObjectName& name() = 0;

/*!
* Returns the fully qualified name of this type.
* @return Fully qualified name.
*/
virtual const ObjectName& name() const = 0;

/*!
* Modifies the underlying type name by copy.
* @param[in] name Fully qualified name.
*/
virtual void name(
const ObjectName& name) = 0;

/*!
* Modifies the underlying type name by move.
* @param[in] name Fully qualified name.
*/
virtual void name(
ObjectName&& name) = 0;

/*!
* Returns a reference to the base type. The reference can be nil.
* @return @ref DynamicType reference.
*/
virtual traits<DynamicType>::ref_type base_type() const = 0;

/*!
* Returns a reference to the base type. The reference can be nil.
* @return @ref DynamicType reference.
*/
virtual traits<DynamicType>::ref_type& base_type() = 0;

/*!
* Modifies the underlying base type reference.
* @param[in] @ref DynamicType reference.
*/
virtual void base_type(
traits<DynamicType>::ref_type type) = 0;

/*!
* Returns a reference discriminator type. The reference can be nil.
* @return @ref DynamicType reference.
*/
virtual traits<DynamicType>::ref_type discriminator_type() const = 0;

/*!
* Returns a reference discriminator type. The reference can be nil.
* @return @ref DynamicType reference.
*/
virtual traits<DynamicType>::ref_type& discriminator_type() = 0;

/*!
* Modifies the underlying discriminator type reference.
* @param[in] @ref DynamicType reference.
*/
virtual void discriminator_type(
traits<DynamicType>::ref_type type) = 0;

/*!
* Returns the bound.
* @return @ref BoundSeq.
*/
virtual const BoundSeq& bound() const = 0;

/*!
* Returns the bound.
* @return @ref BoundSeq.
*/
virtual BoundSeq& bound() = 0;

/*!
* Modifies the underlying bound by copy.
* @param[in] @ref BoundSeq
*/
virtual void bound(
const BoundSeq& bound) = 0;

/*!
* Modifies the underlying bound by move.
* @param[in] @ref BoundSeq
*/
virtual void bound(
BoundSeq&& bound) = 0;

/*!
* Returns a reference element type. The reference can be nil.
* @return @ref DynamicType reference.
*/
virtual traits<DynamicType>::ref_type element_type() const = 0;

/*!
* Returns a reference element type. The reference can be nil.
* @return @ref DynamicType reference.
*/
virtual traits<DynamicType>::ref_type& element_type() = 0;

/*!
* Modifies the underlying element type reference.
* @param[in] @ref DynamicType reference.
*/
virtual void element_type(
traits<DynamicType>::ref_type type) = 0;

/*!
* Returns a reference key element type. The reference can be nil.
* @return @ref DynamicType reference.
*/
virtual traits<DynamicType>::ref_type key_element_type() const = 0;

/*!
* Returns a reference key element type. The reference can be nil.
* @return @ref DynamicType reference.
*/
virtual traits<DynamicType>::ref_type& key_element_type() = 0;

/*!
* Modifies the underlying key element type reference.
* @param[in] @ref DynamicType reference.
*/
virtual void key_element_type(
traits<DynamicType>::ref_type type) = 0;


/*!
* Returns the extensibility kind.
* return @ref ExtensibilityKind
*/
virtual ExtensibilityKind extensibility_kind() const = 0;

/*!
* Returns the extensibility kind.
* return @ref ExtensibilityKind
*/
virtual ExtensibilityKind& extensibility_kind() = 0;

/*!
* Modifies the extensibility kind.
* @param[in] @ref ExtensibilityKind
*/
virtual void extensibility_kind(
ExtensibilityKind extensibility_kind) = 0;

/*!
* Returns the is_nested property.
* return Boolean
*/
virtual bool is_nested() const = 0;

/*!
* Returns the is_nested property.
* return Boolean
*/
virtual bool& is_nested() = 0;

/*!
* Mofifies the is_nested property.
* @param[in] Boolean
*/
virtual void is_nested(
bool is_nested) = 0;

/*!
* Overwrites the contents of this descriptor with those of another descriptor (see [standard] 7.5.2.4.3).
* @param[in] descriptor reference.
* @return @ref ReturnCode_t
* @retval RETCODE_OK when the copy was successful.
* @retval RETCODE_BAD_PARAMETER when descriptor reference is nil.
*/
virtual ReturnCode_t copy_from(
traits<TypeDescriptor>::ref_type descriptor) = 0;

/*!
* Compares according with the [standard] section \b 7.5.2.4.6.
* @param[in] descriptor reference to compare to.
* @return \b bool `true` on equality
*/
virtual bool equals(
traits<TypeDescriptor>::ref_type descriptor) = 0;

/*!
* Indicates whether the states of all of this descriptor's properties are consistent according with the [standard]
* section \b 7.5.2.4.7.
* @return \b bool `true` if consistent.
*/
virtual bool is_consistent() = 0;

protected:

TypeDescriptor() = default;

TypeDescriptor(
const TypeDescriptor& type) = default;

TypeDescriptor(
TypeDescriptor&& type) = default;

virtual ~TypeDescriptor() = default;

private:

TypeDescriptor& operator =(
const TypeDescriptor& type) = delete;

TypeDescriptor& operator =(
TypeDescriptor&& type) = delete;

};

} // namespace dds
} // namespace fastdds
} // namespace eprosima

#endif // FASTDDS_DDS_XTYPES_DYNAMIC_TYPES_TYPE_DESCRIPTOR_HPP
1 change: 1 addition & 0 deletions include/fastdds/dds/xtypes/dynamic_types/Types.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#define _FASTDDS_DDS_XTYPES_DYNAMIC_TYPES_TYPES_HPP_

#include "detail/dynamic_language_binding.hpp"
#include "type_traits.hpp"

#endif // _FASTDDS_DDS_XTYPES_DYNAMIC_TYPES_TYPES_HPP_

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
* This file was generated by the tool fastddsgen.
*/

#ifndef _FAST_DDS_GENERATED_EPROSIMA_FASTDDS_DDS_DYNAMIC_LANGUAGE_BINDING_HPP_
#define _FAST_DDS_GENERATED_EPROSIMA_FASTDDS_DDS_DYNAMIC_LANGUAGE_BINDING_HPP_
#ifndef _FAST_DDS_GENERATED_DYNAMIC_LANGUAGE_BINDING_HPP_
#define _FAST_DDS_GENERATED_DYNAMIC_LANGUAGE_BINDING_HPP_

#include <cstdint>
#include <map>
Expand Down Expand Up @@ -61,12 +61,12 @@ namespace fastdds {
namespace dds {


class DynamicTypeMember;

typedef std::vector<std::string> IncludePathSeq;

typedef eprosima::fastcdr::fixed_string<256> ObjectName;

typedef std::vector<uint32_t> BoundSeq;

typedef uint8_t TypeKind;

const TypeKind TK_NONE = 0x00;
Expand Down Expand Up @@ -105,7 +105,7 @@ typedef std::map<ObjectName, ObjectName> Parameters;
* @brief This class represents the enumeration ExtensibilityKind defined by the user in the IDL file.
* @ingroup dynamic_language_binding
*/
enum ExtensibilityKind : uint32_t
enum class ExtensibilityKind : uint32_t
{
FINAL,
APPENDABLE,
Expand All @@ -115,7 +115,7 @@ enum ExtensibilityKind : uint32_t
* @brief This class represents the enumeration TryConstructKind defined by the user in the IDL file.
* @ingroup dynamic_language_binding
*/
enum TryConstructKind : uint32_t
enum class TryConstructKind : uint32_t
{
USE_DEFAULT,
DISCARD,
Expand Down Expand Up @@ -167,6 +167,6 @@ typedef std::vector<std::wstring> WstringSeq;
} // namespace eprosima


#endif // _FAST_DDS_GENERATED_EPROSIMA_FASTDDS_DDS_DYNAMIC_LANGUAGE_BINDING_HPP_
#endif // _FAST_DDS_GENERATED_DYNAMIC_LANGUAGE_BINDING_HPP_


Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@

module DDS
{
struct DynamicTypeMember; // Forward declaration included to making not fail fastddsgen.

typedef sequence<string> IncludePathSeq;
typedef string<256> ObjectName;

// Inserted until defined in standard.
typedef sequence<unsigned long> BoundSeq;

// ---------- TypeKinds (begin) -------------------
typedef octet TypeKind;

Expand Down
36 changes: 36 additions & 0 deletions include/fastdds/dds/xtypes/dynamic_types/detail/type_traits.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// Copyright 2023 Proyectos y Sistemas de Mantenimiento SL (eProsima).
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#ifndef _FASTDDS_DDS_XTYPES_DYNAMIC_TYPES_DETAIL_TYPE_TRAITS_HPP_
#define _FASTDDS_DDS_XTYPES_DYNAMIC_TYPES_DETAIL_TYPE_TRAITS_HPP_

#include <memory>

namespace eprosima {
namespace fastdds {
namespace dds {

template<typename T>
struct traits
{
typedef ::std::shared_ptr<T> ref_type;
typedef ::std::weak_ptr<T> weak_ref_type;
};

} // namespace dds
} // namespace fastdds
} // namespace eprosima

#endif // _FASTDDS_DDS_XTYPES_DYNAMIC_TYPES_DETAIL_TYPE_TRAITS_HPP_

Loading

0 comments on commit dcbd61e

Please sign in to comment.