Safir SDK Core
Loading...
Searching...
No Matches
Safir::Dob::Typesystem::ToolSupport::BlobWriter< RepositoryT, Traits > Class Template Reference

This class is used to create blobs by writing member values and the finally calling the CopyRawBlob-method. More...

#include <Safir/Dob/Typesystem/ToolSupport/BlobWriter.h>

Public Types

typedef BlobWriter< RepositoryT, Traits > BlobWriterType
 
typedef BlobReader< RepositoryT, Traits > BlobReaderType
 
typedef Traits::RepositoryType RepositoryType
 
typedef Traits::ClassDescriptionType ClassDescriptionType
 
typedef Traits::MemberDescriptionType MemberDescriptionType
 
typedef Traits::PropertyDescriptionType PropertyDescriptionType
 
typedef Traits::ExceptionDescriptionType ExceptionDescriptionType
 
typedef Traits::ParameterDescriptionType ParameterDescriptionType
 
typedef Traits::EnumDescriptionType EnumDescriptionType
 
typedef Traits::MemberMappingDescriptionType MemberMappingDescriptionType
 
typedef Traits::PropertyMappingDescriptionType PropertyMappingDescriptionType
 
typedef Traits::CreateRoutineDescriptionType CreateRoutineDescriptionType
 

Public Member Functions

 BlobWriter (const RepositoryT *rep, DotsC_TypeId typeId)
 Constructor - Creates a new writeable blob of specified type.
 
 BlobWriter (const BlobReaderType &reader)
 
 BlobWriter (const BlobWriter &)=delete
 
BlobWriteroperator= (const BlobWriter &)=delete
 
DotsC_TypeId TypeId () const
 Get the type id of this BlobWriter.
 
DotsC_Int32 CalculateBlobSize () const
 Calculate the size of the blob in bytes.
 
void CopyRawBlob (char *destBlob) const
 Copy the binarey blob into a destination buffer.
 
void SetChangedTopLevel (DotsC_MemberIndex member, bool isChanged)
 Set the top level isChanged flag.
 
void SetChangedHere (DotsC_MemberIndex member, DotsC_Int32 valueIndex, bool isChanged)
 Set the change flag for a member value.
 
template<class Key >
void WriteKey (DotsC_MemberIndex member, const Key &key)
 Write member key to the a blob.
 
template<class Val >
void WriteValue (DotsC_MemberIndex member, DotsC_Int32 index, const Val &val, bool isNull, bool isChanged)
 Write member value to the a blob.
 
void SetChangedRecursive (bool isChanged)
 SetChangedRecursive - Recursively set all change flags to specified value.
 
bool MarkChanges (const BlobReaderType &reader)
 MarkChanges - Set change flag for all members that differs between this blob and the reader blob.
 

Detailed Description

template<class RepositoryT, class Traits = Safir::Dob::Typesystem::ToolSupport::TypeRepositoryTraits<RepositoryT>>
class Safir::Dob::Typesystem::ToolSupport::BlobWriter< RepositoryT, Traits >

This class is used to create blobs by writing member values and the finally calling the CopyRawBlob-method.

The methods for writing values to blobs are templated on the value type. The memberTypes maps to c++ types like described bellow. All strings must be NULL-terminated. Optional strings shall be set to NULL if not present.

Supported types:

Int32 => DostC_Int32 Int64 => DostC_Int64 Float32 => DostC_Float32 Float64 => DostC_Float64 TypeId => DotsC_TypeId Enumeration => DotsC_EnumerationValue String => const char* InstanceId => pair<DotsC_Int64, const char* optional_string> HandlerId => pair<DotsC_Int64, const char* optional_string> ChannelId => pair<DotsC_Int64, const char* optional_string> EntityId => pair<DotsC_EntityId, const char* optional_instance_string> Binary => pair<const char* data, DostC_Int32 size> Object => pair<const char* blob, DostC_Int32 size> or another BlobWriter

Member Typedef Documentation

◆ BlobReaderType

template<class RepositoryT , class Traits = Safir::Dob::Typesystem::ToolSupport::TypeRepositoryTraits<RepositoryT>>
typedef BlobReader<RepositoryT, Traits> Safir::Dob::Typesystem::ToolSupport::BlobWriter< RepositoryT, Traits >::BlobReaderType

