Changeset 49:cdd4cf3eda0c in rrlib_rtti_conversion


Ignore:
Timestamp:
08.02.2022 07:22:43 (22 months ago)
Author:
Max Reichardt <mreichardt@…>
Branch:
17.03
Phase:
public
Tags:
tip
Message:

Allows to specify destination object pointer type passed to Convert function. Custom types may allow conversion operations to provide additional information (timestamps are an example).

Files:
3 edited

Legend:

Unmodified
Added
Removed
  • tCompiledConversionOperation.h

    r40 r49  
    9595  }; 
    9696 
    97   tCompiledConversionOperation() : tConversionOperationSequence(), conversion_function_first(nullptr), conversion_function_final(nullptr), fixed_offset_first(0), fixed_offset_final(0), flags(0) 
     97  tCompiledConversionOperation() : tConversionOperationSequence(), conversion_function_first(nullptr), conversion_function_final(nullptr), fixed_offset_first(0), fixed_offset_final(0), flags(0), destination_pointer_type(&typeid(tTypedPointer)) 
    9898  { 
    9999    memset(custom_operation_data_storage, 0, sizeof(custom_operation_data_storage)); 
     
    139139  { 
    140140    assert(flags & tFlag::cRESULT_REFERENCES_SOURCE_DIRECTLY); 
     141    assert(typeid(tTypedPointer) == *destination_pointer_type && "This convert function required default destination_pointer_type"); 
    141142    tTypedConstPointer result(static_cast<const char*>(source_object.GetRawDataPointer()) + fixed_offset_first, type_after_first_fixed_offset); 
    142143    if (get_destination_reference_function_first != nullptr) 
     
    155156 
    156157  /*! 
     158   * return Type of destination_object used when calling Convert 
     159   */ 
     160  const std::type_info& DestinationPointerType() const 
     161  { 
     162    return *destination_pointer_type; 
     163  } 
     164 
     165  /*! 
    157166   * \return Flags for conversion operation 
    158167   */ 
     
    217226  char* custom_operation_data_storage[2 * tCustomOperationData::cMAX_SIZE]; 
    218227 
     228  /*! Type of destination_object used calling Convert; may be subclass of tTypedPointer; set when compiling */ 
     229  const std::type_info* destination_pointer_type; 
     230 
    219231  tCustomOperationData CustomOperationData(size_t index) 
    220232  { 
  • tConversionOperationSequence.cpp

    r46 r49  
    144144} 
    145145 
    146 tCompiledConversionOperation tConversionOperationSequence::Compile(bool allow_reference_to_source, const tType& source_type, const tType& destination_type) const 
     146tCompiledConversionOperation tConversionOperationSequence::Compile(bool allow_reference_to_source, const tType& source_type, const tType& destination_type, const std::type_info& destination_pointer_type) const 
    147147{ 
    148148  // ############ 
     
    406406  result.destination_type = last_conversion->destination_type; 
    407407  static_cast<tConversionOperationSequence&>(result).intermediate_type = this->intermediate_type; 
     408  result.destination_pointer_type = &(first_operation == &cFOR_EACH_OPERATION ? typeid(tTypedPointer) : destination_pointer_type);  // Special For-Each operation works with standard typed pointers only 
    408409 
    409410  // Handle special case: only const offsets 
  • tConversionOperationSequence.h

    r3 r49  
    139139   * \param source_type Source Type (can be omitted if first operation has fixed source type) 
    140140   * \param destination_type Destination Type (can be omitted if last operation has fixed destination type) 
     141   * \param destination_pointer_type Type of destination_object pointer caller provides to Convert function. Custom types allow conversion operations to provide additional information (timestamps are an example). 
    141142   * \throw Throws exception if conversion operation sequence erroneous, ambiguous, or cannot be used to convert specified types 
    142143   */ 
    143   tCompiledConversionOperation Compile(bool allow_reference_to_source, const tType& source_type = tType(), const tType& destination_type = tType()) const; 
     144  tCompiledConversionOperation Compile(bool allow_reference_to_source, const tType& source_type = tType(), const tType& destination_type = tType(), const std::type_info& destination_pointer_type = typeid(tTypedPointer)) const; 
    144145 
    145146  /*! 
Note: See TracChangeset for help on using the changeset viewer.