Sierra Toolkit  Version of the Day
ProductRegistry.hpp
1 // Copyright (c) 2013, Sandia Corporation.
2 // Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
3 // the U.S. Government retains certain rights in this software.
4 //
5 // Redistribution and use in source and binary forms, with or without
6 // modification, are permitted provided that the following conditions are
7 // met:
8 //
9 // * Redistributions of source code must retain the above copyright
10 // notice, this list of conditions and the following disclaimer.
11 //
12 // * Redistributions in binary form must reproduce the above
13 // copyright notice, this list of conditions and the following
14 // disclaimer in the documentation and/or other materials provided
15 // with the distribution.
16 //
17 // * Neither the name of Sandia Corporation nor the names of its
18 // contributors may be used to endorse or promote products derived
19 // from this software without specific prior written permission.
20 //
21 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 //
33 
34 #ifndef STK_UTIL_ENVIRONMENT_PRODUCTREGISTRY_HPP
35 #define STK_UTIL_ENVIRONMENT_PRODUCTREGISTRY_HPP
36 
37 #include <map>
38 #include <string>
39 
40 namespace stk_classic {
41 
56 {
57 public:
58  typedef std::map<std::string, std::string> AttributeMap;
59  typedef std::map<std::string, AttributeMap> ProductMap;
60 
66  static ProductRegistry &instance();
67 
68 private:
74  : m_productMap(),
75  m_productName(),
76  m_registryOK(true)
77  {}
78 
80 
81  ProductRegistry &operator=(const ProductRegistry &);
82 
84  {}
85 
86 
87 public:
93  static const char *version();
94 
102  m_registryOK = false;
103  }
104 
112  bool isRegistryOK() {
113  return m_registryOK;
114  }
115 
121  const std::string &getProductName() const {
122  return m_productName;
123  }
124 
129  void setProductName(const std::string &product_name) {
130  m_productName = product_name;
131  }
132 
140  return m_productMap;
141  }
142 
152  AttributeMap &addProduct(const std::string &name);
153 
170  AttributeMap &addTPL(const std::string &name, const std::string &version, const std::string &qualifier = "");
171 
183  AttributeMap &addRegion(const std::string &name);
184 
195  AttributeMap &getProductAttributeMap(const std::string &name);
196 
211  const std::string &getProductAttribute(const std::string &name, const std::string &attribute) const;
212 
227  std::string &getProductAttribute(const std::string &name, const std::string &attribute);
228 
243  void setProductAttribute(const std::string &name, const std::string &attribute, const std::string &value);
244 
245 public:
246  static const std::string NAME;
247  static const std::string TITLE;
248  static const std::string VERSION;
249  static const std::string QUALIFIER;
250  static const std::string CONTACT;
251  static const std::string ERROR;
252  static const std::string PRODUCT_TYPE;
253 
254  static const std::string EXECUTABLE;
255  static const std::string BUILD_TIME;
256 
257  static const std::string BANNER_DETAIL;
258  static const std::string COPYRIGHT;
259 
260  static const std::string REGION_TITLE;
261 
262  static const std::string PRODUCT_TYPE_REGION;
263 
264 private:
265  mutable ProductMap m_productMap;
266  std::string m_productName;
267  bool m_registryOK;
268 };
269 
270 } // namespace stk_classic
271 
272 #ifdef STK_BUILT_IN_SIERRA
273 #undef VERSION // Nice, Trilinos leaves us this gem
274 
275 namespace sierra {
276 
277 typedef stk_classic::ProductRegistry ProductRegistry;
278 
279 } // namespace sierra
280 #endif // STK_BUILT_IN_SIERRA
281 
282 
283 #endif // STK_UTIL_ENVIRONMENT_PRODUCTREGISTRY_HPP
static const std::string BANNER_DETAIL
Product&#39;s additional banner info attribute.
ProductMap & getProductMap() const
Member function getProductMap returns a reference to the map of all products.
Definition: Env.cpp:53
static const std::string TITLE
Product&#39;s title attribute.
static const std::string PRODUCT_TYPE_REGION
Region product_type value.
void setProductAttribute(const std::string &name, const std::string &attribute, const std::string &value)
Member function setAttribute sets the attribute for the named poduct to the specified value...
std::map< std::string, AttributeMap > ProductMap
Map of product name to attribute map.
static const std::string BUILD_TIME
Product&#39;s build_time attribute.
Class ProductRegistry maps product names and attributes to brief descriptive values. Each added product has at a minimum the NAME value initialized. A region type product also has the PRODUCT_TYPE set to PRODUCT_TYPE_REGION.
static const std::string CONTACT
Product&#39;s contact attribute.
bool isRegistryOK()
Member function isRegistryOK returns true if the registry has not been flagged as having an error via...
static const char * version()
Member function version returns the version number of the combined product.
static ProductRegistry & instance()
Member function instance returns a reference to the registry singleton.
void setProductName(const std::string &product_name)
Member function setProductName sets the product name.
static const std::string REGION_TITLE
Product&#39;s region_title attribute.
const std::string & getProductName() const
Member function getProductName returns the product name.
const std::string & getProductAttribute(const std::string &name, const std::string &attribute) const
Member function getAttribute returns the attribute for the named product.
Sierra Toolkit.
AttributeMap & addTPL(const std::string &name, const std::string &version, const std::string &qualifier="")
Member function addTPL adds a product to the registry. A product always has the VERSION and QUALIFIER...
static const std::string QUALIFIER
TPL&#39;s qualifier attribute.
static const std::string EXECUTABLE
Product&#39;s executable attribute.
static const std::string COPYRIGHT
Product&#39;s copyright information.
std::map< std::string, std::string > AttributeMap
Map of attribute keyword to value.
AttributeMap & addRegion(const std::string &name)
Member function addRegion add a region as a product to the registry. A region product is a product wi...
static const std::string ERROR
Product&#39;s error attribute.
static const std::string VERSION
TPL&#39;s version attribute.
static const std::string PRODUCT_TYPE
Product&#39;s product_type attribute.
void setRegistryInvalid()
Member function setRegistryInvalid marks th registry as contain a conflict of some sort...
static const std::string NAME
Product&#39;s name attribute.
AttributeMap & addProduct(const std::string &name)
Member function addProduct adds a product to the registry.
AttributeMap & getProductAttributeMap(const std::string &name)
Member function getProduct returns a reference to the product attribute map.
const std::string & product_name()
Function product_name returns the product&#39;s name. This name is used to query the product registry for...
Definition: Env.cpp:174