Created
April 22, 2015 23:14
-
-
Save RedBeard0531/8ce71a176e1ff071b42a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class OpDebug : public Decorable<OpDebug> { | |
public: | |
// | |
// Removed existing members for brevity. | |
// | |
class Extension { | |
virtual void appendToString(StringBuilder*) = 0; | |
virtual void appendToBson(BSONObjBuilder*) = 0; | |
protected: | |
// Can't delete through base pointer. | |
~Extension() = default; | |
}; | |
template <typename T> | |
static Decoration<T> declareExtension() { | |
BOOST_STATIC_ASSERT(std::is_base_of<Extension, T>()); | |
auto decoration = declareDecoration<T>(); | |
_extensions.push_back([decoration](CurOp* curOp) { | |
return decoration(curOp); | |
}); | |
return decoration; | |
} | |
private: | |
static std::vector<stdx::function<Extension&(CurOp*)>> _extensions; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment