/
usr
/
include
/
boost
/
serialization
/
/usr/include/boost/serialization
mkdir
upload
Name
Size
Mode
Actions
detail/
-
0755
rm
access.hpp
4374
0644
edit
dl
rm
archive_input_unordered_map.hpp
2794
0644
edit
dl
rm
archive_input_unordered_set.hpp
2275
0644
edit
dl
rm
array.hpp
1443
0644
edit
dl
rm
array_optimization.hpp
1381
0644
edit
dl
rm
array_wrapper.hpp
3271
0644
edit
dl
rm
assume_abstract.hpp
1935
0644
edit
dl
rm
base_object.hpp
3008
0644
edit
dl
rm
binary_object.hpp
2295
0644
edit
dl
rm
bitset.hpp
1953
0644
edit
dl
rm
boost_array.hpp
949
0644
edit
dl
rm
boost_unordered_map.hpp
4272
0644
edit
dl
rm
boost_unordered_set.hpp
4044
0644
edit
dl
rm
collections_load_imp.hpp
2917
0644
edit
dl
rm
collections_save_imp.hpp
2306
0644
edit
dl
rm
collection_size_type.hpp
1764
0644
edit
dl
rm
collection_size_type copy.hpp
3415
0644
edit
dl
rm
collection_traits.hpp
3679
0644
edit
dl
rm
complex.hpp
2219
0644
edit
dl
rm
config.hpp
2734
0644
edit
dl
rm
deque.hpp
2324
0644
edit
dl
rm
export.hpp
8215
0644
edit
dl
rm
extended_type_info.hpp
3604
0644
edit
dl
rm
extended_type_info_no_rtti.hpp
6367
0644
edit
dl
rm
extended_type_info_typeid.hpp
5661
0644
edit
dl
rm
factory.hpp
4099
0644
edit
dl
rm
force_include.hpp
2073
0644
edit
dl
rm
forward_list.hpp
3865
0644
edit
dl
rm
hash_collections_load_imp.hpp
2686
0644
edit
dl
rm
hash_collections_save_imp.hpp
3435
0644
edit
dl
rm
hash_map.hpp
6313
0644
edit
dl
rm
hash_set.hpp
5884
0644
edit
dl
rm
is_bitwise_serializable.hpp
1399
0644
edit
dl
rm
item_version_type.hpp
1856
0644
edit
dl
rm
level.hpp
3621
0644
edit
dl
rm
level_enum.hpp
2140
0644
edit
dl
rm
library_version_type.hpp
2045
0644
edit
dl
rm
list.hpp
2485
0644
edit
dl
rm
map.hpp
4447
0644
edit
dl
rm
nvp.hpp
3538
0644
edit
dl
rm
optional.hpp
3201
0644
edit
dl
rm
priority_queue.hpp
2413
0644
edit
dl
rm
queue.hpp
2094
0644
edit
dl
rm
scoped_ptr.hpp
1552
0644
edit
dl
rm
serialization.hpp
4678
0644
edit
dl
rm
set.hpp
4284
0644
edit
dl
rm
shared_ptr.hpp
9821
0644
edit
dl
rm
shared_ptr_132.hpp
7370
0644
edit
dl
rm
shared_ptr_helper.hpp
7047
0644
edit
dl
rm
singleton.hpp
7603
0644
edit
dl
rm
slist.hpp
4828
0644
edit
dl
rm
smart_cast.hpp
8944
0644
edit
dl
rm
split_free.hpp
2734
0644
edit
dl
rm
split_member.hpp
2640
0644
edit
dl
rm
stack.hpp
2093
0644
edit
dl
rm
state_saver.hpp
2691
0644
edit
dl
rm
static_warning.hpp
3844
0644
edit
dl
rm
string.hpp
976
0644
edit
dl
rm
strong_typedef.hpp
3084
0644
edit
dl
rm
throw_exception.hpp
947
0644
edit
dl
rm
tracking.hpp
3990
0644
edit
dl
rm
tracking_enum.hpp
1227
0644
edit
dl
rm
traits.hpp
2017
0644
edit
dl
rm
type_info_implementation.hpp
2621
0644
edit
dl
rm
unique_ptr.hpp
1971
0644
edit
dl
rm
unordered_collections_load_imp.hpp
2438
0644
edit
dl
rm
unordered_collections_save_imp.hpp
2993
0644
edit
dl
rm
unordered_map.hpp
4164
0644
edit
dl
rm
unordered_set.hpp
4024
0644
edit
dl
rm
utility.hpp
1789
0644
edit
dl
rm
valarray.hpp
2754
0644
edit
dl
rm
variant.hpp
5122
0644
edit
dl
rm
vector.hpp
6924
0644
edit
dl
rm
vector_135.hpp
942
0644
edit
dl
rm
version.hpp
4291
0644
edit
dl
rm
void_cast.hpp
8747
0644
edit
dl
rm
void_cast_fwd.hpp
1187
0644
edit
dl
rm
weak_ptr.hpp
2437
0644
edit
dl
rm
wrapper.hpp
1907
0644
edit
dl
rm
Edit:
/usr/include/boost/serialization/singleton.hpp
(7603B)
#ifndef BOOST_SERIALIZATION_SINGLETON_HPP #define BOOST_SERIALIZATION_SINGLETON_HPP /////////1/////////2///////// 3/////////4/////////5/////////6/////////7/////////8 // singleton.hpp // // Copyright David Abrahams 2006. Original version // // Copyright Robert Ramey 2007. Changes made to permit // application throughout the serialization library. // // Copyright Alexander Grund 2018. Corrections to singleton lifetime // // Distributed under the Boost // Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) // // The intention here is to define a template which will convert // any class into a singleton with the following features: // // a) initialized before first use. // b) thread-safe for const access to the class // c) non-locking // // In order to do this, // a) Initialize dynamically when used. // b) Require that all singletons be initialized before main // is called or any entry point into the shared library is invoked. // This guarentees no race condition for initialization. // In debug mode, we assert that no non-const functions are called // after main is invoked. // // MS compatible compilers support #pragma once #if defined(_MSC_VER) # pragma once #endif #include <boost/assert.hpp> #include <boost/config.hpp> #include <boost/noncopyable.hpp> #include <boost/serialization/force_include.hpp> #include <boost/serialization/config.hpp> #include <boost/archive/detail/auto_link_archive.hpp> #include <boost/archive/detail/abi_prefix.hpp> // must be the last header #ifdef BOOST_MSVC # pragma warning(push) # pragma warning(disable : 4511 4512) #endif namespace boost { namespace serialization { ////////////////////////////////////////////////////////////////////// // Provides a dynamically-initialized (singleton) instance of T in a // way that avoids LNK1179 on vc6. See http://tinyurl.com/ljdp8 or // http://lists.boost.org/Archives/boost/2006/05/105286.php for // details. // // Singletons created by this code are guaranteed to be unique // within the executable or shared library which creates them. // This is sufficient and in fact ideal for the serialization library. // The singleton is created when the module is loaded and destroyed // when the module is unloaded. // This base class has two functions. // First it provides a module handle for each singleton indicating // the executable or shared library in which it was created. This // turns out to be necessary and sufficient to implement the tables // used by serialization library. // Second, it provides a mechanism to detect when a non-const function // is called after initialization. // Make a singleton to lock/unlock all singletons for alteration. // The intent is that all singletons created/used by this code // are to be initialized before main is called. A test program // can lock all the singletons when main is entered. Thus any // attempt to retrieve a mutable instance while locked will // generate an assertion if compiled for debug. // The singleton template can be used in 2 ways: // 1 (Recommended): Publicly inherit your type T from singleton<T>, // make its ctor protected and access it via T::get_const_instance() // 2: Simply access singleton<T> without changing T. Note that this only // provides a global instance accesible by singleton<T>::get_const_instance() // or singleton<T>::get_mutable_instance() to prevent using multiple instances // of T make its ctor protected // Note on usage of BOOST_DLLEXPORT: These functions are in danger of // being eliminated by the optimizer when building an application in // release mode. Usage of the macro is meant to signal the compiler/linker // to avoid dropping these functions which seem to be unreferenced. // This usage is not related to autolinking. class BOOST_SYMBOL_VISIBLE singleton_module : public boost::noncopyable { private: BOOST_DLLEXPORT bool & get_lock() BOOST_USED { static bool lock = false; return lock; } public: BOOST_DLLEXPORT void lock(){ get_lock() = true; } BOOST_DLLEXPORT void unlock(){ get_lock() = false; } BOOST_DLLEXPORT bool is_locked(){ return get_lock(); } }; static inline singleton_module & get_singleton_module(){ static singleton_module m; return m; } namespace detail { // This is the class actually instantiated and hence the real singleton. // So there will only be one instance of this class. This does not hold // for singleton<T> as a class derived from singleton<T> could be // instantiated multiple times. // It also provides a flag `is_destroyed` which returns true, when the // class was destructed. It is static and hence accesible even after // destruction. This can be used to check, if the singleton is still // accesible e.g. in destructors of other singletons. template<class T> class singleton_wrapper : public T { static bool & get_is_destroyed(){ // Prefer a static function member to avoid LNK1179. // Note: As this is for a singleton (1 instance only) it must be set // never be reset (to false)! static bool is_destroyed_flag = false; return is_destroyed_flag; } public: singleton_wrapper(){ BOOST_ASSERT(! is_destroyed()); } ~singleton_wrapper(){ get_is_destroyed() = true; } static bool is_destroyed(){ return get_is_destroyed(); } }; } // detail template <class T> class singleton { private: static T * m_instance; // include this to provoke instantiation at pre-execution time static void use(T const &) {} static T & get_instance() { BOOST_ASSERT(! is_destroyed()); // use a wrapper so that types T with protected constructors can be used // Using a static function member avoids LNK1179 static detail::singleton_wrapper< T > t; // note that the following is absolutely essential. // commenting out this statement will cause compilers to fail to // construct the instance at pre-execution time. This would prevent // our usage/implementation of "locking" and introduce uncertainty into // the sequence of object initialization. // Unfortunately, this triggers detectors of undefine behavior // and reports an error. But I've been unable to find a different // of guarenteeing that the the singleton is created at pre-main time. if (m_instance) use(* m_instance); return static_cast<T &>(t); } protected: // Do not allow instantiation of a singleton<T>. But we want to allow // `class T: public singleton<T>` so we can't delete this ctor BOOST_DLLEXPORT singleton(){} public: BOOST_DLLEXPORT static T & get_mutable_instance(){ BOOST_ASSERT(! get_singleton_module().is_locked()); return get_instance(); } BOOST_DLLEXPORT static const T & get_const_instance(){ return get_instance(); } BOOST_DLLEXPORT static bool is_destroyed(){ return detail::singleton_wrapper< T >::is_destroyed(); } }; // Assigning the instance reference to a static member forces initialization // at startup time as described in // https://groups.google.com/forum/#!topic/microsoft.public.vc.language/kDVNLnIsfZk template<class T> T * singleton< T >::m_instance = & singleton< T >::get_instance(); } // namespace serialization } // namespace boost #include <boost/archive/detail/abi_suffix.hpp> // pops abi_suffix.hpp pragmas #ifdef BOOST_MSVC #pragma warning(pop) #endif #endif // BOOST_SERIALIZATION_SINGLETON_HPP
Save
cmd:
run