Skip to content

Instantly share code, notes, and snippets.

@RedBeard0531
Created April 22, 2015 23:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save RedBeard0531/8ce71a176e1ff071b42a to your computer and use it in GitHub Desktop.
Save RedBeard0531/8ce71a176e1ff071b42a to your computer and use it in GitHub Desktop.
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