diff --git a/opentracing/tracer.cc b/opentracing/tracer.cc index 25fe42b..9411982 100644 --- a/opentracing/tracer.cc +++ b/opentracing/tracer.cc @@ -58,6 +58,10 @@ TextMapReader::~TextMapReader() { } +TextMapReader::ReadCallback::~ReadCallback() +{ +} + namespace { class NoopSpan : public virtual Span diff --git a/opentracing/tracer.h b/opentracing/tracer.h index 6b1a947..5b5dd5a 100644 --- a/opentracing/tracer.h +++ b/opentracing/tracer.h @@ -245,14 +245,26 @@ class TextMapReader : public virtual Reader virtual ~TextMapReader(); /** - * The type of callback which will be called for each key. + * Callback functor typically implemented from the tracer in order to retrieve + * key-value pairs from the `TextMapReader`. */ - typedef void (*PairReadCallback)(const std::string& key, const std::string& value, bool isBaggage); + struct ReadCallback + { + /** + * Destroys this ReadCallback. + */ + virtual ~ReadCallback(); + + /** + * Will be called for each key-value pair. + */ + virtual void operator() (const std::string& key, const std::string& value, bool isBaggage) const = 0; + }; /** * Reads from the carrier and calls the `callback()` for each key-value pair. */ - virtual void forEachPair(const PairReadCallback & callback) const = 0; + virtual void forEachPair(const ReadCallback & callback) const = 0; }; /** diff --git a/test/opentracing.t.cc b/test/opentracing.t.cc index 746d3de..f5d42a0 100644 --- a/test/opentracing.t.cc +++ b/test/opentracing.t.cc @@ -158,7 +158,7 @@ class MapTextAdapter : public TextMapWriter, public TextMapReader m_carrier.insert(typename T::value_type(key, std::make_pair(value, isBaggage))); } - virtual void forEachPair(const PairReadCallback & callback) const + virtual void forEachPair(const ReadCallback & callback) const { for (typename T::const_iterator i = m_carrier.begin(); i != m_carrier.end(); ++i) {