◆ BlobWriterType

template<class RepositoryT , class Traits = Safir::Dob::Typesystem::ToolSupport::TypeRepositoryTraits<RepositoryT>>
typedef BlobWriter<RepositoryT, Traits> Safir::Dob::Typesystem::ToolSupport::BlobWriter< RepositoryT, Traits >::BlobWriterType

◆ ClassDescriptionType

template<class RepositoryT , class Traits = Safir::Dob::Typesystem::ToolSupport::TypeRepositoryTraits<RepositoryT>>
typedef Traits::ClassDescriptionType Safir::Dob::Typesystem::ToolSupport::BlobWriter< RepositoryT, Traits >::ClassDescriptionType

◆ CreateRoutineDescriptionType

template<class RepositoryT , class Traits = Safir::Dob::Typesystem::ToolSupport::TypeRepositoryTraits<RepositoryT>>
typedef Traits::CreateRoutineDescriptionType Safir::Dob::Typesystem::ToolSupport::BlobWriter< RepositoryT, Traits >::CreateRoutineDescriptionType

◆ EnumDescriptionType

template<class RepositoryT , class Traits = Safir::Dob::Typesystem::ToolSupport::TypeRepositoryTraits<RepositoryT>>
typedef Traits::EnumDescriptionType Safir::Dob::Typesystem::ToolSupport::BlobWriter< RepositoryT, Traits >::EnumDescriptionType

◆ ExceptionDescriptionType

template<class RepositoryT , class Traits = Safir::Dob::Typesystem::ToolSupport::TypeRepositoryTraits<RepositoryT>>
typedef Traits::ExceptionDescriptionType Safir::Dob::Typesystem::ToolSupport::BlobWriter< RepositoryT, Traits >::ExceptionDescriptionType

◆ MemberDescriptionType

template<class RepositoryT , class Traits = Safir::Dob::Typesystem::ToolSupport::TypeRepositoryTraits<RepositoryT>>
typedef Traits::MemberDescriptionType Safir::Dob::Typesystem::ToolSupport::BlobWriter< RepositoryT, Traits >::MemberDescriptionType

◆ MemberMappingDescriptionType

template<class RepositoryT , class Traits = Safir::Dob::Typesystem::ToolSupport::TypeRepositoryTraits<RepositoryT>>
typedef Traits::MemberMappingDescriptionType Safir::Dob::Typesystem::ToolSupport::BlobWriter< RepositoryT, Traits >::MemberMappingDescriptionType

◆ ParameterDescriptionType

template<class RepositoryT , class Traits = Safir::Dob::Typesystem::ToolSupport::TypeRepositoryTraits<RepositoryT>>
typedef Traits::ParameterDescriptionType Safir::Dob::Typesystem::ToolSupport::BlobWriter< RepositoryT, Traits >::ParameterDescriptionType

◆ PropertyDescriptionType

template<class RepositoryT , class Traits = Safir::Dob::Typesystem::ToolSupport::TypeRepositoryTraits<RepositoryT>>
typedef Traits::PropertyDescriptionType Safir::Dob::Typesystem::ToolSupport::BlobWriter< RepositoryT, Traits >::PropertyDescriptionType

◆ PropertyMappingDescriptionType

template<class RepositoryT , class Traits = Safir::Dob::Typesystem::ToolSupport::TypeRepositoryTraits<RepositoryT>>
typedef Traits::PropertyMappingDescriptionType Safir::Dob::Typesystem::ToolSupport::BlobWriter< RepositoryT, Traits >::PropertyMappingDescriptionType

◆ RepositoryType

template<class RepositoryT , class Traits = Safir::Dob::Typesystem::ToolSupport::TypeRepositoryTraits<RepositoryT>>
typedef Traits::RepositoryType Safir::Dob::Typesystem::ToolSupport::BlobWriter< RepositoryT, Traits >::RepositoryType

Constructor & Destructor Documentation

◆ BlobWriter() [1/3]

template<class RepositoryT , class Traits = Safir::Dob::Typesystem::ToolSupport::TypeRepositoryTraits<RepositoryT>>
Safir::Dob::Typesystem::ToolSupport::BlobWriter< RepositoryT, Traits >::BlobWriter ( const RepositoryT * rep,
DotsC_TypeId typeId )

