SeExpr
SeContext.h
Go to the documentation of this file.
1 /*
2 * Copyright Disney Enterprises, Inc. All rights reserved.
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 * and the following modification to it: Section 6 Trademarks.
7 * deleted and replaced with:
8 *
9 * 6. Trademarks. This License does not grant permission to use the
10 * trade names, trademarks, service marks, or product names of the
11 * Licensor and its affiliates, except as required for reproducing
12 * the content of the NOTICE file.
13 *
14 * You may obtain a copy of the License at
15 * http://www.apache.org/licenses/LICENSE-2.0
16 */
17 #pragma once
18 
19 #include <map>
20 #include <string>
21 
22 class SeContext{
23 public:
25  bool lookupParameter(const std::string& parameterName,std::string& value) const{
26  ParameterMap::const_iterator it=_parameters.find(parameterName);
27  if(it != _parameters.end()){value=it->second;return true;}
28  else if(_parent) return _parent->lookupParameter(parameterName,value);
29  else return false;
30  }
32  void setParameter(const std::string& parameterName,const std::string& value);
35 
36  // Parent access uses pointers as it is acceptable to set/get a NULL parent
38  const SeContext* getParent() const {return _parent;}
39 
40  bool hasContext(const SeContext* context) const{
41  if(this == context) return true;
42  if(_parent) return _parent->hasContext(context);
43  return false;
44  }
45 
47  static SeContext& global();
48 private:
51  SeContext(const SeContext&);
52  SeContext& operator=(const SeContext&);
53 
54  SeContext(const SeContext* parent);
57 
58  // TODO: Use std::map until C++11 is ubiq.
59  typedef std::map<std::string,std::string> ParameterMap;
62 };
SeContext * createChildContext() const
Create a context that is a child of this context.
Definition: SeContext.cpp:27
std::map< std::string, std::string > ParameterMap
Definition: SeContext.h:59
void setParameter(const std::string &parameterName, const std::string &value)
Set a parameter. NOTE: this must be done when no threads are accessing lookupParameter for safety...
Definition: SeContext.cpp:23
SeContext & operator=(const SeContext &)
ParameterMap _parameters
Attribute/value pairs.
Definition: SeContext.h:61
bool lookupParameter(const std::string &parameterName, std::string &value) const
Lookup a SeContext parameter by name.
Definition: SeContext.h:25
void setParent(const SeContext *context)
Definition: SeContext.h:37
static SeContext & global()
The global default context of the seexpr.
Definition: SeContext.cpp:31
For any rgb or hsl value(except for negative s values)
const SeContext * _parent
The parent scope.
Definition: SeContext.h:56
const SeContext * getParent() const
Definition: SeContext.h:38
bool hasContext(const SeContext *context) const
Definition: SeContext.h:40
SeContext(const SeContext &)
If a scalar is used in a vector context
Definition: userdoc.txt:456
you may not use this file except in compliance with the License and the following modification to it
Definition: license.txt:10