merge the formfield patch from ooo-build
[ooovba.git] / configmgr / source / inc / nodechange.hxx
blob30536d85d04d03b44ae91f88d8e8f48c37c8e9ca
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: nodechange.hxx,v $
10 * $Revision: 1.9 $
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 CONFIGMGR_CONFIGCHANGE_HXX_
32 #define CONFIGMGR_CONFIGCHANGE_HXX_
34 #include "rtl/ref.hxx"
36 #include "configexcept.hxx"
38 #include <vector>
40 namespace configmgr
42 namespace configuration
44 //-----------------------------------------------------------------------------
45 class AbsolutePath;
46 class RelativePath;
47 class NodeRef;
48 class NodeID;
49 class SubNodeID;
50 class Tree;
51 //-----------------------------------------------------------------------------
53 class NodeChange;
54 class NodeChangeImpl;
55 class NodeChangeLocation;
56 class NodeChangeInformation;
57 class NodeChangesInformation;
58 //-----------------------------------------------------------------------------
60 /// represents a node position in some tree
61 class NodeChange
63 public:
64 /// constructs an empty (unchanging) node change
65 NodeChange();
66 /// constructs a node change with a given implementation
67 NodeChange(NodeChangeImpl* pImpl);
68 /// copies a node change with reference semantics
69 NodeChange(NodeChange const& rOther);
70 /// copies a node change with reference semantics
71 NodeChange& operator=(NodeChange const& rOther);
72 /// swaps the contents of this with another NodeChange
73 void swap(NodeChange& rOther);
74 /// destroys a node change
75 ~NodeChange();
77 /// checks, if this may represent an actual change (might not be tested)
78 bool maybeChange() const;
79 /// checks, if this represents an actual change (PRE: must be tested)
80 bool isChange() const;
81 /// retrieve information about the changed data, appending to a sequence, returning the count
82 sal_uInt32 getChangeInfos(NodeChangesInformation& rInfo) const;
83 /// retrieve information about what node is changed
84 bool getChangeLocation(NodeChangeLocation& rLoc) const;
86 /// test whether this would really be a change (as close as possible)
87 NodeChange& test();
88 NodeChange const& test() const;
90 /// apply this change and check whether the target node changed
91 NodeChange& apply();
92 NodeChange const& apply() const;
94 // retrieve the tree where the change is actually taking place
95 rtl::Reference< Tree > getAffectedTree() const;
96 // retrieve the node where the change is actually taking place
97 NodeRef getAffectedNode() const;
99 // Comparison
100 friend bool operator==(NodeChange const& lhs, NodeChange const& rhs)
102 return lhs.m_pImpl == rhs.m_pImpl;
104 friend bool operator!=(NodeChange const& lhs, NodeChange const& rhs)
106 return lhs.m_pImpl != rhs.m_pImpl;
109 /// provides access to the internal Implementation for related classes
110 NodeChangeImpl* impl() const { return m_pImpl; }
111 private:
112 NodeChangeImpl* m_pImpl;
113 void init(), deinit();
116 /** represents a collection of updates to nodes (identified by <type>NodeChange</type>s) within a hierarchy of config entries
118 class NodeChanges
120 public:
121 /// Constructs an empty collection of changes
122 NodeChanges();
124 /// checks whether there are any (non-empty) changes in this
125 bool isEmpty() const;
127 /// retrieves the total count of changes in this collection
128 std::vector<NodeChange>::size_type getCount() const { return m_aChanges.size(); }
130 /// retrieve information about the changed data, appending to a sequence, returning the count
131 sal_uInt32 getChangesInfos(NodeChangesInformation& rInfos) const;
133 /// test all changes
134 NodeChanges& test() { implTest(); return *this; }
135 NodeChanges const& test() const { implTest(); return *this; }
137 /// remove all changes known to be doing nothing from this collection.
138 NodeChanges& compact();
140 /** insert a change into this collection
142 void add(NodeChange const& aChange);
144 /// returns an STL-style iterator to the first element of the collection
145 std::vector<NodeChange>::const_iterator begin() const { return m_aChanges.begin(); }
146 std::vector<NodeChange>::iterator begin() { return m_aChanges.begin(); }
148 /// returns an STL-style iterator to past the last element of the collection
149 std::vector<NodeChange>::const_iterator end() const { return m_aChanges.end(); }
150 std::vector<NodeChange>::iterator end() { return m_aChanges.end(); }
152 private:
153 void implTest() const;
154 std::vector<NodeChange> m_aChanges;
160 #endif // CONFIGMGR_CONFIGCHANGE_HXX_