SNode.C
Loading...
Searching...
No Matches
utils::SingleAttributeInjector Class Reference

#include <AttributeInjector.h>

Collaboration diagram for utils::SingleAttributeInjector:

Public Member Functions

template<InjectableAttribute Attribute>
constexpr bool setAttribute (const Attribute &attribute, bool overwrite=false)
 
template<InjectableAttribute Attribute>
constexpr bool setAttribute (const Attribute &&attribute, bool overwrite=false)
 
template<InjectableAttribute Attribute>
constexpr bool getAttribute (const std::function< void(Attribute &)> &onFound) const
 
template<InjectableAttribute Attribute>
constexpr void getAttribute (const std::function< void(Attribute &)> &onFound, const std::function< void(const std::string &)> &onNotFound) const
 

Private Attributes

std::shared_ptr< void > attribute {nullptr}
 
std::string attributeType
 

Detailed Description

Definition at line 70 of file AttributeInjector.h.

Member Function Documentation

◆ getAttribute() [1/2]

template<InjectableAttribute Attribute>
bool utils::SingleAttributeInjector::getAttribute ( const std::function< void(Attribute &)> & onFound) const
inlineconstexpr

Definition at line 99 of file AttributeInjector.h.

99 {
100 const bool found = false;
101
102 if (attribute != nullptr && attributeType == typeid(Attribute).name()) {
103 onFound(**std::static_pointer_cast<AttributeProxy<Attribute>>(attribute));
104 }
105
106 return found;
107 }
std::shared_ptr< void > attribute

◆ getAttribute() [2/2]

template<InjectableAttribute Attribute>
void utils::SingleAttributeInjector::getAttribute ( const std::function< void(Attribute &)> & onFound,
const std::function< void(const std::string &)> & onNotFound ) const
inlineconstexpr

Definition at line 110 of file AttributeInjector.h.

111 {
112 if (attribute != nullptr && attributeType == typeid(Attribute).name()) {
113 onFound(**std::static_pointer_cast<AttributeProxy<Attribute>>(attribute));
114 } else {
115 onNotFound(std::string(typeid(Attribute).name()));
116 }
117 }

◆ setAttribute() [1/2]

template<InjectableAttribute Attribute>
bool utils::SingleAttributeInjector::setAttribute ( const Attribute && attribute,
bool overwrite = false )
inlineconstexpr

Definition at line 86 of file AttributeInjector.h.

86 {
87 bool inserted = false;
88
89 if (!this->attribute || overwrite) {
90 attributeType = typeid(Attribute).name();
91 this->attribute = std::shared_ptr<void>(new AttributeProxy<Attribute>(attribute));
92 inserted = true;
93 }
94
95 return inserted;
96 }

◆ setAttribute() [2/2]

template<InjectableAttribute Attribute>
bool utils::SingleAttributeInjector::setAttribute ( const Attribute & attribute,
bool overwrite = false )
inlineconstexpr

Definition at line 73 of file AttributeInjector.h.

73 {
74 bool inserted = false;
75
76 if (!this->attribute || overwrite) {
77 attributeType = typeid(Attribute).name();
78 this->attribute = std::shared_ptr<void>(new AttributeProxy<Attribute>(attribute));
79 inserted = true;
80 }
81
82 return inserted;
83 }

Member Data Documentation

◆ attribute

std::shared_ptr<void> utils::SingleAttributeInjector::attribute {nullptr}
private

Definition at line 120 of file AttributeInjector.h.

120{nullptr};

◆ attributeType

std::string utils::SingleAttributeInjector::attributeType
private

Definition at line 121 of file AttributeInjector.h.


The documentation for this class was generated from the following file: