[Bro-Dev] Broker & CAF includes

Matthias Vallentin vallentin at icir.org
Fri Mar 18 20:20:57 PDT 2016


During Broker refactoring, I noticed the following: all headers in
broker/* include either standard library headers or Broker headers. This
appears to be by design, which makes sense to me. 

As a library writer, one faces the tricky question of exposing headers
from dependencies. For example, Broker currently has it's own
broker::util::optional, which ships as a (now outdated) copy of the
corresponding CAF source. I am inclined to change this copy to an
include that points directly into CAF headers, with the following
rationale: Broker already depends on CAF, and a system that has CAF
installed always ships with CAF headers. (Strictly speaking, we're not
copying the code of <vector> into broker either, but relying on it via
an include.)

>From a user perspective, nothing changes here. A user will never include
a CAF header, but may rely on it during compilation. Here's what I an
example of what I want broker/util/optional.hh to look like:

    #include "caf/optional.hpp" // <--- New include.

    namespace broker { namespace util {
    
    using caf::optional;

    }}

Currently we have:

    // Note the absence of a CAF include.
    namespace broker { namespace util {
    
    template <class T>
    class optional {
      // code copied from CAF
    };

    }}

Relying on the former form is more maintainable, and allows us to stay
in sync with upstream fixes and improvements on the CAF side. I'm
checking in here on the list to see whether anyone has objections. 

    Matthias


More information about the bro-dev mailing list