libbmq  a5f8a06ba1d16cb5a65643e1fa7f1a1d6aadef40
bmqpi_dtspan.h
Go to the documentation of this file.
1 // Copyright 2021-2023 Bloomberg Finance L.P.
2 // SPDX-License-Identifier: Apache-2.0
3 //
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 // http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 
16 // bmqpi_dtspan.h -*-C++-*-
17 #ifndef INCLUDED_BMQPI_DTSPAN
18 #define INCLUDED_BMQPI_DTSPAN
19 
30 
31 // BMQ
32 
33 // BDE
34 #include <bsl_string.h>
35 #include <bsl_string_view.h>
36 #include <bsl_unordered_map.h>
37 #include <bslma_allocator.h>
38 
39 namespace BloombergLP {
40 namespace bmqpi {
41 
42 // ============
43 // class DTSpan
44 // ============
45 
47 class DTSpan {
48  public:
49  // PUBLIC CREATORS
50 
52  virtual ~DTSpan();
53 
54  // PUBLIC ACCESSORS
55 
57  virtual bsl::string_view operation() const = 0;
58 
59  // =============
60  // class Baggage
61  // =============
62 
63  // PUBLIC INNER CLASSES
64 
66  class Baggage BSLS_KEYWORD_FINAL {
67  private:
68  // PRIVATE TYPEDEFS
69  typedef bsl::unordered_map<bsl::string, bsl::string> MapType;
70 
71  // PRIVATE DATA
72  MapType d_data;
73 
74  public:
75  // PUBLIC TYPES
76  typedef MapType::const_iterator const_iterator;
77 
78  // PUBLIC CREATORS
79  Baggage(bslma::Allocator* allocator = 0);
80 
81  // PUBLIC ACCESSORS
82 
85 
88 
91  bool has(const bsl::string& key) const;
92 
99  bsl::string_view get(const bsl::string& key,
100  const bsl::string_view& dflt = "") const;
101 
102  // PUBLIC MANIPULATORS
103 
107  void put(const bsl::string_view& key, const bsl::string_view& value);
108 
111  bool erase(const bsl::string& key);
112  };
113 };
114 
115 } // close package namespace
116 } // close enterprise namespace
117 
118 #endif
A set of key-values used to describe a DTSpan.
Definition: bmqpi_dtspan.h:66
bsl::string_view get(const bsl::string &key, const bsl::string_view &dflt="") const
bool erase(const bsl::string &key)
bool has(const bsl::string &key) const
MapType::const_iterator const_iterator
Definition: bmqpi_dtspan.h:76
Baggage(bslma::Allocator *allocator=0)
const_iterator begin() const
Returns a const-iterator used to iterate over key-values.
void put(const bsl::string_view &key, const bsl::string_view &value)
const_iterator end() const
Returns a const-iterator representing the end of key-values.
A pure interface for representing a span of a distributed trace.
Definition: bmqpi_dtspan.h:47
virtual bsl::string_view operation() const =0
Returns the name of the operation that this DTSpan represents.
virtual ~DTSpan()
Destructor.
Definition: bmqa_abstractsession.h:42