@@ -322,22 +322,35 @@ class CompoundArrayMessage_ final : public ArrayMessageBase
322322 // Explicitly use Message operator to prevent hidden warnings
323323 using Message::operator [];
324324
325- CompoundMessage &operator []( size_t index ) { return getImplementation ( index ); }
325+ CompoundMessage &operator []( size_t index ) { return * get ( index ); }
326326
327- const CompoundMessage &operator []( size_t index ) const { return getImplementation ( index ); }
327+ const CompoundMessage &operator []( size_t index ) const { return * get ( index ); }
328328
329- CompoundMessage &at ( size_t index ) { return getImplementation ( index ); }
329+ // ! Use at to obtain a reference to the message.
330+ // ! @throws std::out_of_range If index is out of range.
331+ CompoundMessage &at ( size_t index ) { return *get ( index ); }
330332
331- const CompoundMessage &at ( size_t index ) const { return getImplementation ( index ); }
333+ const CompoundMessage &at ( size_t index ) const { return *get ( index ); }
334+
335+ // ! Use get to obtain the shared ptr to the message.
336+ // ! @throws std::out_of_range If index is out of range.
337+ CompoundMessage::SharedPtr get ( size_t index )
338+ {
339+ ensureInitialized ( index );
340+ return values_[index];
341+ }
342+
343+ CompoundMessage::ConstSharedPtr get ( size_t index ) const
344+ {
345+ ensureInitialized ( index );
346+ return values_[index];
347+ }
332348
333349 /* !
334350 * @param index The index at which the array element is set/overwritten
335351 * @param value The value with which the array element is overwritten, has to be the same as the element type.
336352 */
337- virtual void assign ( size_t index, const CompoundMessage &value )
338- {
339- getImplementation ( index ) = value;
340- }
353+ virtual void assign ( size_t index, const CompoundMessage &value ) { *get ( index ) = value; }
341354
342355 // ! Alias for _assign
343356 void replace ( size_t index, const CompoundMessage &value ) { assign ( index, value ); }
@@ -362,7 +375,7 @@ class CompoundArrayMessage_ final : public ArrayMessageBase
362375 {
363376 size_t index = size ();
364377 resize ( index + 1 );
365- return getImplementation ( index );
378+ return * get ( index );
366379 }
367380
368381 void pop_back ()
@@ -470,18 +483,6 @@ class CompoundArrayMessage_ final : public ArrayMessageBase
470483 }
471484 }
472485
473- CompoundMessage &getImplementation ( size_t index )
474- {
475- ensureInitialized ( index );
476- return *values_[index];
477- }
478-
479- const CompoundMessage &getImplementation ( size_t index ) const
480- {
481- ensureInitialized ( index );
482- return *values_[index];
483- }
484-
485486 void _assign ( const ArrayMessageBase &other ) override
486487 {
487488 if ( other.isBounded () ) {
0 commit comments