CollectionManager.h
Go to the documentation of this file.
1 /*
2  * Copyright 2006-2012 The FLWOR Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 #ifndef API_COLLECTION_MANAGER_H
17 #define API_COLLECTION_MANAGER_H
18 
19  /** \brief This class defines a set of functions for managing persistent
20  * collections.
21  *
22  */
24 {
25 private:
26  zorba::CollectionManager* theManager;
27 
28 public:
29  CollectionManager(const CollectionManager& aMgr) : theManager(aMgr.theManager) {}
30  CollectionManager(zorba::CollectionManager* aMgr) : theManager(aMgr) {}
31 
32  /**
33  * This function returns a sequence of names of the collections
34  * that are available. If this is an instance of the StaticCollectionManager
35  * class (i.e. returned by any of the getStaticCollectionManager methods),
36  * the collections returned by this function are also
37  * statically declared.
38  *
39  * @return The list of names of the available collections.
40  *
41  */
43 
44  /**
45  * This function creates the collection with the given name.
46  *
47  * @param aName The name of the collection to create.
48  *
49  * @throw XDDY0002 if a collection with the given name already exists.
50  *
51  */
52  void createCollection(const Item &aName );
53 
54  /**
55  * This function creates the collection with the given name.
56  * Moreover, it adds copies of the sequence aContents to the new collection.
57  *
58  * @param aName The name of the collection to create.
59  * @param aContents The sequence of items.
60  *
61  * @throw XDDY0002 if a collection with the given name already exists.
62  *
63  */
64  void createCollection(const Item &aName, const ItemSequence &aContents );
65 
66  /**
67  * This function removes the collection with the given name.
68  *
69  * @param aName The name of the collection to delete.
70  *
71  * @throw XDDY0003 if the collection does not exist.
72  */
73  void deleteCollection(const Item &aName );
74 
75  /**
76  * Returns a instance of the Collection class which can
77  * be used to modify and retrieve the contents of the collection
78  * identified by the given name.
79  *
80  * @param aName The name of the collection to retrieve.
81  *
82  * @throw XDDY0003 if the collection does not exist.
83  */
84  Collection getCollection(const Item &aName );
85 
86  /**
87  * This function returns true if a collection with the given name is available.
88  * If this is an instance of the StaticCollectionManager class (i.e.
89  * returned by any of the getStaticCollectionManager() methods),
90  * the collection also needs to be statically declared.
91  *
92  * @param aName The name of the collection that is being checked.
93  *
94  * @return true if the collection is available and false otherwise.
95  *
96  */
97  bool isAvailableCollection(const Item &aName );
98 
99  /** \brief Register a DiagnosticHandler to which errors
100  * occuring during the management of collections are reported.
101  *
102  * If no DiagnosticHandler has been set using this function or
103  * the corresponding function of the XmlDataManager then
104  * subclasses of the ZorbaException class are thrown to report
105  * errors.
106  *
107  * @param aDiagnosticHandler DiagnosticHandler to which errors
108  * are reported. The caller retains ownership over the
109  * DiagnosticHandler passed as parameter.
110  */
111  void registerDiagnosticHandler(DiagnosticHandler *aDiagnosticHandler);
112 
113 };
114 
115 #endif
CollectionManager(zorba::CollectionManager *aMgr)
void registerDiagnosticHandler(DiagnosticHandler *aDiagnosticHandler)
Register a DiagnosticHandler to which errors occuring during the management of collections are report...
This interface represents an instance of the XQuery 1.0 and XPath 2.0 Data Model (XDM).
Definition: ItemSequence.h:25
ItemSequence availableCollections()
This function returns a sequence of names of the collections that are available.
void createCollection(const Item &aName)
This function creates the collection with the given name.
A Collection is a persistent sequence of node items.
Definition: Collection.h:29
This class defines a set of functions for managing persistent collections.
void deleteCollection(const Item &aName)
This function removes the collection with the given name.
When registered with an XQuery object, a DiagnosticHandler handles all exceptions that otherwise woul...
The Zorba Item interface.
Definition: Item.h:39
bool isAvailableCollection(const Item &aName)
This function returns true if a collection with the given name is available.
CollectionManager(const CollectionManager &aMgr)
Collection getCollection(const Item &aName)
Returns a instance of the Collection class which can be used to modify and retrieve the contents of t...