diff options
Diffstat (limited to 'autodoc/source/ary/inc')
-rw-r--r-- | autodoc/source/ary/inc/cpp_internalgate.hxx | 66 | ||||
-rw-r--r-- | autodoc/source/ary/inc/cross_refs.hxx | 99 | ||||
-rw-r--r-- | autodoc/source/ary/inc/idl_internalgate.hxx | 66 | ||||
-rw-r--r-- | autodoc/source/ary/inc/idsort.hxx | 52 | ||||
-rw-r--r-- | autodoc/source/ary/inc/loc_internalgate.hxx | 63 | ||||
-rw-r--r-- | autodoc/source/ary/inc/nametreenode.hxx | 210 | ||||
-rw-r--r-- | autodoc/source/ary/inc/reposy.hxx | 91 | ||||
-rw-r--r-- | autodoc/source/ary/inc/sci_impl.hxx | 413 | ||||
-rw-r--r-- | autodoc/source/ary/inc/slots.hxx | 163 | ||||
-rw-r--r-- | autodoc/source/ary/inc/sorted_idset.hxx | 97 | ||||
-rw-r--r-- | autodoc/source/ary/inc/sortedids.hxx | 237 | ||||
-rw-r--r-- | autodoc/source/ary/inc/store/s_base.hxx | 180 | ||||
-rw-r--r-- | autodoc/source/ary/inc/store/s_iterator.hxx | 237 | ||||
-rw-r--r-- | autodoc/source/ary/inc/store/s_storage.hxx | 294 | ||||
-rw-r--r-- | autodoc/source/ary/inc/traits_impl.hxx | 119 |
15 files changed, 2387 insertions, 0 deletions
diff --git a/autodoc/source/ary/inc/cpp_internalgate.hxx b/autodoc/source/ary/inc/cpp_internalgate.hxx new file mode 100644 index 000000000000..723e019cb4f6 --- /dev/null +++ b/autodoc/source/ary/inc/cpp_internalgate.hxx @@ -0,0 +1,66 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef ARY_CPP_INTERNALGATE_HXX +#define ARY_CPP_INTERNALGATE_HXX + +// BASE CLASSES +#include <ary/cpp/c_gate.hxx> + +namespace ary +{ + class RepositoryCenter; +} + + + + +namespace ary +{ +namespace cpp +{ + + +/** Provides access to the ->cpp::RepositoryPartition as far as is needed + by the ->RepositoryCenter. +*/ +class InternalGate : public ::ary::cpp::Gate +{ + public: + virtual ~InternalGate() {} + + static DYN InternalGate & + Create_Partition_( + RepositoryCenter & i_center ); +}; + + + + +} // namespace cpp +} // namespace ary +#endif diff --git a/autodoc/source/ary/inc/cross_refs.hxx b/autodoc/source/ary/inc/cross_refs.hxx new file mode 100644 index 000000000000..8f6b98aabc05 --- /dev/null +++ b/autodoc/source/ary/inc/cross_refs.hxx @@ -0,0 +1,99 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef ARY_CROSS_REFS_HXX +#define ARY_CROSS_REFS_HXX + + + +// USED SERVICES + // BASE CLASSES + // COMPONENTS + // PARAMETERS +#include "sorted_idset.hxx" + + +template <class VALUE_LIST, class TYPES> +class CrossReferences +{ + public: + typedef TYPES::element_type element; + + /// Checks for double occurences + void Add( + VALUE_LIST::index_type + i_nPosition + const element & i_rElem ); + void Get_List( + Dyn_StdConstIterator<element> & + o_rResult ) const; + private: + SortedIdSet<TYPES> aData[VALUE_LIST::max]; +}; + + + +namespace ary +{ + +template <class TYPES> +class SortedIdSet +{ + public: + typedef typename TYPES::element_type element; + typedef typename TYPES::sort_type sorter; + typedef typename TYPES::find_type finder; + + SortedIdSet( + const finder & i_rFinder ) + : aSorter(i_rFinder), + aData(aSorter) {} + ~SortedIdSet() {} + + void Get_Begin( + Dyn_StdConstIterator<element> & + o_rResult ) + { o_rResult = new SCI_Set<FINDER>(aData); } + void Add( + const element & i_rElement ) + { aData.insert(i_rElement); } + + private: + typedef std::set<element, sorter> Set; + + // DATA + sorter aSorter; + Set aData; +}; + + +} // namespace ary + + + +#endif + diff --git a/autodoc/source/ary/inc/idl_internalgate.hxx b/autodoc/source/ary/inc/idl_internalgate.hxx new file mode 100644 index 000000000000..783971f7295f --- /dev/null +++ b/autodoc/source/ary/inc/idl_internalgate.hxx @@ -0,0 +1,66 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef ARY_IDL_INTERNALGATE_HXX +#define ARY_IDL_INTERNALGATE_HXX + +// BASE CLASSES +#include <ary/idl/i_gate.hxx> + +namespace ary +{ + class RepositoryCenter; +} + + + + +namespace ary +{ +namespace idl +{ + + +/** Provides access to the ->idl::RepositoryPartition as far as is needed + by the ->RepositoryCenter. +*/ +class InternalGate : public ::ary::idl::Gate +{ + public: + virtual ~InternalGate() {} + + static DYN InternalGate & + Create_Partition_( + RepositoryCenter & i_center ); +}; + + + + +} // namespace idl +} // namespace ary +#endif diff --git a/autodoc/source/ary/inc/idsort.hxx b/autodoc/source/ary/inc/idsort.hxx new file mode 100644 index 000000000000..d0bbaa37e7a2 --- /dev/null +++ b/autodoc/source/ary/inc/idsort.hxx @@ -0,0 +1,52 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef ARY_IDSORT_HXX +#define ARY_IDSORT_HXX + + +/** A compare function that sorts ids of repository entities in the same + storage. + + @see ::ary::SortedIds +*/ +template<class COMPARE> +struct IdSorter +{ + bool operator()( + typename COMPARE::id_type + i_1, + typename COMPARE::id_type + i_2 ) const + { return COMPARE::Lesser_( + COMPARE::KeyOf_(COMPARE::EntityOf_(i_1)), + COMPARE::KeyOf_(COMPARE::EntityOf_(i_2)) ); + } +}; + + +#endif diff --git a/autodoc/source/ary/inc/loc_internalgate.hxx b/autodoc/source/ary/inc/loc_internalgate.hxx new file mode 100644 index 000000000000..13409e6364de --- /dev/null +++ b/autodoc/source/ary/inc/loc_internalgate.hxx @@ -0,0 +1,63 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef ARY_LOC_INTERNALGATE_HXX +#define ARY_LOC_INTERNALGATE_HXX + +// USED SERVICES + +namespace ary +{ +namespace loc +{ + class LocationPilot; +} +} + + + + +namespace ary +{ +namespace loc +{ + + +/** Additional access to locations for the repository implementation. +*/ +class InternalGate +{ + public: + + static DYN LocationPilot & + Create_Locations_(); +}; + + +} // namespace loc +} // namespace ary +#endif diff --git a/autodoc/source/ary/inc/nametreenode.hxx b/autodoc/source/ary/inc/nametreenode.hxx new file mode 100644 index 000000000000..c7d77faaab34 --- /dev/null +++ b/autodoc/source/ary/inc/nametreenode.hxx @@ -0,0 +1,210 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef ARY_NAMETREENODE_HXX +#define ARY_NAMETREENODE_HXX +// KORR_DEPRECATED_3.0 +// Replace by ::ary::symtree::Node. + +// USED SERVICES +#include <cosv/tpl/tpltools.hxx> +#include <sci_impl.hxx> +// HACK because of SunPro 5.2 compiler bug with templates: +#include <ary/idl/i_module.hxx> + + + + +namespace ary +{ + + +/** Implementation of a node in a namespace-tree. +*/ +template<class ITEM_ID> +class NameTreeNode +{ + public: + typedef NameTreeNode self; + typedef ITEM_ID item_id; + typedef StringVector::const_iterator name_iterator; + typedef std::map<String, item_id> Map_LocalNames; + + // LIFECYCLE + NameTreeNode(); + NameTreeNode( + const String & i_sName, + const self & i_rParent, + ITEM_ID i_nParentId ); + virtual ~NameTreeNode(); + + // OPERATIONS + void Add_Name( + const String & i_sName, + item_id i_nId ); + // INQUIRY + const String & Name() const { return Depth() > 0 ? aCompleteNameChain.back() : String::Null_(); } + item_id Parent() const { return nParent; } + intt Depth() const { return aCompleteNameChain.size(); } + + bool IsEquivalent( + const NameTreeNode & + i_rNode ) const; + name_iterator NameChain_Begin() const { return aCompleteNameChain.begin(); } + name_iterator NameChain_End() const { return aCompleteNameChain.end(); } + + item_id Search_Name( + const String & i_sName ) const; + void Get_Names( + Dyn_StdConstIterator<ITEM_ID> & + o_rResult ) const; + const Map_LocalNames & + LocalNames() const { return aLocalNames; } + private: + // Locals + Map_LocalNames & LocalNames() { return aLocalNames; } + + // DATA + Map_LocalNames aLocalNames; + StringVector aCompleteNameChain; + item_id nParent; +}; + + + + +// IMPLEMENTATION +template<class ITEM_ID> +NameTreeNode<ITEM_ID>::NameTreeNode() + : aLocalNames(), + aCompleteNameChain(), + nParent(0) +{ +} + +template<class ITEM_ID> +NameTreeNode<ITEM_ID>::NameTreeNode( const String & i_sName, + const self & i_rParent, + ITEM_ID i_nParentId ) + : aLocalNames(), + aCompleteNameChain(), + nParent(i_nParentId) +{ + aCompleteNameChain.reserve(i_rParent.Depth()+1); + for ( name_iterator it = i_rParent.NameChain_Begin(); + it != i_rParent.NameChain_End(); + ++it ) + { + aCompleteNameChain.push_back(*it); + } + aCompleteNameChain.push_back(i_sName); +} + +template<class ITEM_ID> +NameTreeNode<ITEM_ID>::~NameTreeNode() +{ +} + + +template<class ITEM_ID> +inline void +NameTreeNode<ITEM_ID>::Add_Name( const String & i_sName, + item_id i_nId ) +{ + LocalNames().insert( typename Map_LocalNames::value_type(i_sName, i_nId) ); +} + + +template<class ITEM_ID> +inline bool +NameTreeNode<ITEM_ID>::IsEquivalent( const NameTreeNode & i_rNode ) const +{ + return aCompleteNameChain == i_rNode.aCompleteNameChain; +} + +template<class ITEM_ID> +inline ITEM_ID +NameTreeNode<ITEM_ID>::Search_Name( const String & i_sName ) const +{ + return csv::value_from_map(LocalNames(),i_sName, ITEM_ID(0)); +} + +template<class ITEM_ID> +inline void +NameTreeNode<ITEM_ID>::Get_Names( Dyn_StdConstIterator<ITEM_ID> & o_rResult ) const +{ + o_rResult = new SCI_DataInMap<String,item_id>(LocalNames()); +} + + +// HACK because of SunPro 5.2 compiler bug with templates: +// ary::idl::Module has to be "FIND_NODE::node_type" +// must be solved later somehow. +template <class FIND_NODE> +typename FIND_NODE::id_type +Search_SubTree( const ary::idl::Module & i_rStart, + const FIND_NODE & i_rNodeFinder ) +{ + const ary::idl::Module * + ret = &i_rStart; + + for ( StringVector::const_iterator it = i_rNodeFinder.Begin(); + it != i_rNodeFinder.End() AND ret != 0; + ++it ) + { + ret = i_rNodeFinder(ret->Search_Name(*it)); + } + + typename FIND_NODE::id_type nret(0); + return ret != 0 + ? ret->Search_Name(i_rNodeFinder.Name2Search()) + : nret; +} + +template <class FIND_NODE> +typename FIND_NODE::id_type +Search_SubTree_UpTillRoot( const ary::idl::Module & i_rStart, + const FIND_NODE & i_rNodeFinder ) +{ + typename FIND_NODE::id_type + ret(0); + for ( const ary::idl::Module * start = &i_rStart; + start != 0 AND NOT ret.IsValid(); + start = i_rNodeFinder(start->Owner()) ) + { + ret = Search_SubTree( *start, + i_rNodeFinder ); + } + return ret; +} +// END Hack for SunPro 5.2 compiler bug. + + + + +} // namespace ary +#endif diff --git a/autodoc/source/ary/inc/reposy.hxx b/autodoc/source/ary/inc/reposy.hxx new file mode 100644 index 000000000000..6bdfd907ce04 --- /dev/null +++ b/autodoc/source/ary/inc/reposy.hxx @@ -0,0 +1,91 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef ARY_REPOSY_HXX +#define ARY_REPOSY_HXX + +// BASE CLASSES +#include <ary/ary.hxx> +// USED SERVICES +#include <cosv/ploc_dir.hxx> + +namespace ary +{ +namespace cpp +{ + class InternalGate; +} +namespace idl +{ + class InternalGate; +} +} // namespace ary + + + + +namespace ary +{ + + +/** Implements ::ary::Repository. + + @see Repository +*/ + +class RepositoryCenter : public ::ary::Repository +{ + public: + // LIFECYCLE + RepositoryCenter(); + virtual ~RepositoryCenter(); + + // INHERITED + // Interface Repository: + virtual const cpp::Gate & Gate_Cpp() const; + virtual const idl::Gate & Gate_Idl() const; + virtual const String & Title() const; + virtual cpp::Gate & Gate_Cpp(); + virtual idl::Gate & Gate_Idl(); + virtual void Set_Title(const String & i_sName ); + + private: + // DATA + String sDisplayedName; /// Name to be displayed for human users. + csv::ploc::Directory + aLocation; + Dyn<cpp::InternalGate> + pCppPartition; + Dyn<idl::InternalGate> + pIdlPartition; +}; + + + + +} // namespace ary +#endif diff --git a/autodoc/source/ary/inc/sci_impl.hxx b/autodoc/source/ary/inc/sci_impl.hxx new file mode 100644 index 000000000000..26c5236904b9 --- /dev/null +++ b/autodoc/source/ary/inc/sci_impl.hxx @@ -0,0 +1,413 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef ARY_SCI_IMPL_HXX +#define ARY_SCI_IMPL_HXX + + + +// USED SERVICES + // BASE CLASSES +#include <ary/stdconstiter.hxx> + // COMPONENTS + // PARAMETERS + + +namespace ary +{ + + +//************************* SCI_Vector **********************************// + +template <class ELEM> +class SCI_Vector : public StdConstIterator<ELEM> +{ + public: + typedef std::vector<ELEM> source; + typedef typename source::const_iterator source_iterator; + + SCI_Vector( + const source & i_rSource ); + virtual ~SCI_Vector(); + + private: + // Interface StdConstIterator<>: + virtual void do_Advance(); + virtual const ELEM * + inq_CurElement() const; + virtual bool inq_IsSorted() const; + + // DATA + source_iterator itRun; + source_iterator itEnd; +}; + + + +//************************* SCI_Map **********************************// + +template <class KEY, class VALUE> +class SCI_Map : public StdConstIterator< typename std::map<KEY,VALUE>::value_type > +{ + public: + typedef std::map<KEY,VALUE> source; + typedef typename source::const_iterator source_iterator; + + SCI_Map( + const source & i_rSource ); + virtual ~SCI_Map(); + + private: + // Interface StdConstIterator<>: + virtual void do_Advance(); + virtual const typename std::map<KEY,VALUE>::value_type * + inq_CurElement() const; + virtual bool inq_IsSorted() const; + + // DATA + source_iterator itRun; + source_iterator itEnd; +}; + + +//************************* SCI_MultiMap **********************************// + +template <class KEY, class VALUE> +class SCI_MultiMap : public StdConstIterator< typename std::multimap<KEY,VALUE>::value_type > +{ + public: + typedef std::multimap<KEY,VALUE> source; + typedef typename source::const_iterator source_iterator; + + SCI_MultiMap( + const source & i_rSource ); + SCI_MultiMap( + source_iterator i_begin, + source_iterator i_end ); + virtual ~SCI_MultiMap(); + + private: + // Interface StdConstIterator<>: + virtual void do_Advance(); + virtual const typename std::multimap<KEY,VALUE>::value_type * + inq_CurElement() const; + virtual bool inq_IsSorted() const; + + // DATA + source_iterator itRun; + source_iterator itEnd; +}; + + + +//************************* SCI_Set **********************************// + + +template <class TYPES> +class SCI_Set : public StdConstIterator<typename TYPES::element_type> +{ + public: + typedef typename TYPES::element_type element; + typedef typename TYPES::sort_type sorter; + typedef std::set<element, sorter> source; + typedef typename source::const_iterator source_iterator; + + SCI_Set( + const source & i_rSource ); + virtual ~SCI_Set(); + + private: + // Interface StdConstIterator<>: + virtual void do_Advance(); + virtual const element * + inq_CurElement() const; + virtual bool inq_IsSorted() const; + + // DATA + source_iterator itRun; + source_iterator itEnd; +}; + +//************************* SCI_DataInMap **********************************// + +template <class KEY, class VALUE> +class SCI_DataInMap : public StdConstIterator<VALUE> +{ + public: + typedef std::map<KEY,VALUE> source; + typedef typename source::const_iterator source_iterator; + + SCI_DataInMap( + const source & i_rSource ); + virtual ~SCI_DataInMap(); + + private: + // Interface StdConstIterator<>: + virtual void do_Advance(); + virtual const VALUE * + inq_CurElement() const; + virtual bool inq_IsSorted() const; + + // DATA + source_iterator itRun; + source_iterator itEnd; +}; + + + + + +//********************************************************************// + + +// IMPLEMENTATION + +template <class ELEM> +SCI_Vector<ELEM>::SCI_Vector( const source & i_rSource ) + : itRun(i_rSource.begin()), + itEnd(i_rSource.end()) +{ +} + +template <class ELEM> +SCI_Vector<ELEM>::~SCI_Vector() +{ +} + + +template <class ELEM> +void +SCI_Vector<ELEM>::do_Advance() +{ + if (itRun != itEnd) + ++itRun; +} + +template <class ELEM> +const ELEM * +SCI_Vector<ELEM>::inq_CurElement() const +{ + if (itRun != itEnd) + return &(*itRun); + return 0; +} + +template <class ELEM> +bool +SCI_Vector<ELEM>::inq_IsSorted() const +{ + return false; +} + + + + +template <class KEY, class VALUE> +SCI_Map<KEY,VALUE>::SCI_Map( const source & i_rSource ) + : itRun(i_rSource.begin()), + itEnd(i_rSource.end()) +{ +} + +template <class KEY, class VALUE> +SCI_Map<KEY,VALUE>::~SCI_Map() +{ +} + +template <class KEY, class VALUE> +void +SCI_Map<KEY,VALUE>::do_Advance() +{ + if (itRun != itEnd) + ++itRun; +} + +template <class KEY, class VALUE> +const typename std::map<KEY,VALUE>::value_type * +SCI_Map<KEY,VALUE>::inq_CurElement() const +{ + if (itRun != itEnd) + return &(*itRun); + return 0; +} + + +template <class KEY, class VALUE> +bool +SCI_Map<KEY,VALUE>::inq_IsSorted() const +{ + return true; +} + + + + + + + +template <class KEY, class VALUE> +SCI_MultiMap<KEY,VALUE>::SCI_MultiMap( const source & i_rSource ) + : itRun(i_rSource.begin()), + itEnd(i_rSource.end()) +{ +} + +template <class KEY, class VALUE> +SCI_MultiMap<KEY,VALUE>::SCI_MultiMap( source_iterator i_begin, + source_iterator i_end ) + : itRun(i_begin), + itEnd(i_end) +{ +} + +template <class KEY, class VALUE> +SCI_MultiMap<KEY,VALUE>::~SCI_MultiMap() +{ +} + +template <class KEY, class VALUE> +void +SCI_MultiMap<KEY,VALUE>::do_Advance() +{ + if (itRun != itEnd) + ++itRun; +} + +template <class KEY, class VALUE> +const typename std::multimap<KEY,VALUE>::value_type * +SCI_MultiMap<KEY,VALUE>::inq_CurElement() const +{ + if (itRun != itEnd) + return &(*itRun); + return 0; +} + + +template <class KEY, class VALUE> +bool +SCI_MultiMap<KEY,VALUE>::inq_IsSorted() const +{ + return true; +} + + + + + + + + +template <class ELEM> +SCI_Set<ELEM>::SCI_Set( const source & i_rSource ) + : itRun(i_rSource.begin()), + itEnd(i_rSource.end()) +{ +} + +template <class ELEM> +SCI_Set<ELEM>::~SCI_Set() +{ +} + + +template <class ELEM> +void +SCI_Set<ELEM>::do_Advance() +{ + if (itRun != itEnd) + ++itRun; +} + +template <class ELEM> +const typename SCI_Set<ELEM>::element * +SCI_Set<ELEM>::inq_CurElement() const +{ + if (itRun != itEnd) + return &(*itRun); + return 0; +} + +template <class ELEM> +bool +SCI_Set<ELEM>::inq_IsSorted() const +{ + return true; +} + + + + + + + +template <class KEY, class VALUE> +SCI_DataInMap<KEY,VALUE>::SCI_DataInMap( const source & i_rSource ) + : itRun(i_rSource.begin()), + itEnd(i_rSource.end()) +{ +} + +template <class KEY, class VALUE> +SCI_DataInMap<KEY,VALUE>::~SCI_DataInMap() +{ +} + +template <class KEY, class VALUE> +void +SCI_DataInMap<KEY,VALUE>::do_Advance() +{ + if (itRun != itEnd) + ++itRun; +} + +template <class KEY, class VALUE> +const VALUE * +SCI_DataInMap<KEY,VALUE>::inq_CurElement() const +{ + if (itRun != itEnd) + return &(*itRun).second; + return 0; +} + + +template <class KEY, class VALUE> +bool +SCI_DataInMap<KEY,VALUE>::inq_IsSorted() const +{ + return true; +} + + + + + + + +} // namespace ary + + +#endif diff --git a/autodoc/source/ary/inc/slots.hxx b/autodoc/source/ary/inc/slots.hxx new file mode 100644 index 000000000000..f5c449f7a30a --- /dev/null +++ b/autodoc/source/ary/inc/slots.hxx @@ -0,0 +1,163 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef ARY_SLOTS_HXX +#define ARY_SLOTS_HXX + + +// USED SERVICES + // BASE CLASSES +#include <ary/ceslot.hxx> + // COMPONENTS + // PARAMETERS +#include <ary/ary_disp.hxx> +#include <ary/types.hxx> +#include <ary/sequentialids.hxx> +#include <ary/cpp/c_types4cpp.hxx> +#include <ary/cpp/c_slntry.hxx> + + + +namespace ary +{ + + +class Slot_Null : public Slot +{ + public: + virtual ~Slot_Null(); + + virtual void StoreAt( + Display & o_rDestination ) const; + virtual uintt Size() const; + + private: + virtual void StoreEntries( + Display & o_rDestination ) const; +}; + +class Slot_MapLocalCe : public Slot +{ + public: + Slot_MapLocalCe( + const cpp::Map_LocalCe & i_rData ); + virtual ~Slot_MapLocalCe(); + virtual uintt Size() const; + + private: + virtual void StoreEntries( + Display & o_rDestination ) const; + // DATA + const cpp::Map_LocalCe * + pData; +}; + +class Slot_MapOperations : public Slot +{ + public: + Slot_MapOperations( + const std::multimap<String, cpp::Ce_id> & + i_rData ); + virtual ~Slot_MapOperations(); + virtual uintt Size() const; + + private: + virtual void StoreEntries( + Display & o_rDestination ) const; + // DATA + const std::multimap<String, cpp::Ce_id> * + pData; +}; + +class Slot_ListLocalCe : public Slot +{ + public: + Slot_ListLocalCe( + const cpp::List_LocalCe & + i_rData ); + virtual ~Slot_ListLocalCe(); + + virtual uintt Size() const; + + private: + virtual void StoreEntries( + Display & o_rDestination ) const; + // DATA + const cpp::List_LocalCe * + pData; +}; + +template <class ID> +class Slot_SequentialIds : public Slot +{ + public: + Slot_SequentialIds( + const SequentialIds<ID> & + i_rData ) + : pData(&i_rData) {} + virtual ~Slot_SequentialIds(); + + virtual uintt Size() const; + + private: + virtual void StoreEntries( + Display & o_rDestination ) const; + // DATA + const SequentialIds<ID> * + pData; +}; + + +template <class ID> +Slot_SequentialIds<ID>::~Slot_SequentialIds() +{ +} + +template <class ID> +uintt +Slot_SequentialIds<ID>::Size() const +{ + return pData->Size(); +} + +template <class ID> +void +Slot_SequentialIds<ID>::StoreEntries( Display & o_rDestination ) const +{ + for ( typename SequentialIds<ID>::const_iterator it = pData->Begin(); + it != pData->End(); + ++it ) + { + o_rDestination.DisplaySlot_Rid( (*it).Value() ); + } +} + + + + +} // namespace ary +#endif diff --git a/autodoc/source/ary/inc/sorted_idset.hxx b/autodoc/source/ary/inc/sorted_idset.hxx new file mode 100644 index 000000000000..93c00a1091ca --- /dev/null +++ b/autodoc/source/ary/inc/sorted_idset.hxx @@ -0,0 +1,97 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef ARY_SORTED_IDSET_HXX +#define ARY_SORTED_IDSET_HXX + + + +// USED SERVICES + // BASE CLASSES + // COMPONENTS +#include <set> + // PARAMETERS +#include "csi_impl.hxx" + + +template <class XY> class SortedIdSet; + +class Interface_2s +{ + public: + /// Checks for double occurences + void Add_ExportingService( + Ce_id i_nId ); + void Get_ExportingServices( + Dyn_StdConstIterator<Ce_id> & + o_rResult ) const; + private: + Dyn<SortedIdSet> pExportingServices; +}; + + + +namespace ary +{ + +template <class TYPES> +class SortedIdSet +{ + public: + typedef typename TYPES::element_type element; + typedef typename TYPES::sort_type sorter; + typedef typename TYPES::find_type finder; + + SortedIdSet( + const finder & i_rFinder ) + : aSorter(i_rFinder), + aData(aSorter) {} + ~SortedIdSet() {} + + void Get_Begin( + Dyn_StdConstIterator<element> & + o_rResult ) + { o_rResult = new SCI_Set<FINDER>(aData); } + void Add( + const element & i_rElement ) + { aData.insert(i_rElement); } + + private: + typedef std::set<element, sorter> Set; + + // DATA + sorter aSorter; + Set aData; +}; + + +} // namespace ary + + + +#endif + diff --git a/autodoc/source/ary/inc/sortedids.hxx b/autodoc/source/ary/inc/sortedids.hxx new file mode 100644 index 000000000000..9bebaa9b19a5 --- /dev/null +++ b/autodoc/source/ary/inc/sortedids.hxx @@ -0,0 +1,237 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef ARY_SORTEDIDS_HXX +#define ARY_SORTEDIDS_HXX + + +// USED SERVICES +#include <algorithm> +#include <cosv/tpl/range.hxx> + + + + +namespace ary +{ + + +/** Implementation of a set of children to an entity in the Autodoc + repository. The children are sorted. + + @tpl COMPARE + Needs to provide types: + entity_base_type + id_type + key_type + + and functions: + static entity_base_type & + EntityOf_( + id_type i_id ); + static const key_type & + KeyOf_( + const entity_type & i_entity ); + static bool Lesser_( + const key_type & i_1, + const key_type & i_2 ); +*/ +template<class COMPARE> +class SortedIds +{ + public: + typedef typename COMPARE::id_type element_t; + typedef typename COMPARE::key_type key_t; + typedef std::vector<element_t> data_t; + typedef typename data_t::const_iterator const_iterator; + typedef typename data_t::iterator iterator; + typedef csv::range<const_iterator> search_result_t; + + // LIFECYCLE + explicit SortedIds( + std::size_t i_reserve = 0 ); + ~SortedIds(); + + // OPERATIONS + void Add( + element_t i_elem ); + // INQUIRY + const_iterator Begin() const; + const_iterator End() const; + + element_t Search( + const key_t & i_key ) const; + search_result_t SearchAll( + const key_t & i_key ) const; + const_iterator LowerBound( + const key_t & i_key ) const; + + private: + typedef typename COMPARE::entity_base_type entity_t; + + // Locals + iterator LowerBound( + const key_t & i_key ); + + static const key_t & + KeyOf_( + element_t i_child ); + template <class ITER> + static ITER impl_LowerBound_( + ITER i_begin, + ITER i_end, + const key_t & i_key ); + + // DATA + data_t aData; +}; + + + + +// IMPLEMENTATION +template<class COMPARE> +inline const typename SortedIds<COMPARE>::key_t & +SortedIds<COMPARE>::KeyOf_(element_t i_child) +{ + return COMPARE::KeyOf_(COMPARE::EntityOf_(i_child)); +} + +template<class COMPARE> +SortedIds<COMPARE>::SortedIds(std::size_t i_reserve) + : aData() +{ + if (i_reserve > 0) + aData.reserve(i_reserve); +} + +template<class COMPARE> +SortedIds<COMPARE>::~SortedIds() +{ +} + +template<class COMPARE> +void +SortedIds<COMPARE>::Add(element_t i_elem) +{ + aData.insert( LowerBound( KeyOf_(i_elem) ), + i_elem ); +} + +template<class COMPARE> +inline typename SortedIds<COMPARE>::const_iterator +SortedIds<COMPARE>::Begin() const +{ + return aData.begin(); +} + +template<class COMPARE> +inline typename SortedIds<COMPARE>::const_iterator +SortedIds<COMPARE>::End() const +{ + return aData.end(); +} + +template<class COMPARE> +typename SortedIds<COMPARE>::element_t +SortedIds<COMPARE>::Search(const key_t & i_key) const +{ + const_iterator + ret = LowerBound(i_key); + return ret != aData.end() AND NOT COMPARE::Lesser_(i_key, KeyOf_(*ret)) + ? *ret + : element_t(0); +} + +template<class COMPARE> +typename SortedIds<COMPARE>::search_result_t +SortedIds<COMPARE>::SearchAll(const key_t & i_key) const +{ + const_iterator + r1 = LowerBound(i_key); + const_iterator + r2 = r1; + while ( r2 != aData.end() + AND NOT COMPARE::Lesser_(i_key, KeyOf_(*r2)) ) + { + ++r2; + } + + return csv::make_range(r1,r2); +} + +template<class COMPARE> +inline typename SortedIds<COMPARE>::const_iterator +SortedIds<COMPARE>::LowerBound(const key_t & i_key) const +{ + return impl_LowerBound_( aData.begin(), + aData.end(), + i_key ); +} + +template<class COMPARE> +inline typename SortedIds<COMPARE>::iterator +SortedIds<COMPARE>::LowerBound(const key_t & i_key) +{ + return impl_LowerBound_( aData.begin(), + aData.end(), + i_key ); +} + +template<class COMPARE> +template <class ITER> +ITER +SortedIds<COMPARE>::impl_LowerBound_( ITER i_begin, + ITER i_end, + const key_t & i_key ) +{ + ITER i1 = i_begin; + ITER i2 = i_end; + + for ( ITER it = i1 + (i2-i1)/2; + i1 != i2; + it = i1 + (i2-i1)/2 ) + { + if ( COMPARE::Lesser_(KeyOf_(*it), i_key) ) + { + i1 = it; + ++i1; + } + else + { + i2 = it; + } + } // end for + + return i1; +} + + + + +} // namespace ary +#endif diff --git a/autodoc/source/ary/inc/store/s_base.hxx b/autodoc/source/ary/inc/store/s_base.hxx new file mode 100644 index 000000000000..e14fc2652293 --- /dev/null +++ b/autodoc/source/ary/inc/store/s_base.hxx @@ -0,0 +1,180 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef ARY_STORE_S_BASE_HXX +#define ARY_STORE_S_BASE_HXX + +// USED SERVICES +#include <deque> +#include <cosv/tpl/tpltools.hxx> + + + + +namespace ary +{ +namespace stg +{ + + +/** The basic storage container of the repository. + + @collab Storage + Implements Storage. Not used elsewhere. + + @tpl ENTITY + The type of *it, where it is of type c_iter, has to be ENTITY * const. +*/ +template <class ENTITY> +class Base +{ + public: + // LIFECYCLE + typedef std::deque< ENTITY* > impl_type; + typedef typename impl_type::const_iterator c_iter; + + + /** @param i_nrOfReservedItems + The number of actual items to reserve, including the item + at index [0] that is always empty and unused. + */ + Base( + uintt i_nrOfReservedItems ); + ~Base(); + + // OPERATORS + ENTITY * operator[]( + uintt i_index ) const; + // OPERATIONS + uintt Add_Entity( /// @return the index of the new element. + DYN ENTITY & pass_newEntity ); + DYN ENTITY * Set_Entity( /// @return the previous value. + uintt i_index, + DYN ENTITY & pass_newEntity ); + // INQUIRY + uintt Size() const; /// Incl. reserved size. + uintt ReservedSize() const; /// Incl. zero for element at [0]. + + c_iter Begin() const; /// @return location of index 1, because 0 is always empty. + c_iter BeginUnreserved() const; + c_iter End() const; + + private: + // DATA + impl_type aData; + uintt nReservedSize; +}; + + + +// IMPLEMENTATION + +template <class ENTITY> +Base<ENTITY>::Base(uintt i_nrOfReservedItems) + : aData(i_nrOfReservedItems, 0), + nReservedSize(i_nrOfReservedItems) +{ +} + +template <class ENTITY> +Base<ENTITY>::~Base() +{ + csv::erase_container_of_heap_ptrs(aData); +} + + +template <class ENTITY> +ENTITY * +Base<ENTITY>::operator[](uintt i_index) const +{ + if (i_index < aData.size()) + return aData[i_index]; + return 0; +} + +template <class ENTITY> +uintt +Base<ENTITY>::Add_Entity(DYN ENTITY & pass_newEntity) +{ + aData.push_back(&pass_newEntity); + return aData.size() - 1; +} + +template <class ENTITY> +DYN ENTITY * +Base<ENTITY>::Set_Entity( uintt i_index, + DYN ENTITY & pass_newEntity ) +{ + csv_assert(i_index != 0 AND i_index < aData.size()); + + Dyn<ENTITY> + ret(aData[i_index]); + aData[i_index] = &pass_newEntity; + return ret.Release(); +} + +template <class ENTITY> +uintt +Base<ENTITY>::Size() const +{ + return aData.size(); +} + +template <class ENTITY> +uintt +Base<ENTITY>::ReservedSize() const +{ + return nReservedSize; +} + +template <class ENTITY> +typename Base<ENTITY>::c_iter +Base<ENTITY>::Begin() const +{ + return aData.begin() + 1; +} + +template <class ENTITY> +typename Base<ENTITY>::c_iter +Base<ENTITY>::BeginUnreserved() const +{ + return aData.begin() + nReservedSize; +} + +template <class ENTITY> +typename Base<ENTITY>::c_iter +Base<ENTITY>::End() const +{ + return aData.end(); +} + + + + +} // namespace stg +} // namespace ary +#endif diff --git a/autodoc/source/ary/inc/store/s_iterator.hxx b/autodoc/source/ary/inc/store/s_iterator.hxx new file mode 100644 index 000000000000..af5c991ba9a9 --- /dev/null +++ b/autodoc/source/ary/inc/store/s_iterator.hxx @@ -0,0 +1,237 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef ARY_STORE_S_ITERATOR_HXX +#define ARY_STORE_S_ITERATOR_HXX + +// USED SERVICES +#include <ary/getncast.hxx> +#include "s_base.hxx" + + + + +namespace ary +{ +namespace stg +{ + + +template <class> class const_iterator; +template <class, class> class const_filter_iterator; + + +/** A non-const iterator that runs on a ->Storage<>. + + @collab Storage<> +*/ +template <class ENTITY> +class iterator : public std::iterator<std::forward_iterator_tag, ENTITY> +{ + public: + typedef iterator<ENTITY> self; + typedef typename Base<ENTITY>::impl_type impl_container; + typedef typename impl_container::const_iterator impl_type; + + // OPERATORS + iterator() + : itImpl() {} + explicit iterator( + impl_type i_impl) + : itImpl(i_impl) {} + ~iterator() {} + + bool operator==( + self i_other ) const + { return itImpl == i_other.itImpl; } + bool operator!=( + self i_other ) const + { return itImpl != i_other.itImpl; } + ENTITY & operator*() const { csv_assert(*itImpl != 0); + return *(*itImpl); } + self & operator++() { ++itImpl; return *this; } + self operator++(int) { return self(itImpl++); } + + private: + friend class const_iterator<ENTITY>; // For const_iterator(iterator); + impl_type ImplIterator() const { return itImpl; } + + // DATA + impl_type itImpl; +}; + + +/** A const iterator that runs on a ->Storage<>. + + @collab Storage<> +*/ +template <class ENTITY> +class const_iterator : + public std::iterator<std::forward_iterator_tag, const ENTITY> +{ + public: + typedef const_iterator<ENTITY> self; + typedef typename Base<ENTITY>::impl_type impl_container; + typedef typename impl_container::const_iterator impl_type; + + // OPERATORS + const_iterator() + : itImpl() {} + explicit const_iterator( + impl_type i_impl) + : itImpl(i_impl) {} + const_iterator( // implicit conversions allowed + ::ary::stg::iterator<ENTITY> i_it ) + : itImpl(i_it.ImplIterator()) {} + ~const_iterator() {} + + bool operator==( + self i_other ) const + { return itImpl == i_other.itImpl; } + bool operator!=( + self i_other ) const + { return itImpl != i_other.itImpl; } + const ENTITY & operator*() const { csv_assert(*itImpl != 0); + return *(*itImpl); } + self & operator++() { ++itImpl; return *this; } + self operator++(int) { return self(itImpl++); } + + private: + // DATA + impl_type itImpl; +}; + + + + + +/** A non const iterator that runs on a ->Storage<> and returns only + the elements of a specific type. + + @tpl ENTITY + The element type of the ->Storage<> + + @tpl FILTER + The actual type of the returned items. FILTER needs to be derived from + ENTITY. + + @collab Storage<> +*/ +template <class ENTITY, class FILTER> +class filter_iterator : + public std::iterator<std::forward_iterator_tag, FILTER> +{ + public: + typedef filter_iterator<ENTITY,FILTER> self; + typedef ::ary::stg::iterator<ENTITY> impl_type; + + // OPERATORS + filter_iterator() + : itCur() {} + explicit filter_iterator( + impl_type i_cur ) + : itCur(i_cur) {} + ~filter_iterator() {} + + bool operator==( + self i_other ) const + { return itCur == i_other.itCur; } + bool operator!=( + self i_other ) const + { return itCur != i_other.itCur; } + FILTER & operator*() const { csv_assert(IsValid()); + return static_cast< FILTER& >(*itCur); } + self & operator++() { ++itCur; + return *this; } + self operator++(int) { return self(itCur++); } + bool IsValid() const { return ary::is_type<FILTER>(*itCur); } + + private: + friend class const_filter_iterator<ENTITY,FILTER>; // For const_filter_iterator(filter_iterator); + impl_type ImplCur() const { return itCur; } + + // DATA + impl_type itCur; +}; + + +/** A const iterator that runs on a ->Storage<> and returns only + the elements of a specific type. + + @tpl ENTITY + The element type of the ->Storage<> + + @tpl FILTER + The actual type of the returned items. FILTER needs to be derived from + ENTITY. + + @collab Storage<> +*/ +template <class ENTITY, class FILTER> +class const_filter_iterator : + public std::iterator<std::forward_iterator_tag, const FILTER> +{ + public: + typedef const_filter_iterator<ENTITY,FILTER> self; + typedef ::ary::stg::const_iterator<ENTITY> impl_type; + + // OPERATORS + const_filter_iterator() + : itCur() {} + explicit const_filter_iterator( + impl_type i_cur ) + : itCur(i_cur) {} + explicit const_filter_iterator( // implicit conversions allowed + filter_iterator<ENTITY,FILTER> + i_it ) + : itCur(i_it.ImplCur()) {} + ~const_filter_iterator() + {} + bool operator==( + self i_other ) const + { return itCur == i_other.itCur; } + bool operator!=( + self i_other ) const + { return itCur != i_other.itCur; } + const FILTER & operator*() const { csv_assert(IsValid()); + return static_cast< const FILTER& >(*itCur); } + self & operator++() { ++itCur; + return *this; } + self operator++(int) { return self(itCur++); } + bool IsValid() const { return ary::is_type<FILTER>(*itCur); } + + private: + // DATA + impl_type itCur; +}; + + + + +} // namespace stg +} // namespace ary +#endif diff --git a/autodoc/source/ary/inc/store/s_storage.hxx b/autodoc/source/ary/inc/store/s_storage.hxx new file mode 100644 index 000000000000..aace69ef6678 --- /dev/null +++ b/autodoc/source/ary/inc/store/s_storage.hxx @@ -0,0 +1,294 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef ARY_STORE_S_STORAGE_HXX +#define ARY_STORE_S_STORAGE_HXX + +// USED SERVICES +#include <ary/types.hxx> +#include "s_iterator.hxx" + + + + +namespace ary +{ +namespace stg +{ + + +/** The storage unit of one class of commomly stored repository + entities. +*/ +template <class ENTITY> +class Storage +{ + public: + typedef Base<ENTITY> container_type; + typedef ary::TypedId<ENTITY> key_type; + typedef stg::const_iterator<ENTITY> c_iter; + typedef stg::iterator<ENTITY> iter; + + // LIFECYCLE + virtual ~Storage() {} + + // OPERATORS + const ENTITY & operator[]( + key_type i_id ) const; + ENTITY & operator[]( + key_type i_id ); + const ENTITY & operator[]( + Rid i_index ) const; + ENTITY & operator[]( + Rid i_index ); + // OPERATIONS + /// Sets the id of the new entity. + key_type Store_Entity( + DYN ENTITY & pass_newEntity ); + /// Sets the id of the new entity. + void Set_Reserved( + uintt i_index, + DYN ENTITY & pass_newEntity ); + /// Sets the id of the new entity. + void Replace_Entity( + key_type i_index, + DYN ENTITY & pass_newEntity ); + // INQUIRY + bool Exists( + key_type i_id ) const; + bool Exists( + Rid i_index ) const; + + c_iter Begin() const; + c_iter BeginUnreserved() const; + c_iter End() const; + + // ACCESS + iter Begin(); + iter BeginUnreserved(); + iter End(); + + protected: + Storage( + uintt i_nrOfReservedItems ); + private: + // DATA + container_type aData; +}; + + + + + + +// IMPLEMENTATION + +// Used later, so implemented first. +template <class ENTITY> +inline bool +Storage<ENTITY>::Exists(Rid i_index) const +{ + return 0 < i_index AND i_index < aData.Size(); +} + +template <class ENTITY> +inline bool +Storage<ENTITY>::Exists(key_type i_id) const +{ + return Exists(i_id.Value()); +} + +template <class ENTITY> +inline const ENTITY & +Storage<ENTITY>::operator[](Rid i_index) const +{ + csv_assert(Exists(i_index)); + return * aData[i_index]; +} + +template <class ENTITY> +inline ENTITY & +Storage<ENTITY>::operator[](Rid i_index) +{ + csv_assert(Exists(i_index)); + return * aData[i_index]; +} + +template <class ENTITY> +inline const ENTITY & +Storage<ENTITY>::operator[](key_type i_id) const +{ + return operator[](i_id.Value()); +} + +template <class ENTITY> +inline ENTITY & +Storage<ENTITY>::operator[](key_type i_id) +{ + return operator[](i_id.Value()); +} + +template <class ENTITY> +typename Storage<ENTITY>::key_type +Storage<ENTITY>::Store_Entity(DYN ENTITY & pass_newEntity) +{ + csv_assert( aData.Size() >= aData.ReservedSize() ); + Rid + ret( aData.Add_Entity(pass_newEntity) ); + pass_newEntity.Set_Id(ret); + return key_type(ret); +} + +template <class ENTITY> +void +Storage<ENTITY>::Set_Reserved(uintt i_index, + DYN ENTITY & pass_newEntity) +{ + // 0 must not be used. + csv_assert( i_index != 0 ); + // Make sure, i_index actually is the id of a reserved item. + csv_assert( i_index < aData.ReservedSize() ); + + // If there was a previous entity, it will be deleted by + // the destructor of pOldEntity. + Dyn<ENTITY> + pOldEntity(aData.Set_Entity(i_index, pass_newEntity)); + pass_newEntity.Set_Id(i_index); +} + +template <class ENTITY> +void +Storage<ENTITY>::Replace_Entity( key_type i_index, + DYN ENTITY & pass_newEntity ) +{ + uintt + nIndex = i_index.Value(); + // Make sure, i_index actually is the id of an existing, + // non reserved entity. + csv_assert( csv::in_range(aData.ReservedSize(), nIndex, aData.Size()) ); + + // If there was a previous entity, it will be deleted by + // the destructor of pOldEntity. + Dyn<ENTITY> + pOldEntity(aData.Set_Entity(nIndex, pass_newEntity)); + pass_newEntity.Set_Id(nIndex); +} + +template <class ENTITY> +inline +typename Storage<ENTITY>::c_iter +Storage<ENTITY>::Begin() const +{ + return c_iter(aData.Begin()); +} + +template <class ENTITY> +inline +typename Storage<ENTITY>::c_iter +Storage<ENTITY>::BeginUnreserved() const +{ + return c_iter(aData.BeginUnreserved()); +} + +template <class ENTITY> +inline +typename Storage<ENTITY>::c_iter +Storage<ENTITY>::End() const +{ + return c_iter(aData.End()); +} + +template <class ENTITY> +inline +typename Storage<ENTITY>::iter +Storage<ENTITY>::Begin() +{ + return iter(aData.Begin()); +} + +template <class ENTITY> +inline +typename Storage<ENTITY>::iter +Storage<ENTITY>::BeginUnreserved() +{ + return iter(aData.BeginUnreserved()); +} + +template <class ENTITY> +inline +typename Storage<ENTITY>::iter +Storage<ENTITY>::End() +{ + return iter(aData.End()); +} + +template <class ENTITY> +inline +Storage<ENTITY>::Storage(uintt i_nrOfReservedItems) + : aData(i_nrOfReservedItems) +{ + // Make sure Rid and uintt are the same type, because + // the interface of this uses Rid, but the interface of + // container_type uses uintt. + csv_assert( sizeof(uintt) == sizeof(Rid) ); +} + + + + +// HELPER FUNCTIONS + +/** @return 0, if data are not there. +*/ +template <class ENTITY> +inline const ENTITY * +Search( const Storage<ENTITY> & i_storage, + Rid i_id ) +{ + if (NOT i_storage.Exists(i_id)) + return 0; + return &i_storage[i_id]; +} + +/** @return 0, if data are not there. +*/ +template <class ENTITY> +inline ENTITY * +SearchAccess( const Storage<ENTITY> & i_storage, + Rid i_id ) +{ + if (NOT i_storage.Exists(i_id)) + return 0; + return &i_storage[i_id]; +} + + + + +} // namespace stg +} // namespace ary +#endif diff --git a/autodoc/source/ary/inc/traits_impl.hxx b/autodoc/source/ary/inc/traits_impl.hxx new file mode 100644 index 000000000000..77c84c819ba6 --- /dev/null +++ b/autodoc/source/ary/inc/traits_impl.hxx @@ -0,0 +1,119 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef ARY_TRAITS_IMPL_HXX +#define ARY_TRAITS_IMPL_HXX + + +// USED SERVICES +#include <ary/getncast.hxx> + + +namespace ary +{ +namespace traits +{ + + +/** Finds the node assigned to an entity, if that entity has a specific + actual type. + + @tpl NODE + The assumed actual type of io_node. +*/ +template<class NODE> +const typename NODE::node_t * + NodeOf( + const typename NODE::traits_t::entity_base_type & + io_node ); + +/** Finds the node assigned to an entity, if that entity has a specific + actual type. + + @tpl NODE + The assumed actual type of io_node. +*/ +template<class NODE> +typename NODE::node_t * + NodeOf( + typename NODE::traits_t::entity_base_type & + io_node ); + +/** Finds a child to a node. +*/ +template<class NODE, class KEY> +typename NODE::traits_t::id_type + Search_Child( + const typename NODE::traits_t::entity_base_type & + i_node, + const KEY & i_localKey ); + + + + +// IMPLEMENTATION + +template<class NODE> +const typename NODE::node_t * +NodeOf(const typename NODE::traits_t::entity_base_type & io_node) +{ + const NODE * + pn = ary_cast<NODE>(&io_node); + if (pn != 0) + return & pn->AsNode(); + return 0; +} + +template<class NODE> +typename NODE::node_t * +NodeOf(typename NODE::traits_t::entity_base_type & io_node) +{ + NODE * + pn = ary_cast<NODE>(&io_node); + if (pn != 0) + return & pn->AsNode(); + return 0; +} + +template<class NODE, class KEY> +typename NODE::traits_t::id_type +Search_Child( const typename NODE::traits_t::entity_base_type & i_node, + const KEY & i_localKey ) +{ + const NODE * + pn = ary_cast<NODE>(&i_node); + if (pn != 0) + return pn->Search_Child(i_localKey); + return typename NODE::traits_t::id_type(0); +} + + + + +} // namespace traits +} // namespace ary +#endif |