Kaydet (Commit) 67e69a55 authored tarafından Stephan Bergmann's avatar Stephan Bergmann

Revert "WIP: Experimental new binary type.rdb format"

This reverts commit 892ef8b0,
Windows-only cli_ure needs to be adapted first.
üst 157ce655
......@@ -75,7 +75,7 @@ $(eval $(call gb_Library_add_exception_objects,cppuhelper,\
cppuhelper/source/shlib \
cppuhelper/source/supportsservice \
cppuhelper/source/tdmgr \
cppuhelper/source/typemanager \
cppuhelper/source/typedescriptionprovider \
cppuhelper/source/typeprovider \
cppuhelper/source/unourl \
cppuhelper/source/weak \
......
......@@ -32,6 +32,8 @@
#include <cassert>
#include <vector>
#include "com/sun/star/container/XHierarchicalNameAccess.hpp"
#include "com/sun/star/container/XSet.hpp"
#include "com/sun/star/uno/DeploymentException.hpp"
#include "com/sun/star/uno/Any.hxx"
#include "com/sun/star/uno/Reference.hxx"
......@@ -45,7 +47,7 @@
#include "macro_expander.hxx"
#include "paths.hxx"
#include "servicemanager.hxx"
#include "typemanager.hxx"
#include "typedescriptionprovider.hxx"
namespace {
......@@ -76,9 +78,6 @@ cppu::defaultBootstrap_InitialComponentContext(rtl::OUString const & iniUri)
rtl::Reference< cppuhelper::ServiceManager > smgr(
new cppuhelper::ServiceManager(
getBootstrapVariable(bs, "UNO_SERVICES")));
rtl::Reference< cppuhelper::TypeManager > tmgr(
new cppuhelper::TypeManager(
getBootstrapVariable(bs, "UNO_TYPES")));
cppu::ContextEntry_Init entry;
std::vector< cppu::ContextEntry_Init > context_values;
context_values.push_back(
......@@ -88,13 +87,6 @@ cppu::defaultBootstrap_InitialComponentContext(rtl::OUString const & iniUri)
css::uno::Reference< css::uno::XInterface >(
static_cast< cppu::OWeakObject * >(smgr.get()))),
false));
context_values.push_back(
cppu::ContextEntry_Init(
"/singletons/com.sun.star.reflection.theTypeDescriptionManager",
css::uno::makeAny(
css::uno::Reference< css::uno::XInterface >(
static_cast< cppu::OWeakObject * >(tmgr.get()))),
false));
context_values.push_back( //TODO: from services.rdb?
cppu::ContextEntry_Init(
"/singletons/com.sun.star.util.theMacroExpander",
......@@ -118,7 +110,18 @@ cppu::defaultBootstrap_InitialComponentContext(rtl::OUString const & iniUri)
&context_values[0], context_values.size(),
css::uno::Reference< css::uno::XComponentContext >()));
smgr->setContext(context);
cppu::installTypeDescriptionManager(tmgr.get());
css::uno::Reference< css::container::XHierarchicalNameAccess > tdmgr(
context->getValueByName(
"/singletons/com.sun.star.reflection.theTypeDescriptionManager"),
css::uno::UNO_QUERY_THROW);
css::uno::Reference< css::container::XSet >(
tdmgr, css::uno::UNO_QUERY_THROW)->
insert(
css::uno::makeAny(
cppuhelper::createTypeDescriptionProviders(
getBootstrapVariable(bs, "UNO_TYPES"), smgr.get(),
context)));
cppu::installTypeDescriptionManager(tdmgr);
return context;
}
......
/* -*- 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/.
*/
#ifndef INCLUDED_CPPUHELPER_SOURCE_TYPEDESCRIPTIONPROVIDER_HXX
#define INCLUDED_CPPUHELPER_SOURCE_TYPEDESCRIPTIONPROVIDER_HXX
#include "sal/config.h"
#include "com/sun/star/uno/Reference.hxx"
#include "com/sun/star/uno/Sequence.hxx"
namespace com { namespace sun { namespace star {
namespace container { class XHierarchicalNameAccess; }
namespace lang { class XMultiComponentFactory; }
namespace uno { class XComponentContext; }
} } }
namespace rtl { class OUString; }
namespace cppuhelper {
css::uno::Sequence<
css::uno::Reference< css::container::XHierarchicalNameAccess > >
createTypeDescriptionProviders(
rtl::OUString const & uris,
css::uno::Reference< css::lang::XMultiComponentFactory > const &
serviceManager,
css::uno::Reference< css::uno::XComponentContext > const & context);
}
#endif
/* 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/.
*/
#ifndef INCLUDED_CPPUHELPER_SOURCE_TYPEMANAGER_HXX
#define INCLUDED_CPPUHELPER_SOURCE_TYPEMANAGER_HXX
#include "sal/config.h"
#include "com/sun/star/container/ElementExistException.hpp"
#include "com/sun/star/container/NoSuchElementException.hpp"
#include "com/sun/star/container/XHierarchicalNameAccess.hpp"
#include "com/sun/star/container/XSet.hpp"
#include "com/sun/star/lang/IllegalArgumentException.hpp"
#include "com/sun/star/lang/XServiceInfo.hpp"
#include "com/sun/star/reflection/InvalidTypeNameException.hpp"
#include "com/sun/star/reflection/NoSuchTypeNameException.hpp"
#include "com/sun/star/reflection/TypeDescriptionSearchDepth.hpp"
#include "com/sun/star/reflection/XTypeDescriptionEnumerationAccess.hpp"
#include "com/sun/star/uno/Reference.hxx"
#include "com/sun/star/uno/RuntimeException.hpp"
#include "com/sun/star/uno/Sequence.hxx"
#include "cppuhelper/compbase4.hxx"
#include "osl/mutex.hxx"
#include "rtl/ref.hxx"
#include "sal/types.h"
namespace com { namespace sun { namespace star {
namespace uno { class Any; }
namespace reflection { class XTypeDescription; }
} } }
namespace rtl { class OUString; }
namespace unoidl {
class ConstantGroupEntity;
class Entity;
class EnumTypeEntity;
class Manager;
}
namespace cppuhelper {
typedef cppu::WeakComponentImplHelper4<
css::lang::XServiceInfo, css::container::XHierarchicalNameAccess,
css::container::XSet, css::reflection::XTypeDescriptionEnumerationAccess >
TypeManager_Base;
class TypeManager: private osl::Mutex, public TypeManager_Base {
public:
explicit TypeManager(rtl::OUString const & rdbUris);
using TypeManager_Base::acquire;
using TypeManager_Base::release;
css::uno::Any find(rtl::OUString const & name);
css::uno::Reference< css::reflection::XTypeDescription > resolve(
rtl::OUString const & name);
private:
virtual ~TypeManager() throw ();
virtual void SAL_CALL disposing();
virtual rtl::OUString SAL_CALL getImplementationName()
throw (css::uno::RuntimeException);
virtual sal_Bool SAL_CALL supportsService(rtl::OUString const & ServiceName)
throw (css::uno::RuntimeException);
virtual css::uno::Sequence< rtl::OUString > SAL_CALL
getSupportedServiceNames() throw (css::uno::RuntimeException);
virtual css::uno::Any SAL_CALL getByHierarchicalName(
rtl::OUString const & aName)
throw (
css::container::NoSuchElementException, css::uno::RuntimeException);
virtual sal_Bool SAL_CALL hasByHierarchicalName(rtl::OUString const & aName)
throw (css::uno::RuntimeException);
virtual css::uno::Type SAL_CALL getElementType()
throw (css::uno::RuntimeException);
virtual sal_Bool SAL_CALL hasElements() throw (css::uno::RuntimeException);
virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL
createEnumeration() throw (css::uno::RuntimeException);
virtual sal_Bool SAL_CALL has(css::uno::Any const & aElement)
throw (css::uno::RuntimeException);
virtual void SAL_CALL insert(css::uno::Any const & aElement)
throw (
css::lang::IllegalArgumentException,
css::container::ElementExistException, css::uno::RuntimeException);
virtual void SAL_CALL remove(css::uno::Any const & aElement)
throw (
css::lang::IllegalArgumentException,
css::container::NoSuchElementException, css::uno::RuntimeException);
virtual css::uno::Reference< css::reflection::XTypeDescriptionEnumeration >
SAL_CALL createTypeDescriptionEnumeration(
rtl::OUString const & moduleName,
css::uno::Sequence< css::uno::TypeClass > const & types,
css::reflection::TypeDescriptionSearchDepth depth)
throw (
css::reflection::NoSuchTypeNameException,
css::reflection::InvalidTypeNameException,
css::uno::RuntimeException);
void readRdbs(rtl::OUString const & uris);
void readRdbDirectory(rtl::OUString const & uri, bool optional);
void readRdbFile(rtl::OUString const & uri, bool optional);
css::uno::Any getSequenceType(rtl::OUString const & name);
css::uno::Any getInstantiatedStruct(
rtl::OUString const & name, sal_Int32 separator);
css::uno::Any getInterfaceMember(
rtl::OUString const & name, sal_Int32 separator);
css::uno::Any getNamed(
rtl::OUString const & name, rtl::Reference< unoidl::Entity > entity);
css::uno::Any getEnumMember(
rtl::Reference< unoidl::EnumTypeEntity > entity,
rtl::OUString const & member);
css::uno::Any getConstant(
rtl::Reference< unoidl::ConstantGroupEntity > entity,
rtl::OUString const & member);
rtl::Reference< unoidl::Entity > findEntity(rtl::OUString const & name);
rtl::Reference< unoidl::Manager > manager_;
};
}
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
......@@ -35,6 +35,7 @@
#include "svl/inettype.hxx"
#include "com/sun/star/lang/WrappedTargetRuntimeException.hpp"
#include "com/sun/star/container/XNameContainer.hpp"
#include "com/sun/star/container/XHierarchicalNameAccess.hpp"
#include "com/sun/star/container/XSet.hpp"
#include "com/sun/star/registry/XSimpleRegistry.hpp"
#include "com/sun/star/registry/XImplementationRegistration.hpp"
......@@ -183,6 +184,7 @@ class BackendImpl : public ::dp_registry::backend::PackageRegistryBackend
BackendImpl * getMyBackend() const;
const bool m_jarFile;
Reference<container::XHierarchicalNameAccess> m_xTDprov;
virtual void SAL_CALL disposing();
......@@ -399,6 +401,7 @@ void BackendImpl::ComponentPackageImpl::disposing()
//______________________________________________________________________________
void BackendImpl::TypelibraryPackageImpl::disposing()
{
m_xTDprov.clear();
Package::disposing();
}
......@@ -1530,12 +1533,37 @@ void BackendImpl::TypelibraryPackageImpl::processPackage_(
}
else // RDB:
{
css::uno::Reference< css::container::XSet >(
that->getComponentContext()->getValueByName(
"/singletons"
"/com.sun.star.reflection.theTypeDescriptionManager"),
css::uno::UNO_QUERY_THROW)->insert(
css::uno::makeAny(expandUnoRcUrl(url)));
Reference<XComponentContext> const & xContext =
that->getComponentContext();
if (! m_xTDprov.is())
{
m_xTDprov.set( that->getObject( url ), UNO_QUERY );
if (! m_xTDprov.is())
{
const Reference<registry::XSimpleRegistry> xReg(
xContext->getServiceManager()
->createInstanceWithContext("com.sun.star.registry.SimpleRegistry",
xContext ), UNO_QUERY_THROW );
xReg->open( expandUnoRcUrl(url),
true /* read-only */, false /* ! create */ );
const Any arg(xReg);
Reference<container::XHierarchicalNameAccess> xTDprov(
xContext->getServiceManager()
->createInstanceWithArgumentsAndContext(
"com.sun.star.comp.stoc.RegistryTypeDescriptionProvider",
Sequence<Any>( &arg, 1 ), xContext ), UNO_QUERY );
OSL_ASSERT( xTDprov.is() );
if (xTDprov.is())
m_xTDprov.set( that->insertObject( url, xTDprov ),
UNO_QUERY_THROW );
}
}
if (m_xTDprov.is()) {
Reference<container::XSet> xSet(
xContext->getValueByName( "/singletons/com.sun.star.reflection.theTypeDescriptionManager" ),
UNO_QUERY_THROW );
xSet->insert( Any(m_xTDprov) );
}
}
that->addToUnoRc( m_jarFile ? RCITEM_JAR_TYPELIB : RCITEM_RDB_TYPELIB,
......@@ -1547,13 +1575,18 @@ void BackendImpl::TypelibraryPackageImpl::processPackage_(
m_jarFile ? RCITEM_JAR_TYPELIB : RCITEM_RDB_TYPELIB, url, xCmdEnv );
// revoking types at runtime, possible, sensible?
if (!m_jarFile) {
css::uno::Reference< css::container::XSet >(
if (!m_xTDprov.is())
m_xTDprov.set( that->getObject( url ), UNO_QUERY );
if (m_xTDprov.is()) {
// remove live:
const Reference<container::XSet> xSet(
that->getComponentContext()->getValueByName(
"/singletons"
"/com.sun.star.reflection.theTypeDescriptionManager"),
css::uno::UNO_QUERY_THROW)->remove(
css::uno::makeAny(expandUnoRcUrl(url)));
"/singletons/com.sun.star.reflection.theTypeDescriptionManager" ),
UNO_QUERY_THROW );
xSet->remove( Any(m_xTDprov) );
that->releaseObject( url );
m_xTDprov.clear();
}
}
}
......
......@@ -85,6 +85,9 @@ $(eval $(call gb_Library_add_exception_objects,bootstrap,\
stoc/source/security/permissions \
stoc/source/servicemanager/servicemanager \
stoc/source/simpleregistry/simpleregistry \
stoc/source/tdmanager/tdmgr \
stoc/source/tdmanager/tdmgr_check \
stoc/source/tdmanager/tdmgr_tdenumeration \
))
# vim:set noet sw=4 ts=4:
......@@ -91,6 +91,13 @@ namespace stoc_bootstrap
throw(::com::sun::star::uno::Exception);
::com::sun::star::uno::Sequence< ::rtl::OUString > rdbtdp_getSupportedServiceNames();
::rtl::OUString rdbtdp_getImplementationName();
//tdmanager
::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL ManagerImpl_create(
const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& )
SAL_THROW( (::com::sun::star::uno::Exception) );
::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL tdmgr_getSupportedServiceNames();
::rtl::OUString SAL_CALL tdmgr_getImplementationName();
} // namespace
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
......@@ -96,6 +96,12 @@ static struct ImplementationEntry g_entries[] =
rdbtdp_getSupportedServiceNames, createSingleComponentFactory,
&g_moduleCount.modCnt , 0
},
//tdmanager
{
ManagerImpl_create, tdmgr_getImplementationName,
tdmgr_getSupportedServiceNames, createSingleComponentFactory,
&g_moduleCount.modCnt , 0
},
//end
{ 0, 0, 0, 0, 0, 0 }
};
......
/* -*- 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 _LRU_CACHE_HXX_
#define _LRU_CACHE_HXX_
// __CACHE_DIAGNOSE forces cache size to 4 and works only for OUString keys
// #define __CACHE_DIAGNOSE 1
#include <osl/mutex.hxx>
#include "rtl/ustring.hxx"
#include "sal/log.hxx"
#include <boost/unordered_map.hpp>
/** Implementation of a least recently used (lru) cache.
<br>
@author Daniel Boelzle
*/
template< class t_Key, class t_Val, class t_KeyHash, class t_KeyEqual >
class LRU_Cache
{
struct CacheEntry
{
t_Key aKey;
t_Val aVal;
CacheEntry * pPred;
CacheEntry * pSucc;
};
typedef ::boost::unordered_map< t_Key, CacheEntry *, t_KeyHash, t_KeyEqual > t_Key2Element;
mutable ::osl::Mutex _aCacheMutex;
sal_Int32 _nCachedElements;
t_Key2Element _aKey2Element;
CacheEntry * _pBlock;
mutable CacheEntry * _pHead;
mutable CacheEntry * _pTail;
inline void toFront( CacheEntry * pEntry ) const;
public:
/** Constructor:
<br>
@param nCachedElements number of elements to be cached; default param set to 128
*/
inline LRU_Cache( sal_Int32 nCachedElements = 128 );
/** Destructor: releases all cached elements and keys.
<br>
*/
inline ~LRU_Cache();
/** Retrieves a value from the cache. Returns default constructed value,
if none was found.
<br>
@param rKey a key
@return value
*/
inline t_Val getValue( t_Key const & rKey ) const;
/** Sets a value to be cached for given key.
<br>
@param rKey a key
@param rValue a value
*/
inline void setValue( t_Key const & rKey, t_Val const & rValue );
/** Tests whether a value is cached for given key.
<br>
@param rKey a key
@return true, if value is cached
*/
inline sal_Bool hasValue( t_Key const & rKey ) const;
/** Clears the cache, thus releasing all cached elements and keys.
<br>
*/
inline void clear();
};
//__________________________________________________________________________________________________
template< class t_Key, class t_Val, class t_KeyHash, class t_KeyEqual >
inline LRU_Cache< t_Key, t_Val, t_KeyHash, t_KeyEqual >::LRU_Cache( sal_Int32 nCachedElements )
#ifdef __CACHE_DIAGNOSE
: _nCachedElements( 4 )
#else
: _nCachedElements( nCachedElements )
#endif
, _pBlock( 0 )
{
if (_nCachedElements > 0)
{
_pBlock = new CacheEntry[_nCachedElements];
_pHead = _pBlock;
_pTail = _pBlock + _nCachedElements -1;
for ( sal_Int32 nPos = _nCachedElements; nPos--; )
{
_pBlock[nPos].pPred = _pBlock + nPos -1;
_pBlock[nPos].pSucc = _pBlock + nPos +1;
}
}
}
//__________________________________________________________________________________________________
template< class t_Key, class t_Val, class t_KeyHash, class t_KeyEqual >
inline LRU_Cache< t_Key, t_Val, t_KeyHash, t_KeyEqual >::~LRU_Cache()
{
delete [] _pBlock;
}
//__________________________________________________________________________________________________
template< class t_Key, class t_Val, class t_KeyHash, class t_KeyEqual >
inline void LRU_Cache< t_Key, t_Val, t_KeyHash, t_KeyEqual >::toFront(
CacheEntry * pEntry ) const
{
if (pEntry != _pHead)
{
// cut out element
if (pEntry == _pTail)
{
_pTail = pEntry->pPred;
}
else
{
pEntry->pSucc->pPred = pEntry->pPred;
pEntry->pPred->pSucc = pEntry->pSucc;
}
// push to front
_pHead->pPred = pEntry;
pEntry->pSucc = _pHead;
_pHead = pEntry;
}
}
//__________________________________________________________________________________________________
template< class t_Key, class t_Val, class t_KeyHash, class t_KeyEqual >
inline sal_Bool LRU_Cache< t_Key, t_Val, t_KeyHash, t_KeyEqual >::hasValue(
t_Key const & rKey ) const
{
::osl::MutexGuard aGuard( _aCacheMutex );
typename t_Key2Element::const_iterator const iFind( _aKey2Element.find( rKey ) );
return (iFind != _aKey2Element.end());
}
//__________________________________________________________________________________________________
template< class t_Key, class t_Val, class t_KeyHash, class t_KeyEqual >
inline t_Val LRU_Cache< t_Key, t_Val, t_KeyHash, t_KeyEqual >::getValue(
t_Key const & rKey ) const
{
::osl::MutexGuard aGuard( _aCacheMutex );
const typename t_Key2Element::const_iterator iFind( _aKey2Element.find( rKey ) );
if (iFind != _aKey2Element.end())
{
CacheEntry * pEntry = (*iFind).second;
toFront( pEntry );
#ifdef __CACHE_DIAGNOSE
SAL_INFO("stoc.tdmanager", "> retrieved element \"" );
SAL_INFO("stoc.tdmanager", "" << pEntry->aKey);
SAL_INFO("stoc.tdmanager", "\" from cache <" );
#endif
return pEntry->aVal;
}
return t_Val();
}
//__________________________________________________________________________________________________
template< class t_Key, class t_Val, class t_KeyHash, class t_KeyEqual >
inline void LRU_Cache< t_Key, t_Val, t_KeyHash, t_KeyEqual >::setValue(
t_Key const & rKey, t_Val const & rValue )
{
if (_nCachedElements > 0)
{
::osl::MutexGuard aGuard( _aCacheMutex );
typename t_Key2Element::const_iterator const iFind( _aKey2Element.find( rKey ) );
CacheEntry * pEntry;
if (iFind == _aKey2Element.end())
{
pEntry = _pTail; // erase last element
#ifdef __CACHE_DIAGNOSE
if (pEntry->aKey.getLength())
{
SAL_INFO("stoc.tdmanager", "> kicking element \"" );
SAL_INFO("stoc.tdmanager", "" << pEntry->aKey);
SAL_INFO("stoc.tdmanager", "\" from cache <" );
}
#endif
_aKey2Element.erase( pEntry->aKey );
_aKey2Element[ pEntry->aKey = rKey ] = pEntry;
}
else
{
pEntry = (*iFind).second;
#ifdef __CACHE_DIAGNOSE
SAL_INFO("stoc.tdmanager", "> replacing element \"" );
SAL_INFO("stoc.tdmanager", "" << pEntry->aKey);
SAL_INFO("stoc.tdmanager", "\" in cache <" );
#endif
}
pEntry->aVal = rValue;
toFront( pEntry );
}
}
//__________________________________________________________________________________________________
template< class t_Key, class t_Val, class t_KeyHash, class t_KeyEqual >
inline void LRU_Cache< t_Key, t_Val, t_KeyHash, t_KeyEqual >::clear()
{
::osl::MutexGuard aGuard( _aCacheMutex );
_aKey2Element.clear();
for ( sal_Int32 nPos = _nCachedElements; nPos--; )
{
_pBlock[nPos].aKey = t_Key();
_pBlock[nPos].aVal = t_Val();
}
#ifdef __CACHE_DIAGNOSE
SAL_INFO("stoc.tdmanager", "> cleared cache <" );
#endif
}
//==================================================================================================
struct FctHashOUString : public ::std::unary_function< ::rtl::OUString const &, size_t >
{
size_t operator()( ::rtl::OUString const & rKey ) const
{ return (size_t)rKey.hashCode(); }
};
/** Template instance for OUString keys, Any values.<br>
*/
typedef LRU_Cache< ::rtl::OUString, ::com::sun::star::uno::Any,
FctHashOUString, ::std::equal_to< ::rtl::OUString > >
LRU_CacheAnyByOUString;
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
This diff is collapsed.
/* -*- 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 _STOC_TDMGR_COMMON_HXX
#define _STOC_TDMGR_COMMON_HXX
#include <rtl/unload.h>
#include "com/sun/star/reflection/XTypeDescription.hpp"
#define ARLEN(x) (sizeof (x) / sizeof *(x))
namespace stoc_tdmgr
{
extern rtl_StandardModuleCount g_moduleCount;
struct IncompatibleTypeException
{
::rtl::OUString m_cause;
IncompatibleTypeException( ::rtl::OUString const & cause )
: m_cause( cause ) {}
};
void check(
css::uno::Reference<css::reflection::XTypeDescription> const & xNewTD,
css::uno::Reference<css::reflection::XTypeDescription> const & xExistingTD,
::rtl::OUString const & context = ::rtl::OUString() );
/* throw (css::uno::RuntimeException, IncompatibleTypeException) */
} // namespace stoc_tdmgr
#endif /* _STOC_TDMGR_COMMON_HXX */
/* 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 .
*/
#include <osl/diagnose.h>
#include "tdmgr_common.hxx"
#include "tdmgr_tdenumeration.hxx"
using namespace com::sun::star;
extern rtl_StandardModuleCount g_moduleCount;
namespace stoc_tdmgr
{
//=========================================================================
//=========================================================================
//
// TypeDescriptionEnumerationImpl Implementation.
//
//=========================================================================
//=========================================================================
TypeDescriptionEnumerationImpl::TypeDescriptionEnumerationImpl(
const rtl::OUString & rModuleName,
const com::sun::star::uno::Sequence<
com::sun::star::uno::TypeClass > & rTypes,
com::sun::star::reflection::TypeDescriptionSearchDepth eDepth,
const TDEnumerationAccessStack & rTDEAS )
: m_aModuleName( rModuleName ),
m_aTypes( rTypes ),
m_eDepth( eDepth ),
m_aChildren( rTDEAS )
{
::g_moduleCount.modCnt.acquire( &::g_moduleCount.modCnt );
}
//=========================================================================
// virtual
TypeDescriptionEnumerationImpl::~TypeDescriptionEnumerationImpl()
{
::g_moduleCount.modCnt.release( &::g_moduleCount.modCnt );
}
//=========================================================================
//
// XEnumeration (base of XTypeDescriptionEnumeration) methods
//
//=========================================================================
// virtual
sal_Bool SAL_CALL TypeDescriptionEnumerationImpl::hasMoreElements()
throw ( uno::RuntimeException )
{
uno::Reference< reflection::XTypeDescriptionEnumeration > xEnum
= queryCurrentChildEnumeration();
if ( xEnum.is() )
return xEnum->hasMoreElements();
return sal_False;
}
//=========================================================================
// virtual
uno::Any SAL_CALL TypeDescriptionEnumerationImpl::nextElement()
throw ( container::NoSuchElementException,
lang::WrappedTargetException,
uno::RuntimeException )
{
uno::Reference< reflection::XTypeDescriptionEnumeration > xEnum
= queryCurrentChildEnumeration();
if ( xEnum.is() )
return xEnum->nextElement();
throw container::NoSuchElementException(
rtl::OUString(
RTL_CONSTASCII_USTRINGPARAM("No further elements in enumeration!") ),
static_cast< cppu::OWeakObject * >( this ) );
}
//=========================================================================
//
// XTypeDescriptionEnumeration methods
//
//=========================================================================
// virtual
uno::Reference< reflection::XTypeDescription > SAL_CALL
TypeDescriptionEnumerationImpl::nextTypeDescription()
throw ( container::NoSuchElementException,
uno::RuntimeException )
{
uno::Reference< reflection::XTypeDescriptionEnumeration > xEnum
= queryCurrentChildEnumeration();
if ( xEnum.is() )
return xEnum->nextTypeDescription();
throw container::NoSuchElementException(
rtl::OUString(
RTL_CONSTASCII_USTRINGPARAM("No further elements in enumeration!") ),
static_cast< cppu::OWeakObject * >( this ) );
}
//=========================================================================
uno::Reference< reflection::XTypeDescriptionEnumeration >
TypeDescriptionEnumerationImpl::queryCurrentChildEnumeration()
{
osl::MutexGuard aGuard( m_aMutex );
for (;;)
{
if ( m_xEnum.is() )
{
if ( m_xEnum->hasMoreElements() )
{
return m_xEnum;
}
else
{
// Forget about enumeration without further elements. Try next.
m_xEnum.clear();
}
}
// Note: m_xEnum is always null here.
if ( m_aChildren.empty() )
{
// No child enumerations left.
return m_xEnum;
}
try
{
m_xEnum =
m_aChildren.top()->createTypeDescriptionEnumeration(
m_aModuleName, m_aTypes, m_eDepth );
}
catch ( reflection::NoSuchTypeNameException const & )
{
OSL_FAIL( "TypeDescriptionEnumerationImpl::queryCurrentChildEnumeration "
"- Caught NoSuchTypeNameException!" );
}
catch ( reflection::InvalidTypeNameException const & )
{
OSL_FAIL( "TypeDescriptionEnumerationImpl::queryCurrentChildEnumeration "
"- Caught InvalidTypeNameException!" );
}
// We're done with this enumeration access in any case (Either
// enumeration was successfully created or creation failed for some
// reason).
m_aChildren.pop();
}
// unreachable
}
} // namespace stoc_tdmgr
/* 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 _STOC_TDMGR_TDENUMERATION_HXX
#define _STOC_TDMGR_TDENUMERATION_HXX
#include <stack>
#include <osl/mutex.hxx>
#include <com/sun/star/reflection/XTypeDescriptionEnumeration.hpp>
#include <com/sun/star/reflection/XTypeDescriptionEnumerationAccess.hpp>
#include <cppuhelper/implbase1.hxx>
namespace stoc_tdmgr
{
typedef std::stack< com::sun::star::uno::Reference<
com::sun::star::reflection::XTypeDescriptionEnumerationAccess > >
TDEnumerationAccessStack;
class TypeDescriptionEnumerationImpl
: public cppu::WeakImplHelper1<
com::sun::star::reflection::XTypeDescriptionEnumeration >
{
public:
TypeDescriptionEnumerationImpl(
const rtl::OUString & rModuleName,
const com::sun::star::uno::Sequence<
com::sun::star::uno::TypeClass > & rTypes,
com::sun::star::reflection::TypeDescriptionSearchDepth eDepth,
const TDEnumerationAccessStack & rTDEAS );
virtual ~TypeDescriptionEnumerationImpl();
// XEnumeration (base of XTypeDescriptionEnumeration)
virtual sal_Bool SAL_CALL hasMoreElements()
throw ( ::com::sun::star::uno::RuntimeException );
virtual ::com::sun::star::uno::Any SAL_CALL nextElement()
throw ( ::com::sun::star::container::NoSuchElementException,
::com::sun::star::lang::WrappedTargetException,
::com::sun::star::uno::RuntimeException );
// XTypeDescriptionEnumeration
virtual ::com::sun::star::uno::Reference<
::com::sun::star::reflection::XTypeDescription > SAL_CALL
nextTypeDescription()
throw ( ::com::sun::star::container::NoSuchElementException,
::com::sun::star::uno::RuntimeException );
private:
com::sun::star::uno::Reference<
com::sun::star::reflection::XTypeDescriptionEnumeration >
queryCurrentChildEnumeration();
osl::Mutex m_aMutex;
rtl::OUString m_aModuleName;
com::sun::star::uno::Sequence< com::sun::star::uno::TypeClass > m_aTypes;
com::sun::star::reflection::TypeDescriptionSearchDepth m_eDepth;
TDEnumerationAccessStack m_aChildren;
com::sun::star::uno::Reference<
com::sun::star::reflection::XTypeDescriptionEnumeration > m_xEnum;
};
} // namespace stoc_tdmgr
#endif /* _STOC_TDMGR_TDENUMERATION_HXX */
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
......@@ -41,6 +41,10 @@
<implementation name="com.sun.star.comp.stoc.SimpleRegistry">
<service name="com.sun.star.registry.SimpleRegistry"/>
</implementation>
<implementation name="com.sun.star.comp.stoc.TypeDescriptionManager">
<service name="com.sun.star.reflection.TypeDescriptionManager"/>
<singleton name="com.sun.star.reflection.theTypeDescriptionManager"/>
</implementation>
<implementation name="com.sun.star.security.comp.stoc.AccessController">
<service name="com.sun.star.security.AccessController"/>
</implementation>
......
......@@ -15,7 +15,6 @@
#include <cassert>
#include <vector>
#include "osl/mutex.hxx"
#include "rtl/ref.hxx"
#include "rtl/ustring.hxx"
#include "sal/types.h"
......@@ -624,7 +623,6 @@ public:
private:
virtual SAL_DLLPRIVATE ~Manager() throw ();
mutable osl::Mutex mutex_;
std::vector< rtl::Reference< Provider > > providers_;
};
......
......@@ -11,7 +11,6 @@
#include <vector>
#include "osl/mutex.hxx"
#include "rtl/ref.hxx"
#include "rtl/ustring.hxx"
#include "unoidl/legacyprovider.hxx"
......@@ -75,13 +74,11 @@ rtl::Reference< Provider > loadProvider(
void Manager::addProvider(rtl::Reference< Provider > const & provider) {
assert(provider.is());
osl::MutexGuard g(mutex_);
providers_.push_back(provider);
}
rtl::Reference< Entity > Manager::findEntity(rtl::OUString const & name) const {
//TODO: caching? (here or in cppuhelper::TypeManager?)
osl::MutexGuard g(mutex_);
//TODO: add caching
for (std::vector< rtl::Reference< Provider > >::const_iterator i(
providers_.begin());
i != providers_.end(); ++i)
......
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