BranchKey

Macros

Line Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
#ifndef DataFormats_Provenance_BranchKey_h
#define DataFormats_Provenance_BranchKey_h

/*----------------------------------------------------------------------
  
BranchKey: The key used to identify a Product in the EventPrincipal. The
name of the branch to which the related data product will be written
is determined entirely from the BranchKey.

----------------------------------------------------------------------*/
#include <iosfwd>
#include <string>

#include "DataFormats/Provenance/interface/ProductDescriptionFwd.h"

namespace edm {

  class BranchKey {
  public:
    BranchKey() : friendlyClassName_(), moduleLabel_(), productInstanceName_(), processName_() {}

    BranchKey(std::string const& cn, std::string const& ml, std::string const& pin, std::string const& pn)
        : friendlyClassName_(cn), moduleLabel_(ml), productInstanceName_(pin), processName_(pn) {}

    explicit BranchKey(ProductDescription const& desc);

    std::string const& friendlyClassName() const { return friendlyClassName_; }
    std::string const& moduleLabel() const { return moduleLabel_; }
    std::string const& productInstanceName() const { return productInstanceName_; }
    std::string const& processName() const { return processName_; }

  private:
    std::string friendlyClassName_;
    std::string moduleLabel_;
    std::string productInstanceName_;
    std::string processName_;
  };

  inline bool operator<(BranchKey const& a, BranchKey const& b) {
    return a.friendlyClassName() < b.friendlyClassName()       ? true
           : a.friendlyClassName() > b.friendlyClassName()     ? false
           : a.moduleLabel() < b.moduleLabel()                 ? true
           : a.moduleLabel() > b.moduleLabel()                 ? false
           : a.productInstanceName() < b.productInstanceName() ? true
           : a.productInstanceName() > b.productInstanceName() ? false
           : a.processName() < b.processName()                 ? true
                                                               : false;
  }

  inline bool operator==(BranchKey const& a, BranchKey const& b) { return !(a < b || b < a); }

  inline bool operator!=(BranchKey const& a, BranchKey const& b) { return !(a == b); }

  std::ostream& operator<<(std::ostream& os, BranchKey const& bk);
}  // namespace edm
#endif