Program Listing for File TypeIdentifier.h

Return to documentation for file (/tmp/ws/src/fastrtps/include/fastrtps/types/TypeIdentifier.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 _TYPEIDENTIFIER_H_
#define _TYPEIDENTIFIER_H_

#include <fastrtps/types/TypesBase.h>
#include <fastrtps/types/TypeIdentifierTypes.h>
#include <stdint.h>
#include <array>
#include <string>
#include <vector>

namespace eprosima {

namespace fastcdr {
class Cdr;
}

namespace fastdds {
namespace dds {
class TypeConsistencyEnforcementQosPolicy;
}
}

namespace fastrtps {
namespace types {

typedef octet TypeIdentiferKind;
const octet TI_STRING8_SMALL = 0x70;
const octet TI_STRING8_LARGE = 0x71;
const octet TI_STRING16_SMALL = 0x72;
const octet TI_STRING16_LARGE = 0x73;
const octet TI_PLAIN_SEQUENCE_SMALL = 0x80;
const octet TI_PLAIN_SEQUENCE_LARGE = 0x81;
const octet TI_PLAIN_ARRAY_SMALL = 0x90;
const octet TI_PLAIN_ARRAY_LARGE = 0x91;
const octet TI_PLAIN_MAP_SMALL = 0xA0;
const octet TI_PLAIN_MAP_LARGE = 0xA1;
const octet TI_STRONGLY_CONNECTED_COMPONENT = 0xB0;

// The TypeIdentifier uniquely identifies a type (a set of equivalent
// types according to an equivalence relationship:  COMPLETE, MNIMAL).
//
// In some cases (primitive types, strings, plain types) the identifier
// is a explicit description of the type.
// In other cases the Identifier is a Hash of the type description
//
// In the case of primitive types and strings the implied equivalence
// relation is the identity.
//
// For Plain Types and Hash-defined TypeIdentifiers there are three
//  possibilities: MINIMAL, COMPLETE, and COMMON:
//   - MINIMAL indicates the TypeIdentifier identifies equivalent types
//     according to the MINIMAL equivalence relation
//   - COMPLETE indicates the TypeIdentifier identifies equivalent types
//     according to the COMPLETE equivalence relation
//   - COMMON indicates the TypeIdentifier identifies equivalent types
//     according to both the MINIMAL and the COMMON equivalence relation.
//     This means the TypeIdentifier is the same for both relationships
//
class TypeIdentifier
{
public:

    RTPS_DllAPI TypeIdentifier();

    RTPS_DllAPI ~TypeIdentifier();

    RTPS_DllAPI TypeIdentifier(
            const TypeIdentifier& x);

    RTPS_DllAPI TypeIdentifier(
            TypeIdentifier&& x);

    RTPS_DllAPI TypeIdentifier& operator=(
            const TypeIdentifier& x);

    RTPS_DllAPI TypeIdentifier& operator=(
            TypeIdentifier&& x);

    RTPS_DllAPI void _d(
            octet __d);

    RTPS_DllAPI octet _d() const;

    RTPS_DllAPI octet& _d();

    RTPS_DllAPI void string_sdefn(
            StringSTypeDefn _string_sdefn);

    RTPS_DllAPI const StringSTypeDefn& string_sdefn() const;

    RTPS_DllAPI StringSTypeDefn& string_sdefn();
    RTPS_DllAPI void string_ldefn(
            StringLTypeDefn _string_ldefn);

    RTPS_DllAPI const StringLTypeDefn& string_ldefn() const;

    RTPS_DllAPI StringLTypeDefn& string_ldefn();
    RTPS_DllAPI void seq_sdefn(
            PlainSequenceSElemDefn _seq_sdefn);

    RTPS_DllAPI const PlainSequenceSElemDefn& seq_sdefn() const;

    RTPS_DllAPI PlainSequenceSElemDefn& seq_sdefn();
    RTPS_DllAPI void seq_ldefn(
            PlainSequenceLElemDefn _seq_ldefn);

    RTPS_DllAPI const PlainSequenceLElemDefn& seq_ldefn() const;

    RTPS_DllAPI PlainSequenceLElemDefn& seq_ldefn();
    RTPS_DllAPI void array_sdefn(
            PlainArraySElemDefn _array_sdefn);

    RTPS_DllAPI const PlainArraySElemDefn& array_sdefn() const;

    RTPS_DllAPI PlainArraySElemDefn& array_sdefn();
    RTPS_DllAPI void array_ldefn(
            PlainArrayLElemDefn _array_ldefn);

    RTPS_DllAPI const PlainArrayLElemDefn& array_ldefn() const;

    RTPS_DllAPI PlainArrayLElemDefn& array_ldefn();
    RTPS_DllAPI void map_sdefn(
            PlainMapSTypeDefn _map_sdefn);

    RTPS_DllAPI const PlainMapSTypeDefn& map_sdefn() const;

    RTPS_DllAPI PlainMapSTypeDefn& map_sdefn();
    RTPS_DllAPI void map_ldefn(
            PlainMapLTypeDefn _map_ldefn);

    RTPS_DllAPI const PlainMapLTypeDefn& map_ldefn() const;

    RTPS_DllAPI PlainMapLTypeDefn& map_ldefn();
    RTPS_DllAPI void sc_component_id(
            StronglyConnectedComponentId _sc_component_id);

    RTPS_DllAPI StronglyConnectedComponentId sc_component_id() const;

    RTPS_DllAPI StronglyConnectedComponentId& sc_component_id();
    RTPS_DllAPI void equivalence_hash(
            EquivalenceHash _equivalence_hash);

    RTPS_DllAPI const octet* equivalence_hash() const;

    RTPS_DllAPI octet* equivalence_hash();
    RTPS_DllAPI void extended_defn(
            ExtendedTypeDefn _extended_defn);

    RTPS_DllAPI const ExtendedTypeDefn& extended_defn() const;

    RTPS_DllAPI ExtendedTypeDefn& extended_defn();

    RTPS_DllAPI static size_t getCdrSerializedSize(
            const TypeIdentifier& data,
            size_t current_alignment = 0);


    RTPS_DllAPI void serialize(
            eprosima::fastcdr::Cdr& cdr) const;

    RTPS_DllAPI void deserialize(
            eprosima::fastcdr::Cdr& cdr);

    bool operator==(
            const TypeIdentifier& other) const;

    RTPS_DllAPI bool consistent(
            const TypeIdentifier& x,
            const fastdds::dds::TypeConsistencyEnforcementQosPolicy& consistency) const;

    RTPS_DllAPI std::string equivalence_hash_to_string() const;

private:

    octet m__d;

    StringSTypeDefn m_string_sdefn;
    StringLTypeDefn m_string_ldefn;
    PlainSequenceSElemDefn m_seq_sdefn;
    PlainSequenceLElemDefn m_seq_ldefn;
    PlainArraySElemDefn m_array_sdefn;
    PlainArrayLElemDefn m_array_ldefn;
    PlainMapSTypeDefn m_map_sdefn;
    PlainMapLTypeDefn m_map_ldefn;
    StronglyConnectedComponentId m_sc_component_id;
    EquivalenceHash m_equivalence_hash;
    ExtendedTypeDefn m_extended_defn;
};

typedef std::vector<TypeIdentifier> TypeIdentifierSeq;

} // namespace types
} // namespace fastrtps
} // namespace eprosima

#endif // _TYPEIDENTIFIER_H_