IGLib 1.4
The IGLib base library for development of numerical, technical and business applications.
|
Generic base class for Data Transfer Objects (DTO). This class is used as template for producing concrete DTO classes. Such DTOs are used for serialization and deserialization of state of various kinds of objects that need to be transfered between applications, across platforms, or simply stored in files for future use. WARNING: In most cases ISerializationDto<Type> will be used. Different BaseType and Type are used only in relatively rare cases where different derived types all have the same data that is copied to DTO. Otherwise the advantage of this can not be used because of single inheritance. More...
Public Member Functions | |
SerializationDtoBase () | |
virtual bool | GetNull () |
Returns a flag indicating whether the object represented by the current DTO is null. | |
virtual void | SetNull (bool isNull) |
Sets a flag indicating whether the object represented by the current DTO is null. | |
abstract Type | CreateObject () |
Creates and returns a new object of the type whose data is represented by the current DTO (Data Transfer Object). WARNING: Implement thread locking in overriding functions! | |
virtual void | CopyFromBase (BaseType obj) |
Copies data to the current DTO from an object of type BaseType. | |
virtual void | CopyToBase (ref BaseType obj) |
Copies data from the current DTO to an object of the base type. Object is created anew if necessary by using the CreateObject() method. | |
virtual void | CopyFrom (Type obj) |
Copies data to the current DTO from an object of type Type. | |
virtual void | CopyTo (ref Type obj) |
Copies data from the current DTO to an object of type Type. Object is created anew if necessary by using the CreateObject() method. | |
virtual void | CopyFromObject (object obj) |
Copies data to the current DTO from an object of type object. The necessary casts are performed. | |
virtual void | CopyToObject (ref object obj) |
Copies data from the current DTO to an object of type object. Object is created anew if necessary by using the CreateObject() method. The necessary casts are performed. | |
override string | ToString () |
Creates and returns string representation of the current DTO (data transfer object). | |
Protected Member Functions | |
abstract void | CopyFromPlain (BaseType obj) |
Copies contents of the specified object to the current DTO (Data Transfer Object). | |
abstract void | CopyToPlain (ref BaseType obj) |
Copies contents of the current DTO (Data Transfer Object) to the specified object. | |
Protected Attributes | |
bool | _isNull = false |
Properties | |
object | Lock [get] |
This object's central lock object to be used by other object. Do not use this object for locking in class' methods, for this you should use InternalLock. | |
Private Attributes | |
object | _mainLock = new object() |
Generic base class for Data Transfer Objects (DTO). This class is used as template for producing concrete DTO classes. Such DTOs are used for serialization and deserialization of state of various kinds of objects that need to be transfered between applications, across platforms, or simply stored in files for future use. WARNING: In most cases ISerializationDto<Type> will be used. Different BaseType and Type are used only in relatively rare cases where different derived types all have the same data that is copied to DTO. Otherwise the advantage of this can not be used because of single inheritance.
Type | Type for which DTO is used. |
BaseType | Base type of the type for which DTO is used, and on which copy operations will be defined. In this way, we can avoid defining these operations for each specific type, but only define them for a specific type, since operations may be similar for all derived types. |
There is an agreement that all derived classes must have a public argument-less (default) constructor. Generic classes are usually not used for serialization/deserialization. Only derived types where both type parameters are fixed are normally used for this purpos. IMPORTANT: Base type is used just for being able to define copying operations only once - for the base type - and using it for different derived types. In many occasions this will not be needed, and in these occasions one should just use the derived type that does not have base type as type parameter.
$A Igor Jun09;
BaseType | : | class | |
Type | : | class | |
Type | : | BaseType |
IG::Lib::SerializationDtoBase< Type, BaseType >::SerializationDtoBase | ( | ) | [inline] |
virtual bool IG::Lib::SerializationDtoBase< Type, BaseType >::GetNull | ( | ) | [inline, virtual] |
Returns a flag indicating whether the object represented by the current DTO is null.
Implementing this as a function rather than a property prevents serialization of the flag, since the flag isn't meant to contain data, but to instruct operations that the object represented by the current DTO is null. This is useful in some scenarios where non-null DTOs are needed for null objects.
Implements IG::Lib::ISerializationDtoAux< Type >.
virtual void IG::Lib::SerializationDtoBase< Type, BaseType >::SetNull | ( | bool | isNull | ) | [inline, virtual] |
Sets a flag indicating whether the object represented by the current DTO is null.
isNull | If true, this flag indicates that the object represented by the current DTO is null, although the DTO itself is not null. |
Implementing this as a function rather than a property prevents serialization of the flag, since the flag isn't meant to contain data, but to instruct operations that the object represented by the current DTO is null. This is useful in some scenarios where non-null DTOs are needed for null objects.
Implements IG::Lib::ISerializationDtoAux< Type >.
abstract Type IG::Lib::SerializationDtoBase< Type, BaseType >::CreateObject | ( | ) | [pure virtual] |
Creates and returns a new object of the type whose data is represented by the current DTO (Data Transfer Object). WARNING: Implement thread locking in overriding functions!
Therad locking should be performed in overriding functions!
Implements IG::Lib::ISerializationDtoAux< Type >.
Implemented in IG::Lib::ArrayDto< ElementType, ElementDtoType >, IG::Lib::BoundingBoxDtoBase< BoxType >, IG::Lib::MatrixDtoBase< MatrixType >, IG::Num::AnalysisRequestDto, IG::Lib::VectorDtoBase< VectorType >, IG::Num::VectorFunctionRequestDTO, IG::Num::InputOutputElementDefinitionDto< ElementType >, IG::Num::OutputElementDefinitionDto, IG::Num::InputElementDefinitionDto, IG::Neural::MapNeuralImputOutputElementDefinitionDto< ElementType >, IG::Neural::MapImputElementDefinitionDto, and IG::Neural::MapOutputElementDefinitionDto.
abstract void IG::Lib::SerializationDtoBase< Type, BaseType >::CopyFromPlain | ( | BaseType | obj | ) | [protected, pure virtual] |
Copies contents of the specified object to the current DTO (Data Transfer Object).
obj | Object whose data is copied. |
If the specified object is null then the _isNull property of the current DTO is set to true. Therad locking is usually not needed in overriding functions because it is normally implemeted in calling functions.
abstract void IG::Lib::SerializationDtoBase< Type, BaseType >::CopyToPlain | ( | ref BaseType | obj | ) | [protected, pure virtual] |
Copies contents of the current DTO (Data Transfer Object) to the specified object.
obj | Object that data is copied to. |
If _isNull property of the current DTO is set to true then the object becomes null. Therad locking is usually not needed in overriding functions because it is normally implemeted in calling functions.
virtual void IG::Lib::SerializationDtoBase< Type, BaseType >::CopyFromBase | ( | BaseType | obj | ) | [inline, virtual] |
Copies data to the current DTO from an object of type BaseType.
obj | Object whose data is copied to the current DTO. |
Implements IG::Lib::ISerializationDto< Type >.
virtual void IG::Lib::SerializationDtoBase< Type, BaseType >::CopyToBase | ( | ref BaseType | obj | ) | [inline, virtual] |
Copies data from the current DTO to an object of the base type. Object is created anew if necessary by using the CreateObject() method.
obj | Object to which data is copied. |
Implements IG::Lib::ISerializationDto< Type >.
virtual void IG::Lib::SerializationDtoBase< Type, BaseType >::CopyFrom | ( | Type | obj | ) | [inline, virtual] |
Copies data to the current DTO from an object of type Type.
obj | Object whose data is copied to the current DTO. |
Implements IG::Lib::ISerializationDtoAux< Type >.
virtual void IG::Lib::SerializationDtoBase< Type, BaseType >::CopyTo | ( | ref Type | obj | ) | [inline, virtual] |
Copies data from the current DTO to an object of type Type. Object is created anew if necessary by using the CreateObject() method.
obj | Object to which data is copied. |
Implements IG::Lib::ISerializationDtoAux< Type >.
virtual void IG::Lib::SerializationDtoBase< Type, BaseType >::CopyFromObject | ( | object | obj | ) | [inline, virtual] |
Copies data to the current DTO from an object of type object. The necessary casts are performed.
obj | Object whose data is copied to the current DTO. |
Implements IG::Lib::ISerializationDto< Type >.
virtual void IG::Lib::SerializationDtoBase< Type, BaseType >::CopyToObject | ( | ref object | obj | ) | [inline, virtual] |
Copies data from the current DTO to an object of type object. Object is created anew if necessary by using the CreateObject() method. The necessary casts are performed.
obj | Object to which data is copied. |
Implements IG::Lib::ISerializationDto< Type >.
override string IG::Lib::SerializationDtoBase< Type, BaseType >::ToString | ( | ) | [inline] |
Creates and returns string representation of the current DTO (data transfer object).
This is a generic method that first copies DTO to an object that it represents, and then calls the ToString() method of that object. This solution is slow, but this method usually does not need to be faster because ToString() method is usually only used for tests of this kind of classes.
bool IG::Lib::SerializationDtoBase< Type, BaseType >::_isNull = false [protected] |
object IG::Lib::SerializationDtoBase< Type, BaseType >::_mainLock = new object() [private] |
object IG::Lib::SerializationDtoBase< Type, BaseType >::Lock [get] |
This object's central lock object to be used by other object. Do not use this object for locking in class' methods, for this you should use InternalLock.
Implements IG::Lib::ILockable.