Constructor - Creates a new writeable blob of specified type.

Initial state isNull=true and isChanged=false.

Parameters
rep[in] - A type repository to use when creating a valid blob.
typeId[in] - Type of this blob. Type descripton must exist in the type repository.

◆ BlobWriter() [2/3]

template<class RepositoryT , class Traits = Safir::Dob::Typesystem::ToolSupport::TypeRepositoryTraits<RepositoryT>>
Safir::Dob::Typesystem::ToolSupport::BlobWriter< RepositoryT, Traits >::BlobWriter ( const BlobReaderType & reader)

◆ BlobWriter() [3/3]

template<class RepositoryT , class Traits = Safir::Dob::Typesystem::ToolSupport::TypeRepositoryTraits<RepositoryT>>
Safir::Dob::Typesystem::ToolSupport::BlobWriter< RepositoryT, Traits >::BlobWriter ( const BlobWriter< RepositoryT, Traits > & )
delete

Member Function Documentation

◆ CalculateBlobSize()

template<class RepositoryT , class Traits = Safir::Dob::Typesystem::ToolSupport::TypeRepositoryTraits<RepositoryT>>
DotsC_Int32 Safir::Dob::Typesystem::ToolSupport::BlobWriter< RepositoryT, Traits >::CalculateBlobSize ( ) const

Calculate the size of the blob in bytes.

Returns
Size in bytes.

◆ CopyRawBlob()

template<class RepositoryT , class Traits = Safir::Dob::Typesystem::ToolSupport::TypeRepositoryTraits<RepositoryT>>
void Safir::Dob::Typesystem::ToolSupport::BlobWriter< RepositoryT, Traits >::CopyRawBlob ( char * destBlob) const

Copy the binarey blob into a destination buffer.

The destBlob must already have been allocated and the size of destBlob must be at least the number of bytes retured by a preceeding call to CalculateBlobSize().

Parameters
destBlob[in] - Pointer to an allocated buffer of sufficient size.

◆ MarkChanges()

template<class RepositoryT , class Traits = Safir::Dob::Typesystem::ToolSupport::TypeRepositoryTraits<RepositoryT>>
bool Safir::Dob::Typesystem::ToolSupport::BlobWriter< RepositoryT, Traits >::MarkChanges ( const BlobReaderType & reader)

MarkChanges - Set change flag for all members that differs between this blob and the reader blob.

Parameters
reader[in] - Blob reader to compare against.
Returns
True if there was any differences between this and reader.

References Safir::Dob::Typesystem::ToolSupport::BlobReader< RepositoryT, Traits >::TypeId(), and Safir::Dob::Typesystem::ToolSupport::BlobWriter< RepositoryT, Traits >::TypeId().

Here is the call graph for this function:

◆ operator=()

template<class RepositoryT , class Traits = Safir::Dob::Typesystem::ToolSupport::TypeRepositoryTraits<RepositoryT>>
BlobWriter & Safir::Dob::Typesystem::ToolSupport::BlobWriter< RepositoryT, Traits >::operator= ( const BlobWriter< RepositoryT, Traits > & )
delete

◆ SetChangedHere()

template<class RepositoryT , class Traits = Safir::Dob::Typesystem::ToolSupport::TypeRepositoryTraits<RepositoryT>>
void Safir::Dob::Typesystem::ToolSupport::BlobWriter< RepositoryT, Traits >::SetChangedHere ( DotsC_MemberIndex member,
DotsC_Int32 valueIndex,
bool isChanged )

Set the change flag for a member value.

Parameters
member[in] - Member index of the member.
valueIndex[in] - Index of the value. If array this is the arrayIndex, if dictionary you have to find out the value index in some way. Sequences only have top-level change flag.
isChanged[in] - The change flag value to set.

◆ SetChangedRecursive()

template<class RepositoryT , class Traits = Safir::Dob::Typesystem::ToolSupport::TypeRepositoryTraits<RepositoryT>>
void Safir::Dob::Typesystem::ToolSupport::BlobWriter< RepositoryT, Traits >::SetChangedRecursive ( bool isChanged)

SetChangedRecursive - Recursively set all change flags to specified value.

