Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Move TypeDescriptor::stateTable from header to implementation #2277

Merged
merged 2 commits into from
Oct 19, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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