1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: nodefactory.cxx,v $
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 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_configmgr.hxx"
34 #include "nodefactory.hxx"
35 #include "nodeimplobj.hxx"
36 #include "configpath.hxx"
37 #include <osl/diagnose.h>
41 //-----------------------------------------------------------------------------
45 // Creating Specific types of nodes
46 //-----------------------------------------------------------------------------
49 //---------------------------------------------------------------------
50 struct BasicNodeFactory
: NodeFactory
52 rtl::Reference
<configuration::NodeImpl
> makeValueNode(sharable::ValueNode
* node
);
53 rtl::Reference
<configuration::NodeImpl
> makeGroupNode(sharable::GroupNode
* node
);
54 rtl::Reference
<configuration::NodeImpl
> makeSetNode(sharable::SetNode
* node
, configuration::Template
* pTemplate
);
56 //-------------------------------------------------------------------------
58 rtl::Reference
<configuration::NodeImpl
> BasicNodeFactory::makeValueNode(sharable::ValueNode
* node
)
60 return new configuration::ValueElementNodeImpl(node
);
62 //-------------------------------------------------------------------------
64 rtl::Reference
<configuration::NodeImpl
> BasicNodeFactory::makeGroupNode(sharable::GroupNode
* node
)
66 return new configuration::GroupNodeImpl(node
);
68 //-------------------------------------------------------------------------
70 rtl::Reference
<configuration::NodeImpl
> BasicNodeFactory::makeSetNode(sharable::SetNode
* node
, configuration::Template
* pTemplate
)
72 return new configuration::SetNodeImpl(node
, pTemplate
);
74 //-------------------------------------------------------------------------
76 //-----------------------------------------------------------------------------
78 struct DeferredNodeFactory
: NodeFactory
80 rtl::Reference
<configuration::NodeImpl
> makeValueNode(sharable::ValueNode
* node
);
81 rtl::Reference
<configuration::NodeImpl
> makeGroupNode(sharable::GroupNode
* node
);
82 rtl::Reference
<configuration::NodeImpl
> makeSetNode(sharable::SetNode
* node
, configuration::Template
* pTemplate
);
84 //-------------------------------------------------------------------------
86 rtl::Reference
<configuration::NodeImpl
> DeferredNodeFactory::makeValueNode(sharable::ValueNode
* node
)
88 // OSL_ENSURE(false, "Wrong factory for value elements - should be immutable (=read-only)");
89 return new configuration::ValueElementNodeImpl(node
);
91 //-------------------------------------------------------------------------
93 rtl::Reference
<configuration::NodeImpl
> DeferredNodeFactory::makeGroupNode(sharable::GroupNode
* node
)
95 return new configuration::DeferredGroupNodeImpl(node
);
97 //-------------------------------------------------------------------------
99 rtl::Reference
<configuration::NodeImpl
> DeferredNodeFactory::makeSetNode(sharable::SetNode
* node
, configuration::Template
* pTemplate
)
101 return new configuration::DeferredSetNodeImpl(node
, pTemplate
);
103 //-------------------------------------------------------------------------
105 //-----------------------------------------------------------------------------
107 //-----------------------------------------------------------------------------
109 // Different standard (static) factories
110 //---------------------------------------------------------------------
112 /// provides a factory for immediately commiting node implementations
113 NodeFactory
& getDirectAccessFactory()
115 static BasicNodeFactory aFactory
;
118 /// provides a factory for read-only node implementations
119 NodeFactory
& getReadAccessFactory()
121 static BasicNodeFactory aFactory
;
124 /// provides a factory for nodes that cache changes temporarily
125 NodeFactory
& getDeferredChangeFactory()
127 static DeferredNodeFactory aFactory
;
131 //---------------------------------------------------------------------
134 //-----------------------------------------------------------------------------