Parameters
isChanged[in] - Value to set all change flags to.

References Safir::Dob::Typesystem::ToolSupport::BlobWriter< RepositoryT, Traits >::SetChangedRecursive(), and Safir::Dob::Typesystem::ToolSupport::BlobWriter< RepositoryT, Traits >::WriteValue().

Referenced by Safir::Dob::Typesystem::ToolSupport::BlobWriter< RepositoryT, Traits >::SetChangedRecursive().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SetChangedTopLevel()

template<class RepositoryT , class Traits = Safir::Dob::Typesystem::ToolSupport::TypeRepositoryTraits<RepositoryT>>
void Safir::Dob::Typesystem::ToolSupport::BlobWriter< RepositoryT, Traits >::SetChangedTopLevel ( DotsC_MemberIndex member,
bool isChanged )

Set the top level isChanged flag.

Useful for empty collectons that still may have isChanged=true.

Parameters
member[in] - Member index of the member.
isChanged[in] - Indicates if the member value is changed at top level.

◆ TypeId()

template<class RepositoryT , class Traits = Safir::Dob::Typesystem::ToolSupport::TypeRepositoryTraits<RepositoryT>>
DotsC_TypeId Safir::Dob::Typesystem::ToolSupport::BlobWriter< RepositoryT, Traits >::TypeId ( ) const

Get the type id of this BlobWriter.

Returns
TypeId of the blob writer.

Referenced by Safir::Dob::Typesystem::ToolSupport::BlobWriter< RepositoryT, Traits >::MarkChanges().

Here is the caller graph for this function:

◆ WriteKey()

template<class RepositoryT , class Traits = Safir::Dob::Typesystem::ToolSupport::TypeRepositoryTraits<RepositoryT>>
template<class Key >
void Safir::Dob::Typesystem::ToolSupport::BlobWriter< RepositoryT, Traits >::WriteKey ( DotsC_MemberIndex member,
const Key & key )

Write member key to the a blob.

Only use this when member is a dictionary otherwize the blob will be corrupt. A new key with value null will be added to the collection for each call to this method. Make sure to call WriteValue after a call to this method to set the correct value for the key. Valid types for Key is: Int32, Int64, TypeId, Enumeration, String, InstanceId, HandlerId, ChannelId, EntityId. This method will throw logic_error if used with wrong input data.

Parameters
member[in] - Member index of the member to be written.
key[in] - Key value if the member is a dictionary.

References Safir::Dob::Typesystem::ToolSupport::BlobWriter< RepositoryT, Traits >::WriteKey().

Referenced by Safir::Dob::Typesystem::ToolSupport::BlobWriter< RepositoryT, Traits >::WriteKey().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ WriteValue()

template<class RepositoryT , class Traits = Safir::Dob::Typesystem::ToolSupport::TypeRepositoryTraits<RepositoryT>>
template<class Val >
void Safir::Dob::Typesystem::ToolSupport::BlobWriter< RepositoryT, Traits >::WriteValue ( DotsC_MemberIndex member,
DotsC_Int32 index,
const Val & val,
bool isNull,
bool isChanged )

Write member value to the a blob.

For dictionaries make sure to call WriteKey immediately before calling WriteValue since the WriteValue. If the member is an array, the index is used. For all other collection types index is ignored. If the member is a sequence, a new value is added to the collection for each call to this method. If the member is a dictionary, the key must have been written before the call to this method. This method will throw logic_error if used with wrong input data.

Parameters
member[in] - Member index of the member to be written.
index[in] - Array index of the value to be written. Ignored if CollectionType is not Array.
val[in] - Member value. Use a dummy if isNull=true. See supported types in class comments above.
isNull[in] - True if the member value null. In that case val is not in use.
isChanged[in] - Indicates if the member value is changed.

References Safir::Dob::Typesystem::ToolSupport::BlobWriter< RepositoryT, Traits >::WriteValue().

Referenced by Safir::Dob::Typesystem::ToolSupport::BlobWriter< RepositoryT, Traits >::SetChangedRecursive(), and Safir::Dob::Typesystem::ToolSupport::BlobWriter< RepositoryT, Traits >::WriteValue().

Here is the call graph for this function:
Here is the caller graph for this function: