Kaydet (Commit) c04a0895 authored tarafından Fahad Al-Saidi's avatar Fahad Al-Saidi Kaydeden (comit) Michael Meeks

fdo#80907 Implemented OOXMLFactory using boost::intrusive_ptr.

Change-Id: I350bca3544680ab8227d3bb1c093cba981cba5fc
üst c5b37ef1
...@@ -28,6 +28,7 @@ ...@@ -28,6 +28,7 @@
#include <ooxml/OOXMLFastTokens.hxx> #include <ooxml/OOXMLFastTokens.hxx>
#include "OOXMLFastContextHandler.hxx" #include "OOXMLFastContextHandler.hxx"
#include <boost/intrusive_ptr.hpp>
namespace writerfilter { namespace writerfilter {
namespace ooxml { namespace ooxml {
...@@ -127,7 +128,7 @@ protected: ...@@ -127,7 +128,7 @@ protected:
class OOXMLFactory class OOXMLFactory
{ {
public: public:
typedef boost::shared_ptr<OOXMLFactory> Pointer_t; typedef boost::intrusive_ptr<OOXMLFactory>Pointer_t;
static Pointer_t getInstance(); static Pointer_t getInstance();
...@@ -147,7 +148,16 @@ public: ...@@ -147,7 +148,16 @@ public:
void endAction(OOXMLFastContextHandler * pHandler, Token_t nToken); void endAction(OOXMLFastContextHandler * pHandler, Token_t nToken);
virtual ~OOXMLFactory(); virtual ~OOXMLFactory();
inline void IncRef() const{osl_atomic_increment(&mnRefCnt);}
inline void DecRef() const
{
if (!osl_atomic_decrement(&mnRefCnt))
const_cast<OOXMLFactory*>(this)->Delete();
}
inline void Delete() {delete this;}
inline oslInterlockedCount GetRef() const { return mnRefCnt; }
protected:
mutable oslInterlockedCount mnRefCnt; // reference count
private: private:
static Pointer_t m_Instance; static Pointer_t m_Instance;
...@@ -160,6 +170,14 @@ private: ...@@ -160,6 +170,14 @@ private:
Token_t Element); Token_t Element);
}; };
inline void intrusive_ptr_add_ref(const OOXMLFactory* p)
{
p->IncRef();
}
inline void intrusive_ptr_release(const OOXMLFactory* p)
{
p->DecRef();
}
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment