19 #ifndef ASYLO_PLATFORM_CORE_SHARED_NAME_H_ 20 #define ASYLO_PLATFORM_CORE_SHARED_NAME_H_ 27 #include "asylo/platform/common/hash_combine.h" 28 #include "asylo/platform/core/shared_name_kind.h" 39 SharedName() =
default;
45 SharedName(SharedNameKind kind,
const std::string &name)
46 : kind_(kind), name_(name) {}
51 SharedNameKind kind()
const {
return kind_; }
56 const std::string &name()
const {
return name_; }
59 static SharedName Address(
const std::string &name) {
60 return SharedName(kAddressName, name);
64 static SharedName MemBlock(
const std::string &name) {
65 return SharedName(kMemBlockName, name);
69 static SharedName Socket(
const std::string &name) {
70 return SharedName(kSocketName, name);
74 static SharedName Timer(
const std::string &name) {
75 return SharedName(kTimerName, name);
78 struct Hash : std::unary_function<SharedName, size_t> {
79 size_t operator()(
const SharedName &name)
const {
80 return HashCombine<std::string>(std::hash<
int>()(name.kind_), name.name_);
84 struct Eq : std::binary_function<SharedName, SharedName,
bool> {
85 bool operator()(
const SharedName &lhs,
const SharedName &rhs)
const {
86 return (lhs.kind_ == rhs.kind_) && (lhs.name_ == rhs.name_);
95 inline std::ostream &operator<<(std::ostream &os,
const SharedName &name) {
96 switch (name.kind()) {
97 case kUnspecifiedName:
98 os <<
"kUnspecifiedName";
101 os <<
"kAddressName";
110 os <<
"kMemBlockName";
115 return os <<
"::" << name.name();