diff options
author | Caolán McNamara <caolanm@redhat.com> | 2011-09-10 22:36:51 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2011-09-12 09:10:00 +0100 |
commit | ea05a88c5d9935d2835ff0d42f1df731f687b1ba (patch) | |
tree | 30c308b7403eb44d09f60f1bc0cccb13360e565c /svx | |
parent | 6bc7ca66d938f4e02b084fe4ab215a370058ff2a (diff) |
use boost::noncopyable and rtl::Static
Diffstat (limited to 'svx')
-rw-r--r-- | svx/source/accessibility/DGColorNameLookUp.cxx | 31 | ||||
-rw-r--r-- | svx/source/inc/DGColorNameLookUp.hxx | 19 |
2 files changed, 15 insertions, 35 deletions
diff --git a/svx/source/accessibility/DGColorNameLookUp.cxx b/svx/source/accessibility/DGColorNameLookUp.cxx index 844cd7f3d239..ca673015bc62 100644 --- a/svx/source/accessibility/DGColorNameLookUp.cxx +++ b/svx/source/accessibility/DGColorNameLookUp.cxx @@ -42,29 +42,18 @@ using namespace ::com::sun::star; namespace accessibility { -// Initialize the class instance with NULL. A true instance is created only -// when the static <member>Instance</member> is called for the first time. -DGColorNameLookUp* DGColorNameLookUp::mpInstance = NULL; - -DGColorNameLookUp& DGColorNameLookUp::Instance (void) +namespace { - // Using double check pattern to make sure that exactly one instance of - // the shape type handler is instantiated. - if (mpInstance == NULL) + class theDGColorNameLookUp + : public rtl::Static< DGColorNameLookUp, theDGColorNameLookUp > { - SolarMutexGuard aGuard; - if (mpInstance == NULL) - { - // Create the single instance of the color name look up. - mpInstance = new DGColorNameLookUp(); - } - } - - return *mpInstance; + }; } - - +DGColorNameLookUp& DGColorNameLookUp::Instance() +{ + return theDGColorNameLookUp::get(); +} OUString DGColorNameLookUp::LookUpColor (long int nColor) const { @@ -89,7 +78,7 @@ OUString DGColorNameLookUp::LookUpColor (long int nColor) const -DGColorNameLookUp::DGColorNameLookUp (void) +DGColorNameLookUp::DGColorNameLookUp() { uno::Sequence<OUString> aNames; uno::Reference<container::XNameAccess> xNA; @@ -141,7 +130,7 @@ DGColorNameLookUp::DGColorNameLookUp (void) -DGColorNameLookUp::~DGColorNameLookUp (void) +DGColorNameLookUp::~DGColorNameLookUp() { maColorValueToNameMap.clear(); } diff --git a/svx/source/inc/DGColorNameLookUp.hxx b/svx/source/inc/DGColorNameLookUp.hxx index 8ed88322228b..d3a04a2b8d71 100644 --- a/svx/source/inc/DGColorNameLookUp.hxx +++ b/svx/source/inc/DGColorNameLookUp.hxx @@ -30,7 +30,9 @@ #define _SVX_ACCESSIBILITY_DG_COLOR_NAME_LOOK_UP_HXX #include <rtl/ustrbuf.hxx> +#include <rtl/instance.hxx> #include <boost/unordered_map.hpp> +#include <boost/noncopyable.hpp> namespace accessibility { @@ -49,7 +51,7 @@ namespace accessibility { its values may change during this time. Reacting to these changes remains a task for the future.</p> */ -class DGColorNameLookUp +class DGColorNameLookUp : private ::boost::noncopyable { public: /** Return the single instance of this class. Use this to look up @@ -77,22 +79,11 @@ private: /// This ma translates from numerical color values to names. tColorValueToNameMap maColorValueToNameMap; - /** The pointer to the only instance of this class. It is NULL until - the <member>Instance</member> is called for the first time. - */ - static DGColorNameLookUp* mpInstance; - +private: + template<class> friend class rtl::Static; /// Create a new (the only) instance of this class. DGColorNameLookUp(); - - /// The destructor is never called. ~DGColorNameLookUp(); - - /// The copy constructor is not implemented. - DGColorNameLookUp (const DGColorNameLookUp&); - - /// The assignment operator is not implemented. - DGColorNameLookUp& operator= (const DGColorNameLookUp&); }; } // end of namespace accessibility |