Kaydet (Commit) 183e062e authored tarafından Noel Grandin's avatar Noel Grandin

use SimpleReferenceObject in connectivity module

to replace hand-rolled version

Change-Id: Ib415a6e78733277cbc1c0777d7263b65f404e6a4
üst ea8f32b6
...@@ -52,7 +52,6 @@ endif ...@@ -52,7 +52,6 @@ endif
#connectivity/source/commontools/RowFunctionParser.cxx disable optimization? #connectivity/source/commontools/RowFunctionParser.cxx disable optimization?
$(eval $(call gb_Library_add_exception_objects,dbtools,\ $(eval $(call gb_Library_add_exception_objects,dbtools,\
connectivity/source/simpledbt/refbase \
)) ))
$(eval $(call gb_Library_add_grammars,dbtools,\ $(eval $(call gb_Library_add_grammars,dbtools,\
......
...@@ -30,18 +30,6 @@ namespace connectivity ...@@ -30,18 +30,6 @@ namespace connectivity
//= ODataAccessCharSet //= ODataAccessCharSet
oslInterlockedCount SAL_CALL ODataAccessCharSet::acquire()
{
return ORefBase::acquire();
}
oslInterlockedCount SAL_CALL ODataAccessCharSet::release()
{
return ORefBase::release();
}
sal_Int32 ODataAccessCharSet::getSupportedTextEncodings( ::std::vector< rtl_TextEncoding >& _rEncs ) const sal_Int32 ODataAccessCharSet::getSupportedTextEncodings( ::std::vector< rtl_TextEncoding >& _rEncs ) const
{ {
_rEncs.clear(); _rEncs.clear();
......
...@@ -21,7 +21,6 @@ ...@@ -21,7 +21,6 @@
#define INCLUDED_CONNECTIVITY_SOURCE_SIMPLEDBT_CHARSET_S_HXX #define INCLUDED_CONNECTIVITY_SOURCE_SIMPLEDBT_CHARSET_S_HXX
#include <connectivity/virtualdbtools.hxx> #include <connectivity/virtualdbtools.hxx>
#include "refbase.hxx"
#include <connectivity/dbcharset.hxx> #include <connectivity/dbcharset.hxx>
...@@ -32,9 +31,7 @@ namespace connectivity ...@@ -32,9 +31,7 @@ namespace connectivity
//= ODataAccessCharSet //= ODataAccessCharSet
class ODataAccessCharSet class ODataAccessCharSet : public simple::IDataAccessCharSet
:public simple::IDataAccessCharSet
,public ORefBase
{ {
protected: protected:
::dbtools::OCharsetMap m_aCharsetInfo; ::dbtools::OCharsetMap m_aCharsetInfo;
...@@ -46,10 +43,6 @@ namespace connectivity ...@@ -46,10 +43,6 @@ namespace connectivity
sal_Int32 getSupportedTextEncodings( sal_Int32 getSupportedTextEncodings(
::std::vector< rtl_TextEncoding >& /* [out] */ _rEncs ::std::vector< rtl_TextEncoding >& /* [out] */ _rEncs
) const SAL_OVERRIDE; ) const SAL_OVERRIDE;
// disambiguate IReference
virtual oslInterlockedCount SAL_CALL acquire() SAL_OVERRIDE;
virtual oslInterlockedCount SAL_CALL release() SAL_OVERRIDE;
}; };
......
...@@ -55,18 +55,6 @@ namespace connectivity ...@@ -55,18 +55,6 @@ namespace connectivity
} }
oslInterlockedCount SAL_CALL ODataAccessToolsFactory::acquire()
{
return ORefBase::acquire();
}
oslInterlockedCount SAL_CALL ODataAccessToolsFactory::release()
{
return ORefBase::release();
}
::rtl::Reference< simple::IDataAccessTypeConversion > ODataAccessToolsFactory::getTypeConversionHelper() ::rtl::Reference< simple::IDataAccessTypeConversion > ODataAccessToolsFactory::getTypeConversionHelper()
{ {
return m_xTypeConversionHelper; return m_xTypeConversionHelper;
......
...@@ -21,7 +21,6 @@ ...@@ -21,7 +21,6 @@
#define INCLUDED_CONNECTIVITY_SOURCE_SIMPLEDBT_DBTFACTORY_HXX #define INCLUDED_CONNECTIVITY_SOURCE_SIMPLEDBT_DBTFACTORY_HXX
#include <connectivity/virtualdbtools.hxx> #include <connectivity/virtualdbtools.hxx>
#include "refbase.hxx"
namespace connectivity namespace connectivity
...@@ -31,9 +30,7 @@ namespace connectivity ...@@ -31,9 +30,7 @@ namespace connectivity
//= ODataAccessToolsFactory //= ODataAccessToolsFactory
class ODataAccessToolsFactory class ODataAccessToolsFactory : public simple::IDataAccessToolsFactory
:public simple::IDataAccessToolsFactory
,public ORefBase
{ {
protected: protected:
::rtl::Reference< simple::IDataAccessTypeConversion > m_xTypeConversionHelper; ::rtl::Reference< simple::IDataAccessTypeConversion > m_xTypeConversionHelper;
...@@ -41,6 +38,7 @@ namespace connectivity ...@@ -41,6 +38,7 @@ namespace connectivity
public: public:
ODataAccessToolsFactory(); ODataAccessToolsFactory();
virtual ~ODataAccessToolsFactory() {}
// IDataAccessToolsFactory // IDataAccessToolsFactory
virtual ::rtl::Reference< simple::ISQLParser > createSQLParser( virtual ::rtl::Reference< simple::ISQLParser > createSQLParser(
...@@ -60,9 +58,6 @@ namespace connectivity ...@@ -60,9 +58,6 @@ namespace connectivity
const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxColumn const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxColumn
) SAL_OVERRIDE; ) SAL_OVERRIDE;
// IReference
virtual oslInterlockedCount SAL_CALL acquire() SAL_OVERRIDE;
virtual oslInterlockedCount SAL_CALL release() SAL_OVERRIDE;
}; };
......
...@@ -50,19 +50,6 @@ namespace connectivity ...@@ -50,19 +50,6 @@ namespace connectivity
delete m_pFullNode; delete m_pFullNode;
} }
oslInterlockedCount SAL_CALL OSimpleParseNode::acquire()
{
return ORefBase::acquire();
}
oslInterlockedCount SAL_CALL OSimpleParseNode::release()
{
return ORefBase::release();
}
void OSimpleParseNode::parseNodeToStr(OUString& _rString, const Reference< XConnection >& _rxConnection,const IParseContext* _pContext) const void OSimpleParseNode::parseNodeToStr(OUString& _rString, const Reference< XConnection >& _rxConnection,const IParseContext* _pContext) const
{ {
m_pFullNode->parseNodeToStr( _rString, _rxConnection, _pContext ); m_pFullNode->parseNodeToStr( _rString, _rxConnection, _pContext );
......
...@@ -21,7 +21,6 @@ ...@@ -21,7 +21,6 @@
#define INCLUDED_CONNECTIVITY_SOURCE_SIMPLEDBT_PARSENODE_S_HXX #define INCLUDED_CONNECTIVITY_SOURCE_SIMPLEDBT_PARSENODE_S_HXX
#include <connectivity/virtualdbtools.hxx> #include <connectivity/virtualdbtools.hxx>
#include "refbase.hxx"
namespace connectivity namespace connectivity
...@@ -32,9 +31,7 @@ namespace connectivity ...@@ -32,9 +31,7 @@ namespace connectivity
//= OSimpleParseNode //= OSimpleParseNode
class OSimpleParseNode class OSimpleParseNode : public simple::ISQLParseNode
:public simple::ISQLParseNode
,public ORefBase
{ {
protected: protected:
const OSQLParseNode* m_pFullNode; const OSQLParseNode* m_pFullNode;
...@@ -59,10 +56,6 @@ namespace connectivity ...@@ -59,10 +56,6 @@ namespace connectivity
const sal_Char _cDecSeparator, const sal_Char _cDecSeparator,
const IParseContext* _pContext const IParseContext* _pContext
) const SAL_OVERRIDE; ) const SAL_OVERRIDE;
// disambiguate IReference
virtual oslInterlockedCount SAL_CALL acquire() SAL_OVERRIDE;
virtual oslInterlockedCount SAL_CALL release() SAL_OVERRIDE;
}; };
......
...@@ -41,18 +41,6 @@ namespace connectivity ...@@ -41,18 +41,6 @@ namespace connectivity
} }
oslInterlockedCount SAL_CALL OSimpleSQLParser::acquire()
{
return ORefBase::acquire();
}
oslInterlockedCount SAL_CALL OSimpleSQLParser::release()
{
return ORefBase::release();
}
const IParseContext& OSimpleSQLParser::getContext() const const IParseContext& OSimpleSQLParser::getContext() const
{ {
return m_aFullParser.getContext(); return m_aFullParser.getContext();
......
...@@ -21,7 +21,6 @@ ...@@ -21,7 +21,6 @@
#define INCLUDED_CONNECTIVITY_SOURCE_SIMPLEDBT_PARSER_S_HXX #define INCLUDED_CONNECTIVITY_SOURCE_SIMPLEDBT_PARSER_S_HXX
#include <connectivity/virtualdbtools.hxx> #include <connectivity/virtualdbtools.hxx>
#include "refbase.hxx"
#include <connectivity/sqlparse.hxx> #include <connectivity/sqlparse.hxx>
...@@ -32,9 +31,7 @@ namespace connectivity ...@@ -32,9 +31,7 @@ namespace connectivity
//= OSimpleSQLParser //= OSimpleSQLParser
class OSimpleSQLParser class OSimpleSQLParser : public simple::ISQLParser
:public simple::ISQLParser
,public ORefBase
{ {
protected: protected:
OSQLParser m_aFullParser; OSQLParser m_aFullParser;
...@@ -51,10 +48,6 @@ namespace connectivity ...@@ -51,10 +48,6 @@ namespace connectivity
) const SAL_OVERRIDE; ) const SAL_OVERRIDE;
virtual const IParseContext& getContext() const SAL_OVERRIDE; virtual const IParseContext& getContext() const SAL_OVERRIDE;
// disambiguate IReference
virtual oslInterlockedCount SAL_CALL acquire() SAL_OVERRIDE;
virtual oslInterlockedCount SAL_CALL release() SAL_OVERRIDE;
}; };
......
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#include "refbase.hxx"
namespace connectivity
{
//= ORefBase
ORefBase::~ORefBase()
{
}
oslInterlockedCount SAL_CALL ORefBase::acquire()
{
return osl_atomic_increment(&m_refCount);
}
oslInterlockedCount SAL_CALL ORefBase::release()
{
oslInterlockedCount nNewRefCount = osl_atomic_decrement(&m_refCount);
if (0 == nNewRefCount)
delete this;
return nNewRefCount;
}
} // namespace connectivity
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#ifndef INCLUDED_CONNECTIVITY_SOURCE_SIMPLEDBT_REFBASE_HXX
#define INCLUDED_CONNECTIVITY_SOURCE_SIMPLEDBT_REFBASE_HXX
#include <rtl/ref.hxx>
namespace connectivity
{
//= ORefBase
/// base class for all objects implementing the ::rtl::IReference interface
class ORefBase : public ::rtl::IReference
{
protected:
oslInterlockedCount m_refCount;
protected:
ORefBase() : m_refCount(0) { }
virtual ~ORefBase();
virtual oslInterlockedCount SAL_CALL acquire() SAL_OVERRIDE;
virtual oslInterlockedCount SAL_CALL release() SAL_OVERRIDE;
};
} // namespace connectivity
#endif // INCLUDED_CONNECTIVITY_SOURCE_SIMPLEDBT_REFBASE_HXX
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
...@@ -71,18 +71,6 @@ namespace connectivity ...@@ -71,18 +71,6 @@ namespace connectivity
} }
oslInterlockedCount SAL_CALL ODataAccessStaticTools::acquire()
{
return ORefBase::acquire();
}
oslInterlockedCount SAL_CALL ODataAccessStaticTools::release()
{
return ORefBase::release();
}
Reference< XConnection> ODataAccessStaticTools::getConnection_withFeedback(const OUString& _rDataSourceName, const OUString& _rUser, Reference< XConnection> ODataAccessStaticTools::getConnection_withFeedback(const OUString& _rDataSourceName, const OUString& _rUser,
const OUString& _rPwd, const Reference< XComponentContext>& _rxContext) const const OUString& _rPwd, const Reference< XComponentContext>& _rxContext) const
{ {
......
...@@ -21,7 +21,6 @@ ...@@ -21,7 +21,6 @@
#define INCLUDED_CONNECTIVITY_SOURCE_SIMPLEDBT_STATICDBTOOLS_S_HXX #define INCLUDED_CONNECTIVITY_SOURCE_SIMPLEDBT_STATICDBTOOLS_S_HXX
#include <connectivity/virtualdbtools.hxx> #include <connectivity/virtualdbtools.hxx>
#include "refbase.hxx"
namespace connectivity namespace connectivity
...@@ -34,7 +33,6 @@ namespace connectivity ...@@ -34,7 +33,6 @@ namespace connectivity
class ODataAccessStaticTools class ODataAccessStaticTools
:public simple::IDataAccessTypeConversion :public simple::IDataAccessTypeConversion
,public simple::IDataAccessTools ,public simple::IDataAccessTools
,public ORefBase
{ {
public: public:
ODataAccessStaticTools(); ODataAccessStaticTools();
...@@ -181,11 +179,6 @@ namespace connectivity ...@@ -181,11 +179,6 @@ namespace connectivity
const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _rxComponent, const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _rxComponent,
::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _rxActualConnection ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _rxActualConnection
) SAL_OVERRIDE; ) SAL_OVERRIDE;
// disambiguate IReference
virtual oslInterlockedCount SAL_CALL acquire() SAL_OVERRIDE;
virtual oslInterlockedCount SAL_CALL release() SAL_OVERRIDE;
}; };
......
...@@ -32,6 +32,7 @@ ...@@ -32,6 +32,7 @@
#include <vector> #include <vector>
#include <memory> #include <memory>
#include <connectivity/dbtoolsdllapi.hxx> #include <connectivity/dbtoolsdllapi.hxx>
#include <salhelper/simplereferenceobject.hxx>
//= forward declarations //= forward declarations
...@@ -112,7 +113,7 @@ namespace connectivity ...@@ -112,7 +113,7 @@ namespace connectivity
//= IDataAccessTools //= IDataAccessTools
class OOO_DLLPUBLIC_DBTOOLS IDataAccessTools : public ::rtl::IReference class OOO_DLLPUBLIC_DBTOOLS IDataAccessTools : public virtual salhelper::SimpleReferenceObject
{ {
public: public:
virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection> getConnection_withFeedback( virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection> getConnection_withFeedback(
...@@ -219,7 +220,7 @@ namespace connectivity ...@@ -219,7 +220,7 @@ namespace connectivity
) = 0; ) = 0;
protected: protected:
~IDataAccessTools() {} virtual ~IDataAccessTools() {}
}; };
...@@ -228,7 +229,7 @@ namespace connectivity ...@@ -228,7 +229,7 @@ namespace connectivity
/** simple wrapper for the OCharsetMap /** simple wrapper for the OCharsetMap
*/ */
class OOO_DLLPUBLIC_DBTOOLS IDataAccessCharSet : class OOO_DLLPUBLIC_DBTOOLS IDataAccessCharSet :
public ::rtl::IReference public salhelper::SimpleReferenceObject
{ {
// to be extended if necessary .... // to be extended if necessary ....
public: public:
...@@ -240,14 +241,14 @@ namespace connectivity ...@@ -240,14 +241,14 @@ namespace connectivity
) const = 0; ) const = 0;
protected: protected:
~IDataAccessCharSet() {} virtual ~IDataAccessCharSet() {}
}; };
//= IDataAccessTypeConversion //= IDataAccessTypeConversion
class OOO_DLLPUBLIC_DBTOOLS IDataAccessTypeConversion : class OOO_DLLPUBLIC_DBTOOLS IDataAccessTypeConversion :
public ::rtl::IReference public virtual salhelper::SimpleReferenceObject
{ {
public: public:
virtual ::com::sun::star::util::Date getStandardDate() const = 0; virtual ::com::sun::star::util::Date getStandardDate() const = 0;
...@@ -271,7 +272,7 @@ namespace connectivity ...@@ -271,7 +272,7 @@ namespace connectivity
) const = 0; ) const = 0;
protected: protected:
~IDataAccessTypeConversion() {} virtual ~IDataAccessTypeConversion() {}
}; };
...@@ -279,7 +280,7 @@ namespace connectivity ...@@ -279,7 +280,7 @@ namespace connectivity
/** a simple version of the OSQLParseNode, with all methods being virtual /** a simple version of the OSQLParseNode, with all methods being virtual
*/ */
class OOO_DLLPUBLIC_DBTOOLS ISQLParseNode : public ::rtl::IReference class OOO_DLLPUBLIC_DBTOOLS ISQLParseNode : public salhelper::SimpleReferenceObject
{ {
public: public:
virtual void parseNodeToStr(OUString& _rString, virtual void parseNodeToStr(OUString& _rString,
...@@ -298,7 +299,7 @@ namespace connectivity ...@@ -298,7 +299,7 @@ namespace connectivity
) const = 0; ) const = 0;
protected: protected:
~ISQLParseNode() {} virtual ~ISQLParseNode() {}
}; };
...@@ -306,7 +307,7 @@ namespace connectivity ...@@ -306,7 +307,7 @@ namespace connectivity
/** a simple version of the OSQLParser, with all methods being virtual /** a simple version of the OSQLParser, with all methods being virtual
*/ */
class OOO_DLLPUBLIC_DBTOOLS ISQLParser : public ::rtl::IReference class OOO_DLLPUBLIC_DBTOOLS ISQLParser : public salhelper::SimpleReferenceObject
{ {
public: public:
virtual ::rtl::Reference< ISQLParseNode > predicateTree( virtual ::rtl::Reference< ISQLParseNode > predicateTree(
...@@ -319,7 +320,7 @@ namespace connectivity ...@@ -319,7 +320,7 @@ namespace connectivity
virtual const IParseContext& getContext() const = 0; virtual const IParseContext& getContext() const = 0;
protected: protected:
~ISQLParser() {} virtual ~ISQLParser() {}
}; };
...@@ -328,7 +329,7 @@ namespace connectivity ...@@ -328,7 +329,7 @@ namespace connectivity
/** the main factory for runtime-loadable tools in the DBTOOLS library /** the main factory for runtime-loadable tools in the DBTOOLS library
*/ */
class OOO_DLLPUBLIC_DBTOOLS IDataAccessToolsFactory : class OOO_DLLPUBLIC_DBTOOLS IDataAccessToolsFactory :
public ::rtl::IReference public salhelper::SimpleReferenceObject
{ {
public: public:
/// creates a simple version of the class OSQLParser /// creates a simple version of the class OSQLParser
...@@ -353,7 +354,7 @@ namespace connectivity ...@@ -353,7 +354,7 @@ namespace connectivity
) = 0; ) = 0;
protected: protected:
~IDataAccessToolsFactory() {} virtual ~IDataAccessToolsFactory() {}
}; };
......
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