Darin Petkov | 804e8d0 | 2012-10-10 16:44:36 +0200 | [diff] [blame] | 1 | // Copyright (c) 2012 The Chromium OS Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #ifndef SHILL_SHIMS_ENVIRONMENT_H_ |
| 6 | #define SHILL_SHIMS_ENVIRONMENT_H_ |
| 7 | |
| 8 | #include <map> |
| 9 | #include <string> |
| 10 | |
| 11 | #include <base/lazy_instance.h> |
| 12 | |
| 13 | namespace shill { |
| 14 | |
| 15 | namespace shims { |
| 16 | |
| 17 | // Environment access utilities. |
| 18 | class Environment { |
| 19 | public: |
| 20 | virtual ~Environment(); |
| 21 | |
| 22 | // This is a singleton -- use Environment::GetInstance()->Foo() |
| 23 | static Environment *GetInstance(); |
| 24 | |
| 25 | // Sets |value| to the value of environment variable |name| and returns |
| 26 | // true. Returns false if variable |name| is not set. |
| 27 | virtual bool GetVariable(const std::string &name, std::string *value); |
| 28 | |
| 29 | // Parses and returns the environment as a name->value string map. |
| 30 | virtual std::map<std::string, std::string> AsMap(); |
| 31 | |
| 32 | protected: |
| 33 | Environment(); |
| 34 | |
| 35 | private: |
| 36 | friend struct base::DefaultLazyInstanceTraits<Environment>; |
| 37 | |
| 38 | DISALLOW_COPY_AND_ASSIGN(Environment); |
| 39 | }; |
| 40 | |
| 41 | } // namespace shims |
| 42 | |
| 43 | } // namespace shill |
| 44 | |
| 45 | #endif // SHILL_SHIMS_ENVIRONMENT_H_ |