Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
Public Member Functions | Private Attributes | List of all members
BufferedSensitivityStream Class Reference

#include <orea/engine/bufferedsensitivitystream.hpp>

+ Inheritance diagram for BufferedSensitivityStream:
+ Collaboration diagram for BufferedSensitivityStream:

Public Member Functions

 BufferedSensitivityStream (const QuantLib::ext::shared_ptr< SensitivityStream > &stream)
 
SensitivityRecord next () override
 Returns the next SensitivityRecord in the stream. More...
 
void reset () override
 Resets the stream so that SensitivityRecord objects can be streamed again. More...
 
- Public Member Functions inherited from SensitivityStream
virtual ~SensitivityStream ()
 Destructor. More...
 
virtual SensitivityRecord next ()=0
 Returns the next SensitivityRecord in the stream. More...
 
virtual void reset ()=0
 Resets the stream so that SensitivityRecord objects can be streamed again. More...
 

Private Attributes

QuantLib::ext::shared_ptr< SensitivityStreamstream_
 
std::vector< SensitivityRecordbuffer_
 
QuantLib::Size index_ = QuantLib::Null<QuantLib::Size>()
 

Detailed Description

Definition at line 30 of file bufferedsensitivitystream.hpp.

Constructor & Destructor Documentation

◆ BufferedSensitivityStream()

BufferedSensitivityStream ( const QuantLib::ext::shared_ptr< SensitivityStream > &  stream)
explicit

Definition at line 24 of file bufferedsensitivitystream.cpp.

25 : stream_(stream) {}
QuantLib::ext::shared_ptr< SensitivityStream > stream_

Member Function Documentation

◆ next()

SensitivityRecord next ( )
overridevirtual

Returns the next SensitivityRecord in the stream.

Implements SensitivityStream.

Definition at line 27 of file bufferedsensitivitystream.cpp.

27 {
28 if (index_ == QuantLib::Null<Size>()) {
29 buffer_.push_back(stream_->next());
30 return buffer_.back();
31 }
32 if (index_ < buffer_.size()) {
33 return buffer_[index_++];
34 }
35 return {};
36}

◆ reset()

void reset ( )
overridevirtual

Resets the stream so that SensitivityRecord objects can be streamed again.

Implements SensitivityStream.

Definition at line 38 of file bufferedsensitivitystream.cpp.

38 {
39 // if next() was never called, we do not switch to the buffered mode
40 if (!buffer_.empty())
41 index_ = 0;
42}

Member Data Documentation

◆ stream_

QuantLib::ext::shared_ptr<SensitivityStream> stream_
private

Definition at line 37 of file bufferedsensitivitystream.hpp.

◆ buffer_

std::vector<SensitivityRecord> buffer_
private

Definition at line 38 of file bufferedsensitivitystream.hpp.

◆ index_

QuantLib::Size index_ = QuantLib::Null<QuantLib::Size>()
private

Definition at line 39 of file bufferedsensitivitystream.hpp.