Skip to content

Commit

Permalink
renamed some variables, added tests
Browse files Browse the repository at this point in the history
  • Loading branch information
satac2 committed Jun 10, 2020
1 parent 565c40e commit 2d4a411
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions api/include/opentelemetry/context/context.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@ namespace context
private:

/*The identifier itself*/
std::map<int, int> ctx_;
std::map<int, int> ctx_map_;

/*Used to track that last ContextKey identifier and create the next one */
static int last_key_identifier_;

/* Context: A constructor that accepts a key/value map*/
Context(std::map<int,int> ctx){
ctx_ = ctx;
Context(std::map<int,int> ctx_map){
ctx_map_ = ctx_map;
}

public:
Expand Down Expand Up @@ -81,23 +81,23 @@ namespace context
/* Context: contructor, creates a context object with no key/value pairs
*/
Context(){
ctx_ = std::map<int,int> {};
ctx_map_ = std::map<int,int> {};

}

/* Context: contructor, creates a context object from a map
* of keys and identifiers
*/
Context(ContextKey key, int value){
ctx_[key.GetIdentifier()] = value;
ctx_map_[key.GetIdentifier()] = value;
}


/* WriteValue: accepts a new key/value pair and then returns a new
* context that contains both the original pairs and the new pair.
*/
Context WriteValue(ContextKey key, int value){
std::map<int, int> temp_map = ctx_;
std::map<int, int> temp_map = ctx_map_;

temp_map[key.GetIdentifier()] = value;

Expand All @@ -108,7 +108,7 @@ namespace context
/* GetValue: Returns the value associated with the passed in key
*/
int GetValue(ContextKey key){
return ctx_[key.GetIdentifier()];
return ctx_map_[key.GetIdentifier()];
}

/* CreateKey: Returns a ContextKey that has the passed in name and the
Expand Down Expand Up @@ -146,7 +146,7 @@ namespace context
/* Token: A constructor that sets the token's Context object to the
* one that was passed in.
*/
Token(Context ctx){
Token(Context &ctx){
ctx_ = ctx;
}

Expand Down Expand Up @@ -178,15 +178,15 @@ namespace context
/* RuntimeContext: A constructor that will set the context as
* the passed in context.
*/
RuntimeContext(Context context){
RuntimeContext(Context &context){

context_ = context;
}

/* attach: Sets the current 'Context' object. Returns a token
* that can be used to reset to the previous Context.
*/
Token Attach(Context context){
Token Attach(Context &context){

Token old_context_token = Token(context_);

Expand All @@ -208,7 +208,7 @@ namespace context
/* Detach: Resets the context to a previous value stored in the
* passed in token.
*/
void Detach(Token token){
void Detach(Token &token){
context_ = token.GetContext();
}

Expand Down

0 comments on commit 2d4a411

Please sign in to comment.