diff options
author | Keith Isdale <keith.isdale@nokia.com> | 2010-07-26 14:56:53 +1000 |
---|---|---|
committer | Keith Isdale <keith.isdale@nokia.com> | 2010-07-26 14:56:53 +1000 |
commit | 9f034793bcfc51c2b7c1dd14db806f7258f9a9eb (patch) | |
tree | 63bd0f50ce5b77828ad8205eafd7b9412810499e /botan/build/botan/freestore.h | |
parent | 619d92cfef29e653bfdf852e83888e50cfc4348f (diff) | |
parent | 65271649dbc90f3af1184ad1b23bdb64c0c07d07 (diff) |
Merge branch 'master' of git://git-nokia.trolltech.com.au/qtsoftware/research/qtuitest
Diffstat (limited to 'botan/build/botan/freestore.h')
-rw-r--r-- | botan/build/botan/freestore.h | 85 |
1 files changed, 85 insertions, 0 deletions
diff --git a/botan/build/botan/freestore.h b/botan/build/botan/freestore.h new file mode 100644 index 0000000..f95afa8 --- /dev/null +++ b/botan/build/botan/freestore.h @@ -0,0 +1,85 @@ +/** +* (C) 2007 Christoph Ludwig +* ludwig@fh-worms.de +**/ + +#ifndef BOTAN_FREESTORE_H__ +#define BOTAN_FREESTORE_H__ + +#include <botan/build.h> + +#if defined(BOTAN_USE_STD_TR1) + #include <tr1/memory> +#elif defined(BOTAN_USE_BOOST_TR1) + #include <boost/tr1/memory.hpp> +#else + #error "Please choose a TR1 implementation in build.h" +#endif + +namespace Botan { + +/** +* This class is intended as an function call parameter type and +* enables convenient automatic conversions between plain and smart +* pointer types. It internally stores a SharedPointer which can be +* accessed. +* +* Distributed under the terms of the Botan license +*/ +template<typename T> +class BOTAN_DLL SharedPtrConverter + { + public: + typedef std::tr1::shared_ptr<T> SharedPtr; + + /** + * Construct a null pointer equivalent object. + */ + SharedPtrConverter() : ptr() {} + + /** + * Copy constructor. + */ + SharedPtrConverter(SharedPtrConverter const& other) : + ptr(other.ptr) {} + + /** + * Construct a converter object from another pointer type. + * @param p the pointer which shall be set as the internally stored + * pointer value of this converter. + */ + template<typename Ptr> + SharedPtrConverter(Ptr p) + : ptr(p) {} + + /** + * Get the internally stored shared pointer. + * @return the internally stored shared pointer + */ + SharedPtr const& get_ptr() const { return this->ptr; } + + /** + * Get the internally stored shared pointer. + * @return the internally stored shared pointer + */ + SharedPtr get_ptr() { return this->ptr; } + + /** + * Get the internally stored shared pointer. + * @return the internally stored shared pointer + */ + SharedPtr const& get_shared() const { return this->ptr; } + + /** + * Get the internally stored shared pointer. + * @return the internally stored shared pointer + */ + SharedPtr get_shared() { return this->ptr; } + + private: + SharedPtr ptr; + }; + +} + +#endif |