Index: third_party/protobuf/src/google/protobuf/stubs/singleton.h |
diff --git a/third_party/protobuf/src/google/protobuf/compiler/cpp/cpp_options.h b/third_party/protobuf/src/google/protobuf/stubs/singleton.h |
similarity index 67% |
copy from third_party/protobuf/src/google/protobuf/compiler/cpp/cpp_options.h |
copy to third_party/protobuf/src/google/protobuf/stubs/singleton.h |
index 787706629bd10fc72eb7811d9498f19dd0524d11..9301f549b1d6f9eeb038472eb326190d4be0e30d 100644 |
--- a/third_party/protobuf/src/google/protobuf/compiler/cpp/cpp_options.h |
+++ b/third_party/protobuf/src/google/protobuf/stubs/singleton.h |
@@ -1,6 +1,6 @@ |
// Protocol Buffers - Google's data interchange format |
-// Copyright 2008 Google Inc. All rights reserved. |
-// http://code.google.com/p/protobuf/ |
+// Copyright 2014 Google Inc. All rights reserved. |
+// https://developers.google.com/protocol-buffers/ |
// |
// Redistribution and use in source and binary forms, with or without |
// modification, are permitted provided that the following conditions are |
@@ -27,32 +27,42 @@ |
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
+#ifndef GOOGLE_PROTOBUF_STUBS_SINGLETON_H__ |
+#define GOOGLE_PROTOBUF_STUBS_SINGLETON_H__ |
-// Author: rennie@google.com (Jeffrey Rennie) |
- |
-#ifndef GOOGLE_PROTOBUF_COMPILER_CPP_OPTIONS_H__ |
-#define GOOGLE_PROTOBUF_COMPILER_CPP_OPTIONS_H__ |
- |
-#include <string> |
- |
+#include <google/protobuf/stubs/atomicops.h> |
#include <google/protobuf/stubs/common.h> |
+#include <google/protobuf/stubs/once.h> |
+ |
namespace google { |
namespace protobuf { |
-namespace compiler { |
-namespace cpp { |
- |
-// Generator options: |
-struct Options { |
- Options() : safe_boundary_check(false) { |
+namespace internal { |
+template<typename T> |
+class Singleton { |
+ public: |
+ static T* get() { |
+ GoogleOnceInit(&once_, &Singleton<T>::Init); |
+ return instance_; |
+ } |
+ static void ShutDown() { |
+ delete instance_; |
+ instance_ = NULL; |
} |
- string dllexport_decl; |
- bool safe_boundary_check; |
+ private: |
+ static void Init() { |
+ instance_ = new T(); |
+ } |
+ static ProtobufOnceType once_; |
+ static T* instance_; |
}; |
-} // namespace cpp |
-} // namespace compiler |
-} // namespace protobuf |
- |
+template<typename T> |
+ProtobufOnceType Singleton<T>::once_; |
+template<typename T> |
+T* Singleton<T>::instance_ = NULL; |
+} // namespace internal |
+} // namespace protobuf |
} // namespace google |
-#endif // GOOGLE_PROTOBUF_COMPILER_CPP_OPTIONS_H__ |
+ |
+#endif // GOOGLE_PROTOBUF_STUBS_SINGLETON_H__ |