Changeset 162:a99abff3c256 in rrlib_serialization


Ignore:
Timestamp:
06.06.2017 21:18:23 (20 months ago)
Author:
Max Reichardt <mreichardt@…>
Branch:
17.03
Phase:
public
Message:

Adds tRegisterUpdate - a data type that can be inserted into streams to ensure that auto-published registers are up to date

Files:
1 added
4 edited

Legend:

Unmodified
Added
Removed
  • tInputStream.cpp

    r158 r162  
    272272  { 
    273273    int8_t register_uid = ReadByte(); 
    274     while (true) 
     274    while (register_uid != -1) 
    275275    { 
    276276      if (register_uid >= static_cast<int>(register_array.size()) || register_uid < 0) 
     
    284284      static_cast<PublishedRegisters::tRemoteRegisterBase*>(register_array[register_uid].get())->DeserializeEntries(*this); 
    285285      register_uid = ReadByte(); 
    286       if (register_uid == -1) 
    287       { 
    288         break; 
    289       } 
    290286    } 
    291287  } 
  • tInputStream.h

    r158 r162  
    8181class IsSerializableMap; 
    8282class PublishedRegisters; 
     83class tRegisterUpdate; 
    8384 
    8485//---------------------------------------------------------------------- 
     
    514515  friend class tOutputStream; 
    515516  friend class PublishedRegisters; 
     517  friend tInputStream& operator >> (tInputStream& stream, tRegisterUpdate& update); 
    516518 
    517519  /*! Buffer that is managed by source */ 
  • tOutputStream.cpp

    r161 r162  
    236236} 
    237237 
    238 void tOutputStream::WriteRegisterUpdatesImplementation(uint register_uid, uint entry_handle, size_t handle_size) 
     238bool tOutputStream::WriteRegisterUpdatesImplementation(uint register_uid, size_t handle_size) 
    239239{ 
    240240  bool escape_signal_written = false; 
     
    282282    WriteByte(-1); 
    283283  } 
     284  return escape_signal_written; 
    284285} 
    285286 
  • tOutputStream.h

    r158 r162  
    9494class IsSerializableMap; 
    9595class tInputStream; 
     96class tRegisterUpdate; 
    9697 
    9798//---------------------------------------------------------------------- 
     
    550551  template <typename TEntry, size_t Tchunk_count, size_t Tchunk_size, typename THandle, typename TMutex> 
    551552  friend class tRegister; 
     553  friend tOutputStream& operator << (tOutputStream& stream, const tRegisterUpdate& update); 
    552554 
    553555  /*! Info on a single published registers */ 
     
    639641   * \param register_uid UID of register whose entry is to be serialized after call 
    640642   * \param entry_handle Handle of entry to be serialized after call 
    641    * \param handle_size Size of register's handle (in bytes) 
    642    */ 
    643   void WriteRegisterUpdates(uint register_uid, uint entry_handle, size_t handle_size) 
     643   * \param handle_size Size of register's handle for escaping (in bytes). Passing zero will not escape updates. 
     644   * \return Whether any register updates have been written to stream 
     645   */ 
     646  bool WriteRegisterUpdates(uint register_uid, uint entry_handle, size_t handle_size) 
    644647  { 
    645648    size_t current_counter = shared_serialization_info.published_register_status->on_register_change_update_counter.load(); 
     
    647650    { 
    648651      shared_serialization_info.published_register_status->counter_on_last_update = current_counter; 
    649       WriteRegisterUpdatesImplementation(register_uid, entry_handle, handle_size); 
    650     } 
     652      return WriteRegisterUpdatesImplementation(register_uid, handle_size); 
     653    } 
     654    return false; 
    651655  } 
    652656 
     
    655659   * 
    656660   * \param register_uid UID of register whose entry is to be serialized after call 
    657    * \param entry_handle Handle of entry to be serialized after call 
    658    * \param handle_size Size of register's handle (in bytes) 
    659    */ 
    660   void WriteRegisterUpdatesImplementation(uint register_uid, uint entry_handle, size_t handle_size); 
     661   * \param handle_size Size of register's handle for escaping (in bytes). Passing zero will not escape updates. 
     662   * \return Whether any register updates have been written to stream 
     663   */ 
     664  bool WriteRegisterUpdatesImplementation(uint register_uid, size_t handle_size); 
    661665}; 
    662666 
Note: See TracChangeset for help on using the changeset viewer.