diff options
author | Matthias Huetsch <mhu@openoffice.org> | 2001-03-13 20:18:01 +0000 |
---|---|---|
committer | Matthias Huetsch <mhu@openoffice.org> | 2001-03-13 20:18:01 +0000 |
commit | f3c12a6955a727c0fb613725702a33f70529c0b1 (patch) | |
tree | e51237e1660061c5e23c7ac55220796f7942c046 /store/workben | |
parent | 36fcfd6774bd9695ebe0a1264cbb790be2eba24a (diff) |
Major revision. Removed usage of module 'vos'.
Diffstat (limited to 'store/workben')
-rw-r--r-- | store/workben/makefile.mk | 15 | ||||
-rw-r--r-- | store/workben/t_base.cxx | 219 | ||||
-rw-r--r-- | store/workben/t_file.cxx | 37 | ||||
-rw-r--r-- | store/workben/t_store.cxx | 59 |
4 files changed, 250 insertions, 80 deletions
diff --git a/store/workben/makefile.mk b/store/workben/makefile.mk index 1d2965f9b..187997503 100644 --- a/store/workben/makefile.mk +++ b/store/workben/makefile.mk @@ -2,9 +2,9 @@ # # $RCSfile: makefile.mk,v $ # -# $Revision: 1.1.1.1 $ +# $Revision: 1.2 $ # -# last change: $Author: hr $ $Date: 2000-09-18 15:18:32 $ +# last change: $Author: mhu $ $Date: 2001-03-13 21:15:30 $ # # The Contents of this file are made available subject to the terms of # either of the following licenses @@ -54,7 +54,7 @@ # # All Rights Reserved. # -# Contributor(s): _______________________________________ +# Contributor(s): Matthias Huetsch <matthias.huetsch@sun.com> # # # @@ -105,28 +105,25 @@ OBJFILES= \ APP1TARGET= t_file APP1OBJS= $(OBJ)$/t_file.obj APP1STDLIBS= $(STODBGLIB) -APP1STDLIBS+= $(VOSLIB) $(SALLIB) +APP1STDLIBS+= $(SALLIB) APP1DEPN= \ $(STODBGLIB) \ - $(L)$/ivos.lib \ $(L)$/isal.lib APP2TARGET= t_base APP2OBJS= $(OBJ)$/t_base.obj APP2STDLIBS= $(STODBGLIB) -APP2STDLIBS+= $(VOSLIB) $(SALLIB) +APP2STDLIBS+= $(SALLIB) APP2DEPN= \ $(STODBGLIB) \ - $(L)$/ivos.lib \ $(L)$/isal.lib APP3TARGET= t_store APP3OBJS= $(OBJ)$/t_store.obj APP3STDLIBS= $(STORELIB) -APP3STDLIBS+= $(VOSLIB) $(SALLIB) +APP3STDLIBS+= $(SALLIB) APP3DEPN= \ $(SLB)$/store.lib \ - $(L)$/ivos.lib \ $(L)$/isal.lib # --- Targets --- diff --git a/store/workben/t_base.cxx b/store/workben/t_base.cxx index c2ebc9272..e0740ece2 100644 --- a/store/workben/t_base.cxx +++ b/store/workben/t_base.cxx @@ -2,9 +2,9 @@ * * $RCSfile: t_base.cxx,v $ * - * $Revision: 1.2 $ + * $Revision: 1.3 $ * - * last change: $Author: mhu $ $Date: 2001-02-26 14:21:41 $ + * last change: $Author: mhu $ $Date: 2001-03-13 21:15:30 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -59,7 +59,7 @@ * ************************************************************************/ -#define _T_BASE_CXX "$Revision: 1.2 $" +#define _T_BASE_CXX "$Revision: 1.3 $" #ifndef _SAL_TYPES_H_ #include <sal/types.h> @@ -75,12 +75,8 @@ #ifndef _RTL_USTRING_HXX_ #include <rtl/ustring.hxx> #endif - -#ifndef _VOS_MACROS_HXX_ -#include <vos/macros.hxx> -#endif -#ifndef _VOS_REF_HXX_ -#include <vos/ref.hxx> +#ifndef _RTL_REF_HXX_ +#include <rtl/ref.hxx> #endif #ifndef _STORE_FILELCKB_HXX_ @@ -91,20 +87,136 @@ #include "storbase.hxx" #endif -#ifdef _USE_NAMESPACE using namespace store; -#endif #define TEST_PAGESIZE 1024 /*======================================================================== * + * OTestDaemon. + * + *======================================================================*/ + +#if 1 /* EXP */ + +#include <osl/interlck.h> + +class OTestDaemon : public rtl::IReference +{ +public: + static sal_Bool getOrCreate ( + rtl::Reference<OTestDaemon> &rxDaemon); + + virtual oslInterlockedCount SAL_CALL acquire (void); + virtual oslInterlockedCount SAL_CALL release (void); + +protected: + OTestDaemon (void); + virtual ~OTestDaemon (void); + +private: + static OTestDaemon *m_pThis; + + oslInterlockedCount m_nRefCount; +}; + +#include <osl/mutex.hxx> + +OTestDaemon* OTestDaemon::m_pThis = 0; + +OTestDaemon::OTestDaemon (void) +{ +} + +OTestDaemon::~OTestDaemon (void) +{ +} + +sal_Bool OTestDaemon::getOrCreate (rtl::Reference<OTestDaemon> &rxDaemon) +{ + osl::MutexGuard aGuard (osl::Mutex::getGlobalMutex()); + + rxDaemon = m_pThis; + if (!rxDaemon.is()) + { + m_pThis = new OTestDaemon(); + rxDaemon = m_pThis; + } + return rxDaemon.is(); +} + +oslInterlockedCount SAL_CALL OTestDaemon::acquire (void) +{ + return osl_incrementInterlockedCount (&m_nRefCount); +} + +oslInterlockedCount SAL_CALL OTestDaemon::release (void) +{ + oslInterlockedCount result; + + result = osl_decrementInterlockedCount (&m_nRefCount); + if (result == 0) + { + osl::MutexGuard aGuard (osl::Mutex::getGlobalMutex()); + if (m_nRefCount == 0) + { + m_pThis = 0; + delete this; + } + } + return (result); +} + +#endif /* EXP */ + +/*======================================================================== + * + * OTestObject. + * + *======================================================================*/ +class OTestObject : public store::OStoreObject +{ +public: + OTestObject (void); + + virtual sal_Bool SAL_CALL isKindOf (sal_uInt32 nTypeId); + +protected: + virtual ~OTestObject (void); +}; + +OTestObject::OTestObject (void) +{ +} + +OTestObject::~OTestObject (void) +{ +} + +sal_Bool SAL_CALL OTestObject::isKindOf (sal_uInt32 nTypeId) +{ + return (nTypeId == 42); +} + +namespace store +{ +static OTestObject* SAL_CALL query (IStoreHandle *pHandle, OTestObject*) +{ + if (pHandle && pHandle->isKindOf (42)) + return static_cast<OTestObject*>(pHandle); + else + return 0; +} +} + +/*======================================================================== + * * OTestBIOS. * *======================================================================*/ -class OTestBIOS : public NAMESPACE_STORE(OStorePageBIOS) +class OTestBIOS : public store::OStorePageBIOS { - typedef NAMESPACE_STORE(OStorePageBIOS) base; + typedef store::OStorePageBIOS base; public: OTestBIOS (void); @@ -113,6 +225,8 @@ public: ILockBytes *pLockBytes, storeAccessMode eAccessMode); + virtual sal_Bool SAL_CALL isKindOf (sal_uInt32 nTypeId); + protected: virtual ~OTestBIOS (void); }; @@ -125,6 +239,11 @@ OTestBIOS::~OTestBIOS (void) { } +sal_Bool SAL_CALL OTestBIOS::isKindOf (sal_uInt32 nTypeId) +{ + return (nTypeId == 4242); +} + storeError OTestBIOS::initialize ( ILockBytes *pLockBytes, storeAccessMode eAccessMode) { @@ -143,6 +262,50 @@ storeError OTestBIOS::initialize ( return eErrCode; } +namespace store +{ +static OTestBIOS* SAL_CALL query (IStoreHandle *pHandle, OTestBIOS*) +{ + if (pHandle && pHandle->isKindOf (4242)) + return static_cast<OTestBIOS*>(pHandle); + else + return 0; +} +} + +/*======================================================================== + * + * __store_test_handle. + * + *======================================================================*/ +static void __store_test_handle (void* Handle) +{ + IStoreHandle *pHandle = static_cast<IStoreHandle*>(Handle); + if (pHandle) + { + pHandle->acquire(); + pHandle->isKindOf (42); + pHandle->release(); + } + + OTestObject *pObj = query (pHandle, static_cast<OTestObject*>(0)); + if (pObj) + { + pObj->acquire(); + pObj->isKindOf (42); + pObj->release(); + } + + store::OStoreHandle<OTestObject> xObj ( + store::OStoreHandle<OTestObject>::query (Handle)); + if (xObj.is()) + { + xObj->acquire(); + xObj->isKindOf (42); + xObj->release(); + } +} + /*======================================================================== * * unicode. @@ -173,9 +336,9 @@ static void __store_string_newFromUnicode ( } static storeError __store_namei ( - const NAMESPACE_RTL(OString) &rPath, - const NAMESPACE_RTL(OString) &rName, - OStorePageKey &rKey) + const rtl::OString &rPath, + const rtl::OString &rName, + OStorePageKey &rKey) { return store_E_Unknown; } @@ -185,9 +348,8 @@ static storeError __store_namei ( const sal_Unicode *pszName, OStorePageKey &rKey) { - NAMESPACE_RTL(OString) aName ( + rtl::OString aName ( pszName, rtl_ustr_getLength (pszName), RTL_TEXTENCODING_UTF8); - rtl_String *pszNameA = 0; __store_string_newFromUnicode (&pszNameA, pszName); @@ -305,11 +467,11 @@ int SAL_CALL main (int argc, char **argv) __store_testUnicode (argv[1]); #endif /* EXP */ - NAMESPACE_VOS(ORef)<OFileLockBytes> xLockBytes (new OFileLockBytes()); - if (!xLockBytes.isValid()) + rtl::Reference<OFileLockBytes> xLockBytes (new OFileLockBytes()); + if (!xLockBytes.is()) return 0; - NAMESPACE_RTL(OUString) aFilename ( + rtl::OUString aFilename ( argv[1], rtl_str_getLength(argv[1]), osl_getThreadTextEncoding()); @@ -318,8 +480,15 @@ int SAL_CALL main (int argc, char **argv) if (eErrCode != store_E_None) return eErrCode; - NAMESPACE_VOS(ORef)<OTestBIOS> xBIOS (new OTestBIOS()); - if (!xBIOS.isValid()) + + rtl::Reference<OTestObject> xObject (new OTestObject()); + __store_test_handle (&*xObject); + + rtl::Reference<OTestBIOS> xBIOS (new OTestBIOS()); + __store_test_handle (&*xBIOS); + + + if (!xBIOS.is()) return 0; eErrCode = xBIOS->initialize (&*xLockBytes, store_AccessReadWrite); @@ -334,7 +503,7 @@ int SAL_CALL main (int argc, char **argv) if (eErrCode != store_E_None) return eErrCode; } - xLockBytes.unbind(); + xLockBytes.clear(); sal_Char pBuffer[TEST_PAGESIZE]; rtl_zeroMemory (pBuffer, sizeof (pBuffer)); @@ -355,7 +524,7 @@ int SAL_CALL main (int argc, char **argv) if (eErrCode != store_E_None) return eErrCode; - xBIOS.unbind(); + xBIOS.clear(); return 0; } diff --git a/store/workben/t_file.cxx b/store/workben/t_file.cxx index a1c9cba1d..6705dbb11 100644 --- a/store/workben/t_file.cxx +++ b/store/workben/t_file.cxx @@ -2,9 +2,9 @@ * * $RCSfile: t_file.cxx,v $ * - * $Revision: 1.2 $ + * $Revision: 1.3 $ * - * last change: $Author: mhu $ $Date: 2001-02-26 14:21:41 $ + * last change: $Author: mhu $ $Date: 2001-03-13 21:15:30 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -59,12 +59,15 @@ * ************************************************************************/ -#define _T_FILE_CXX "$Revision: 1.2 $" +#define _T_FILE_CXX "$Revision: 1.3 $" #ifndef _SAL_TYPES_H_ #include <sal/types.h> #endif +#ifndef _OSL_FILE_H_ +#include <osl/file.h> +#endif #ifndef _OSL_THREAD_H_ #include <osl/thread.h> #endif @@ -72,21 +75,15 @@ #ifndef _RTL_USTRING_HXX_ #include <rtl/ustring.hxx> #endif - -#ifndef _VOS_MACROS_HXX_ -#include <vos/macros.hxx> -#endif -#ifndef _VOS_REF_HXX_ -#include <vos/ref.hxx> +#ifndef _RTL_REF_HXX_ +#include <rtl/ref.hxx> #endif #ifndef _STORE_FILELCKB_HXX_ #include <store/filelckb.hxx> #endif -#ifdef _USE_NAMESPACE using namespace store; -#endif /*======================================================================== * @@ -98,14 +95,24 @@ int SAL_CALL main (int argc, char **argv) if (argc < 2) return 0; - NAMESPACE_VOS(ORef)<OFileLockBytes> xLockBytes (new OFileLockBytes()); - if (!xLockBytes.isValid()) + rtl::Reference<OFileLockBytes> xLockBytes (new OFileLockBytes()); + if (!xLockBytes.is()) return 0; - NAMESPACE_RTL(OUString) aFilename ( + rtl::OUString aFilename ( argv[1], rtl_str_getLength(argv[1]), osl_getThreadTextEncoding()); +#if 0 /* EXP */ + + rtl::OUString aNormPath; + osl_searchNormalizedPath (aFilename.pData, 0, &(aNormPath.pData)); + + rtl::OUString aSysPath; + osl_getSystemPathFromNormalizedPath (aNormPath.pData, &(aSysPath.pData)); + +#endif /* EXP */ + storeError eErrCode = xLockBytes->create ( aFilename.pData, store_AccessReadWrite); if (eErrCode != store_E_None) @@ -144,7 +151,7 @@ int SAL_CALL main (int argc, char **argv) if (eErrCode != store_E_None) return eErrCode; - xLockBytes.unbind(); + xLockBytes.clear(); return 0; } diff --git a/store/workben/t_store.cxx b/store/workben/t_store.cxx index 25dee3f7e..d4ac93423 100644 --- a/store/workben/t_store.cxx +++ b/store/workben/t_store.cxx @@ -2,9 +2,9 @@ * * $RCSfile: t_store.cxx,v $ * - * $Revision: 1.2 $ + * $Revision: 1.3 $ * - * last change: $Author: mhu $ $Date: 2001-02-26 14:21:41 $ + * last change: $Author: mhu $ $Date: 2001-03-13 21:15:30 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -59,18 +59,21 @@ * ************************************************************************/ -#define _T_STORE_CXX "$Revision: 1.2 $" +#define _T_STORE_CXX "$Revision: 1.3 $" #ifndef _SAL_TYPES_H_ #include <sal/types.h> #endif -#ifndef _OSL_TIME_H_ -#include <osl/time.h> +#ifndef _OSL_DIAGNOSE_H_ +#include <osl/diagnose.h> #endif #ifndef _OSL_THREAD_H_ #include <osl/thread.h> #endif +#ifndef _OSL_TIME_H_ +#include <osl/time.h> +#endif #ifndef _RTL_CHAR_H_ #include <rtl/char.h> @@ -79,16 +82,6 @@ #include <rtl/ustring.hxx> #endif -#ifndef _VOS_DIAGNOSE_HXX_ -#include <vos/diagnose.hxx> -#endif -#ifndef _VOS_THREAD_HXX_ -#include <vos/thread.hxx> -#endif - -#ifndef _STORE_MACROS_HXX_ -#include <store/macros.hxx> -#endif #ifndef _STORE_STORE_HXX_ #include <store/store.hxx> #endif @@ -179,15 +172,15 @@ struct OTime : public TimeValue * DirectoryTraveller. * *======================================================================*/ -typedef NAMESPACE_STORE(OStoreDirectory) Directory; +typedef store::OStoreDirectory Directory; class DirectoryTraveller : public Directory::traveller { - typedef NAMESPACE_STORE(OStoreFile) file; - typedef Directory::iterator iter; + typedef store::OStoreFile file; + typedef Directory::iterator iter; - NAMESPACE_STORE(OStoreFile) m_aFile; - OUString m_aPath; + store::OStoreFile m_aFile; + OUString m_aPath; sal_uInt32 m_nOptions; sal_uInt32 m_nLevel; @@ -248,6 +241,10 @@ sal_Bool DirectoryTraveller::visit (const iter& it) if (it.m_nAttrib & STORE_ATTRIB_ISDIR) { OUString aName (it.m_pszName, it.m_nLength); + if (aName.compareToAscii ("XTextViewCursorSupplier") == 0) + { + m_nCount += 1 - 1; + } Directory aSubDir; storeError eErrCode = aSubDir.create ( @@ -278,7 +275,7 @@ int SAL_CALL main (int argc, char **argv) OTime aStartTime (OTime::getSystemTime()); #endif /* PROFILE */ - NAMESPACE_STORE(OStoreFile) aFile; + store::OStoreFile aFile; storeError eErrCode = store_E_None; sal_uInt32 nOptions = 0; @@ -402,7 +399,7 @@ int SAL_CALL main (int argc, char **argv) break; #endif /* _REMOVE */ - NAMESPACE_STORE(OStoreStream) aStream; + store::OStoreStream aStream; eErrCode = aStream.create (aFile, aPath, aName, eMode); if (eErrCode != store_E_None) break; @@ -471,7 +468,7 @@ int SAL_CALL main (int argc, char **argv) eErrCode = aFile.symlink ( aPath, OUString::createFromAscii("000000/"), OUString(), aPath); - VOS_POSTCOND( + OSL_POSTCOND( ((eErrCode == store_E_None ) || (eErrCode == store_E_AlreadyExists) ), "t_store::main(): store_symlink() failed"); @@ -482,7 +479,7 @@ int SAL_CALL main (int argc, char **argv) eErrCode = aFile.symlink ( aPath, aLinkName, aPath, OUString::createFromAscii("demostor-1.dat")); - VOS_POSTCOND( + OSL_POSTCOND( ((eErrCode == store_E_None ) || (eErrCode == store_E_AlreadyExists) ), "t_store::main(): store_symlink() failed"); @@ -494,7 +491,7 @@ int SAL_CALL main (int argc, char **argv) eErrCode = aFile.rename ( aPath, aLinkName, aPath, aShortcut); - VOS_POSTCOND( + OSL_POSTCOND( ((eErrCode == store_E_None ) || (eErrCode == store_E_AlreadyExists) ), "t_store::main(): store_rename() failed"); @@ -502,11 +499,11 @@ int SAL_CALL main (int argc, char **argv) // Create directory. OUString aDirName (RTL_CONSTASCII_USTRINGPARAM("demostor-1.dir")); - NAMESPACE_STORE(OStoreDirectory) aDir; + store::OStoreDirectory aDir; eErrCode = aDir.create ( aFile, aPath, aDirName, store_AccessReadCreate); - VOS_POSTCOND( + OSL_POSTCOND( (eErrCode == store_E_None), "t_store::main(): store_createDirectory() failed"); if (eErrCode == store_E_None) @@ -516,7 +513,7 @@ int SAL_CALL main (int argc, char **argv) eErrCode = aFile.rename ( aPath, "demostor-1.dir/", aPath, "Renamed demostor-1.dir"); - VOS_POSTCOND( + OSL_POSTCOND( ((eErrCode == store_E_None ) || (eErrCode == store_E_AlreadyExists) ), "t_store::main(): store_rename() failed"); @@ -524,7 +521,7 @@ int SAL_CALL main (int argc, char **argv) eErrCode = aFile.rename ( aPath, "Renamed demostor-1.dir/", aPath, "demostor-1.dir"); - VOS_POSTCOND( + OSL_POSTCOND( (eErrCode == store_E_None), "t_store::main(): store_rename() failed"); #endif /* NYI */ @@ -540,7 +537,7 @@ int SAL_CALL main (int argc, char **argv) OUString aEmpty; // Root directory. - NAMESPACE_STORE(OStoreDirectory) aRootDir; + store::OStoreDirectory aRootDir; if (nOptions & OPTION_LINK) { // Open symlink entry. @@ -590,7 +587,7 @@ int SAL_CALL main (int argc, char **argv) TimeValue tv; tv.Seconds = 300; tv.Nanosec = 0; - NAMESPACE_VOS(OThread)::wait (tv); + osl_waitThread (&tv); } // Size. |