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 92 of file AttributeInjector.h.

Member Function Documentation

◆ getAttribute() [1/2]

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

Definition at line 121 of file AttributeInjector.h.

121 {
122 const bool found = false;
123
124 if (attribute != nullptr && attributeType == typeid(Attribute).name()) {
125 onFound(**std::static_pointer_cast<AttributeProxy<Attribute>>(attribute));
126 }
127
128 return found;
129 }
std::shared_ptr< void > attribute

◆ getAttribute() [2/2]

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

Definition at line 132 of file AttributeInjector.h.

133 {
134 if (attribute != nullptr && attributeType == typeid(Attribute).name()) {
135 onFound(**std::static_pointer_cast<AttributeProxy<Attribute>>(attribute));
136 } else {
137 onNotFound(std::string(typeid(Attribute).name()));
138 }
139 }

◆ setAttribute() [1/2]

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

Definition at line 108 of file AttributeInjector.h.

108 {
109 bool inserted = false;
110
111 if (!this->attribute || overwrite) {
112 attributeType = typeid(Attribute).name();
113 this->attribute = std::shared_ptr<void>(new AttributeProxy<Attribute>(attribute));
114 inserted = true;
115 }
116
117 return inserted;
118 }

◆ setAttribute() [2/2]

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

Definition at line 95 of file AttributeInjector.h.

95 {
96 bool inserted = false;
97
98 if (!this->attribute || overwrite) {
99 attributeType = typeid(Attribute).name();
100 this->attribute = std::shared_ptr<void>(new AttributeProxy<Attribute>(attribute));
101 inserted = true;
102 }
103
104 return inserted;
105 }

Member Data Documentation

◆ attribute

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

Definition at line 142 of file AttributeInjector.h.

142{nullptr};

◆ attributeType

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

Definition at line 143 of file AttributeInjector.h.


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