pgraph: add version of RenderState::get_attrib(_def) taking a CPT

This commit is contained in:
rdb 2018-06-14 22:51:12 +02:00
parent f804b10d45
commit 19e1b1d877
2 changed files with 17 additions and 2 deletions

View File

@ -483,7 +483,7 @@ flush_level() {
#ifndef CPPPARSER
/**
* Handy templated version of get_attrib that costs to the right type.
* Handy templated version of get_attrib that casts to the right type.
* Returns true if the attribute was present, false otherwise.
*/
template<class AttribType>
@ -492,15 +492,26 @@ get_attrib(const AttribType *&attrib) const {
attrib = (const AttribType *)get_attrib((int)AttribType::get_class_slot());
return (attrib != nullptr);
}
template<class AttribType>
INLINE bool RenderState::
get_attrib(CPT(AttribType) &attrib) const {
attrib = (const AttribType *)get_attrib((int)AttribType::get_class_slot());
return (attrib != nullptr);
}
/**
* Handy templated version of get_attrib_def that costs to the right type.
* Handy templated version of get_attrib_def that casts to the right type.
*/
template<class AttribType>
INLINE void RenderState::
get_attrib_def(const AttribType *&attrib) const {
attrib = (const AttribType *)get_attrib_def((int)AttribType::get_class_slot());
}
template<class AttribType>
INLINE void RenderState::
get_attrib_def(CPT(AttribType) &attrib) const {
attrib = (const AttribType *)get_attrib_def((int)AttribType::get_class_slot());
}
#endif // CPPPARSER
/**

View File

@ -162,7 +162,11 @@ public:
template<class AttribType>
INLINE bool get_attrib(const AttribType *&attrib) const;
template<class AttribType>
INLINE bool get_attrib(CPT(AttribType) &attrib) const;
template<class AttribType>
INLINE void get_attrib_def(const AttribType *&attrib) const;
template<class AttribType>
INLINE void get_attrib_def(CPT(AttribType) &attrib) const;
#endif // CPPPARSER
private: