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

Singleton to hold conventions. More...

#include <ored/configuration/conventions.hpp>

+ Inheritance diagram for InstrumentConventions:
+ Collaboration diagram for InstrumentConventions:

Public Member Functions

const QuantLib::ext::shared_ptr< ore::data::Conventions > & conventions (QuantLib::Date d=QuantLib::Date()) const
 
void setConventions (const QuantLib::ext::shared_ptr< ore::data::Conventions > &conventions, QuantLib::Date d=QuantLib::Date())
 
void clear ()
 

Private Member Functions

 InstrumentConventions ()
 

Private Attributes

std::map< QuantLib::Date, QuantLib::ext::shared_ptr< ore::data::Conventions > > conventions_
 
boost::shared_mutex mutex_
 
std::size_t numberOfEmittedWarnings_ = 0
 

Friends

class QuantLib::Singleton< InstrumentConventions, std::integral_constant< bool, true > >
 

Detailed Description

Singleton to hold conventions.

Definition at line 162 of file conventions.hpp.

Constructor & Destructor Documentation

◆ InstrumentConventions()

InstrumentConventions ( )
private

Definition at line 166 of file conventions.hpp.

166{ conventions_[Date()] = QuantLib::ext::make_shared<ore::data::Conventions>(); }
std::map< QuantLib::Date, QuantLib::ext::shared_ptr< ore::data::Conventions > > conventions_

Member Function Documentation

◆ conventions()

const QuantLib::ext::shared_ptr< ore::data::Conventions > & conventions ( QuantLib::Date  d = QuantLib::Date()) const

Definition at line 72 of file conventions.cpp.

72 {
73 QL_REQUIRE(!conventions_.empty(), "InstrumentConventions: No conventions provided.");
74 boost::shared_lock<boost::shared_mutex> lock(mutex_);
75 Date dt = d == Date() ? Settings::instance().evaluationDate() : d;
76 auto it = conventions_.lower_bound(dt);
77 if(it != conventions_.end() && it->first == dt)
78 return it->second;
79 QL_REQUIRE(it != conventions_.begin(), "InstrumentConventions: Could not find conventions for " << dt);
80 --it;
81 constexpr std::size_t max_num_warnings = 10;
82 if (numberOfEmittedWarnings_ < max_num_warnings) {
84 WLOG("InstrumentConventions: Could not find conventions for "
85 << dt << ", using conventions from " << it->first
86 << (numberOfEmittedWarnings_ == max_num_warnings ? " (no more warnings of this type will be emitted)"
87 : ""));
88 }
89 return it->second;
90}
#define WLOG(text)
Logging Macro (Level = Warning)
Definition: log.hpp:550
+ Here is the caller graph for this function:

◆ setConventions()

void setConventions ( const QuantLib::ext::shared_ptr< ore::data::Conventions > &  conventions,
QuantLib::Date  d = QuantLib::Date() 
)

Definition at line 92 of file conventions.cpp.

93 {
94 boost::unique_lock<boost::shared_mutex> lock(mutex_);
96}
const QuantLib::ext::shared_ptr< ore::data::Conventions > & conventions(QuantLib::Date d=QuantLib::Date()) const
Definition: conventions.cpp:72
+ Here is the call graph for this function:

◆ clear()

void clear ( )

Definition at line 176 of file conventions.hpp.

176{ conventions_.clear(); }

Friends And Related Function Documentation

◆ QuantLib::Singleton< InstrumentConventions, std::integral_constant< bool, true > >

friend class QuantLib::Singleton< InstrumentConventions, std::integral_constant< bool, true > >
friend

Definition at line 157 of file conventions.hpp.

Member Data Documentation

◆ conventions_

std::map<QuantLib::Date, QuantLib::ext::shared_ptr<ore::data::Conventions> > conventions_
mutableprivate

Definition at line 168 of file conventions.hpp.

◆ mutex_

boost::shared_mutex mutex_
mutableprivate

Definition at line 169 of file conventions.hpp.

◆ numberOfEmittedWarnings_

std::size_t numberOfEmittedWarnings_ = 0
mutableprivate

Definition at line 170 of file conventions.hpp.