merge the formfield patch from ooo-build
[ooovba.git] / autodoc / source / ary / inc / traits_impl.hxx
blob3194b3bdf982211dbfaec545539c6d329444b014
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: traits_impl.hxx,v $
10 * $Revision: 1.3 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef ARY_TRAITS_IMPL_HXX
32 #define ARY_TRAITS_IMPL_HXX
35 // USED SERVICES
36 #include <ary/getncast.hxx>
39 namespace ary
41 namespace traits
45 /** Finds the node assigned to an entity, if that entity has a specific
46 actual type.
48 @tpl NODE
49 The assumed actual type of io_node.
51 template<class NODE>
52 const typename NODE::node_t *
53 NodeOf(
54 const typename NODE::traits_t::entity_base_type &
55 io_node );
57 /** Finds the node assigned to an entity, if that entity has a specific
58 actual type.
60 @tpl NODE
61 The assumed actual type of io_node.
63 template<class NODE>
64 typename NODE::node_t *
65 NodeOf(
66 typename NODE::traits_t::entity_base_type &
67 io_node );
69 /** Finds a child to a node.
71 template<class NODE, class KEY>
72 typename NODE::traits_t::id_type
73 Search_Child(
74 const typename NODE::traits_t::entity_base_type &
75 i_node,
76 const KEY & i_localKey );
81 // IMPLEMENTATION
83 template<class NODE>
84 const typename NODE::node_t *
85 NodeOf(const typename NODE::traits_t::entity_base_type & io_node)
87 const NODE *
88 pn = ary_cast<NODE>(&io_node);
89 if (pn != 0)
90 return & pn->AsNode();
91 return 0;
94 template<class NODE>
95 typename NODE::node_t *
96 NodeOf(typename NODE::traits_t::entity_base_type & io_node)
98 NODE *
99 pn = ary_cast<NODE>(&io_node);
100 if (pn != 0)
101 return & pn->AsNode();
102 return 0;
105 template<class NODE, class KEY>
106 typename NODE::traits_t::id_type
107 Search_Child( const typename NODE::traits_t::entity_base_type & i_node,
108 const KEY & i_localKey )
110 const NODE *
111 pn = ary_cast<NODE>(&i_node);
112 if (pn != 0)
113 return pn->Search_Child(i_localKey);
114 return typename NODE::traits_t::id_type(0);
120 } // namespace traits
121 } // namespace ary
122 #endif