Skip to content

Commit

Permalink
Move TypeDescriptor::stateTable from header to implementation (#2278)
Browse files Browse the repository at this point in the history
* Move TypeDescriptor::stateTable from header to implementation. (#2015)

Signed-off-by: Miguel Company <MiguelCompany@eprosima.com>
(cherry picked from commit 1f2636a)

* Uncrustify

Signed-off-by: Miguel Company <MiguelCompany@eprosima.com>

Co-authored-by: Miguel Company <miguelcompany@eprosima.com>
  • Loading branch information
mergify[bot] and MiguelCompany authored Oct 19, 2021
1 parent 9cb18a8 commit 1fd2b7c
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 38 deletions.
68 changes: 30 additions & 38 deletions include/fastrtps/types/TypeDescriptor.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,26 +25,10 @@ namespace eprosima {
namespace fastrtps {
namespace types {

enum FSM_INPUTS
{
LETTER = 1,
NUMBER,
UNDERSCORE,
COLON,
OTHER
};

enum FSM_STATES
{
INVALID = 0,
SINGLECOLON,
DOUBLECOLON,
VALID
};

class TypeDescriptor
{
protected:

TypeKind kind_; // Type Kind.
std::string name_; // Type Name.
DynamicType_ptr base_type_; // SuperType of an structure or base type of an alias type.
Expand All @@ -54,16 +38,10 @@ class TypeDescriptor
DynamicType_ptr key_element_type_; // Key Type for maps.
std::vector<AnnotationDescriptor*> annotation_; // Annotations to apply

const int stateTable[4][6] = {
/* Input: letter, number, underscore, colon, other */
{INVALID, VALID, INVALID, INVALID, INVALID, INVALID},
{SINGLECOLON, INVALID, INVALID, INVALID, DOUBLECOLON, INVALID},
{DOUBLECOLON, VALID, INVALID, INVALID, INVALID, INVALID},
{VALID, VALID, VALID, VALID, SINGLECOLON, INVALID}};

void clean();

bool is_type_name_consistent(const std::string& sName) const;
bool is_type_name_consistent(
const std::string& sName) const;

friend class DynamicTypeBuilderFactory;
friend class TypeObjectFactory;
Expand All @@ -72,25 +50,30 @@ class TypeDescriptor
friend class DynamicDataHelper;

public:

TypeDescriptor();

TypeDescriptor(const TypeDescriptor* other);
TypeDescriptor(
const TypeDescriptor* other);

TypeDescriptor(
const std::string& name,
TypeKind kind);

~TypeDescriptor();

ReturnCode_t copy_from(const TypeDescriptor* descriptor);
ReturnCode_t copy_from(
const TypeDescriptor* descriptor);

bool equals(const TypeDescriptor* descriptor) const;
bool equals(
const TypeDescriptor* descriptor) const;

bool is_consistent() const;

DynamicType_ptr get_base_type() const;

uint32_t get_bounds(uint32_t index = 0) const;
uint32_t get_bounds(
uint32_t index = 0) const;

uint32_t get_bounds_size() const;

Expand All @@ -106,18 +89,22 @@ class TypeDescriptor

uint32_t get_total_bounds() const;

void set_kind(TypeKind kind);
void set_kind(
TypeKind kind);

void set_name(std::string name);
void set_name(
std::string name);

ReturnCode_t apply_annotation(AnnotationDescriptor& descriptor);
ReturnCode_t apply_annotation(
AnnotationDescriptor& descriptor);

ReturnCode_t apply_annotation(
const std::string& annotation_name,
const std::string& key,
const std::string& value);

AnnotationDescriptor* get_annotation(const std::string& name) const;
AnnotationDescriptor* get_annotation(
const std::string& name) const;

// Annotations application
bool annotation_is_extensibility() const;
Expand Down Expand Up @@ -146,21 +133,26 @@ class TypeDescriptor
bool annotation_get_key() const;

// Annotation setters
void annotation_set_extensibility(const std::string& extensibility);
void annotation_set_extensibility(
const std::string& extensibility);

void annotation_set_mutable();

void annotation_set_final();

void annotation_set_appendable();

void annotation_set_nested(bool nested);
void annotation_set_nested(
bool nested);

void annotation_set_bit_bound(uint16_t bit_bound);
void annotation_set_bit_bound(
uint16_t bit_bound);

void annotation_set_key(bool key);
void annotation_set_key(
bool key);

void annotation_set_non_serialized(bool non_serialized);
void annotation_set_non_serialized(
bool non_serialized);
};

} // namespace types
Expand Down
26 changes: 26 additions & 0 deletions src/cpp/dynamic-types/TypeDescriptor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,32 @@ namespace eprosima {
namespace fastrtps {
namespace types {

enum FSM_INPUTS
{
LETTER = 1,
NUMBER,
UNDERSCORE,
COLON,
OTHER
};

enum FSM_STATES
{
INVALID = 0,
SINGLECOLON,
DOUBLECOLON,
VALID
};

static const int stateTable[4][6] =
{
/* Input: letter, number, underscore, colon, other */
{INVALID, VALID, INVALID, INVALID, INVALID, INVALID},
{SINGLECOLON, INVALID, INVALID, INVALID, DOUBLECOLON, INVALID},
{DOUBLECOLON, VALID, INVALID, INVALID, INVALID, INVALID},
{VALID, VALID, VALID, VALID, SINGLECOLON, INVALID}
};

TypeDescriptor::TypeDescriptor()
: kind_(0)
, name_("")
Expand Down

0 comments on commit 1fd2b7c

Please sign in to comment.