40 enum class LocationType
59 void bind(
void* _pLocation,
const Type& _rType );
71 :sRelativePath(
std::move( _aNodePath ))
72 ,eLocationType( LocationType::Unbound )
96 std::unique_lock aGuard( _rMutex );
98 SAL_WARN_IF(!_rAccessor.
isBound(),
"unotools.config",
"::utl::lcl_copyData: invalid accessor!");
101 case LocationType::SimplyObjectInstance:
103 if ( _rData.hasValue() )
108 const_cast< void*
>( _rData.getValue() ), _rData.getValueType().getTypeLibType(),
109 cpp_queryInterface, cpp_acquire, cpp_release
112 "::utl::lcl_copyData( Accessor, Any ): could not assign the data (node path: \"" << _rAccessor.
getPath() <<
"\"");
115 SAL_INFO(
"unotools.config",
"::utl::lcl_copyData: NULL value lost!");
127 std::unique_lock aGuard( _rMutex );
129 SAL_WARN_IF(!_rAccessor.
isBound(),
"unotools.config",
"::utl::lcl_copyData: invalid accessor!" );
132 case LocationType::SimplyObjectInstance:
154 SubNodeAccess(
const OConfigurationNode& _rRootNode,
std::mutex& _rMutex )
161 struct UpdateFromConfig :
public SubNodeAccess
164 UpdateFromConfig(
const OConfigurationNode& _rRootNode,
std::mutex& _rMutex ) : SubNodeAccess( _rRootNode, _rMutex ) { }
166 void operator() ( NodeValueAccessor
const & _rAccessor )
172 struct UpdateToConfig :
public SubNodeAccess
175 UpdateToConfig(
const OConfigurationNode& _rRootNode,
std::mutex& _rMutex ) : SubNodeAccess( _rRootNode, _rMutex ) { }
177 void operator() ( NodeValueAccessor
const & _rAccessor )
181 m_rRootNode.setNodeValue( _rAccessor.getPath( ), aNewValue );
191 Reference< XComponentContext >
xORB;
206 OConfigurationValueContainer::OConfigurationValueContainer(
207 const Reference< XComponentContext >& _rxORB,
std::mutex& _rAccessSafety,
208 const char* _pConfigLocation,
const sal_Int32 _nLevels )
209 :
m_pImpl( new OConfigurationValueContainerImpl( _rxORB, _rAccessSafety ) )
211 implConstruct( OUString::createFromAscii( _pConfigLocation ), _nLevels );
214 OConfigurationValueContainer::~OConfigurationValueContainer()
218 void OConfigurationValueContainer::implConstruct(
const OUString& _rConfigLocation,
219 const sal_Int32 _nLevels )
221 SAL_WARN_IF(
m_pImpl->aConfigRoot.isValid(),
"unotools.config",
"OConfigurationValueContainer::implConstruct: already initialized!");
230 "Could not access the configuration node located at " << _rConfigLocation);
233 void OConfigurationValueContainer::registerExchangeLocation(
const char* _pRelativePath,
234 void* _pContainer,
const Type& _rValueType )
238 "OConfigurationValueContainer::registerExchangeLocation: invalid container location!");
239 SAL_WARN_IF(!( (TypeClass_CHAR == _rValueType.getTypeClass( ) )
240 || ( TypeClass_BOOLEAN == _rValueType.getTypeClass( ) )
241 || ( TypeClass_BYTE == _rValueType.getTypeClass( ) )
242 || ( TypeClass_SHORT == _rValueType.getTypeClass( ) )
243 || ( TypeClass_LONG == _rValueType.getTypeClass( ) )
244 || ( TypeClass_DOUBLE == _rValueType.getTypeClass( ) )
245 || ( TypeClass_STRING == _rValueType.getTypeClass( ) )
246 || ( TypeClass_SEQUENCE == _rValueType.getTypeClass( ) )),
248 "OConfigurationValueContainer::registerExchangeLocation: invalid type!" );
251 NodeValueAccessor aNewAccessor( OUString::createFromAscii( _pRelativePath ) );
252 aNewAccessor.bind( _pContainer, _rValueType );
255 implRegisterExchangeLocation( aNewAccessor );
258 void OConfigurationValueContainer::read( )
267 void OConfigurationValueContainer::commit()
277 m_pImpl->aConfigRoot.commit( );
280 void OConfigurationValueContainer::implRegisterExchangeLocation(
const NodeValueAccessor& _rAccessor )
285 "OConfigurationValueContainer::implRegisterExchangeLocation: invalid relative path!" );
293 "OConfigurationValueContainer::implRegisterExchangeLocation: already registered a container for this subnode!" );
296 m_pImpl->aAccessors.push_back( _rAccessor );
a specialized version of an OConfigurationNode, representing the root of a configuration sub treeOnly...
static OConfigurationTreeRoot createWithComponentContext(const css::uno::Reference< css::uno::XComponentContext > &_rxContext, const OUString &_rPath, sal_Int32 _nDepth=-1, CREATION_MODE _eMode=CM_UPDATABLE)
open a new top-level configuration nodeopens a new node which is the root if an own configuration sub...
const OConfigurationNode & m_rRootNode
sal_Bool SAL_CALL uno_type_assignData(void *pDest, typelib_TypeDescriptionReference *pDestType, void *pSource, typelib_TypeDescriptionReference *pSourceType, uno_QueryInterfaceFunc queryInterface, uno_AcquireFunc acquire, uno_ReleaseFunc release) SAL_THROW_EXTERN_C()
#define SAL_WARN_IF(condition, area, stream)
#define SAL_INFO(area, stream)
static void lcl_copyData(Any &_rData, const NodeValueAccessor &_rAccessor, std::mutex &_rMutex)
static void lcl_copyData(const NodeValueAccessor &_rAccessor, const Any &_rData, std::mutex &_rMutex)
NodeValueAccessor(OUString _aNodePath)
void bind(void *_pLocation, const Type &_rType)
LocationType eLocationType
bool operator==(const NodeValueAccessor &rhs) const
void * getLocation() const
LocationType getLocType() const
const OUString & getPath() const
const Type & getDataType() const
Reference< XComponentContext > xORB
OConfigurationTreeRoot aConfigRoot
OConfigurationValueContainerImpl(const Reference< XComponentContext > &_rxORB, std::mutex &_rMutex)
std::vector< NodeValueAccessor > aAccessors