collection_manager.h
Go to the documentation of this file.
1 /*
2  * Copyright 2006-2011 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 ZORBA_COLLECTIONMANAGER_API_H
17 #define ZORBA_COLLECTIONMANAGER_API_H
18 
19 #include <zorba/config.h>
20 #include <zorba/api_shared_types.h>
21 
22 namespace zorba {
23 
24  /** \brief This class defines a set of functions for managing persistent
25  * collections.
26  *
27  */
28  class ZORBA_DLL_PUBLIC CollectionManager
29  {
30  public:
31  /**
32  * This function creates the collection with the given name.
33  *
34  * @param aName The name of the collection to create.
35  *
36  * @throw XDDY0002 if a collection with the given name already exists.
37  *
38  */
39  virtual void
40  createCollection(const Item& aName) = 0;
41 
42  /**
43  * This function creates the collection with the given name.
44  * Moreover, it adds copies of the sequence aContents to the new collection.
45  *
46  * @param aName The name of the collection to create.
47  * @param aContents The sequence of items.
48  *
49  * @throw XDDY0002 if a collection with the given name already exists.
50  *
51  */
52  virtual void
53  createCollection(
54  const Item& aName,
55  const ItemSequence_t& aContents) = 0;
56 
57  /**
58  * This function removes the collection with the given name.
59  *
60  * @param aName The name of the collection to delete.
61  *
62  * @throw XDDY0003 if the collection does not exist.
63  */
64  virtual void
65  deleteCollection(const Item& aName) = 0;
66 
67  /**
68  * Returns a instance of the Collection class which can
69  * be used to modify and retrieve the contents of the collection
70  * identified by the given name.
71  *
72  * @param aName The name of the collection to retrieve.
73  *
74  * @throw XDDY0003 if the collection does not exist.
75  */
76  virtual Collection_t
77  getCollection(const Item& aName) const = 0;
78 
79  /**
80  * This function returns a sequence of names of the collections
81  * that are available. If this is an instance of the StaticCollectionManager
82  * class (i.e. returned by any of the getStaticCollectionManager methods),
83  * the collections returned by this function are also
84  * statically declared.
85  *
86  * @return The list of names of the available collections.
87  *
88  */
89  virtual ItemSequence_t
90  availableCollections() const = 0;
91 
92  /**
93  * This function returns true if a collection with the given name is available.
94  * If this is an instance of the StaticCollectionManager class (i.e.
95  * returned by any of the getStaticCollectionManager() methods),
96  * the collection also needs to be statically declared.
97  *
98  * @param aName The name of the collection that is being checked.
99  *
100  * @return true if the collection is available and false otherwise.
101  *
102  */
103  virtual bool
104  isAvailableCollection(const Item& aName) const = 0;
105 
106  /** \brief Register a DiagnosticHandler to which errors
107  * occuring during the management of collections are reported.
108  *
109  * If no DiagnosticHandler has been set using this function or
110  * the corresponding function of the XmlDataManager then
111  * subclasses of the ZorbaException class are thrown to report
112  * errors.
113  *
114  * @param aDiagnosticHandler DiagnosticHandler to which errors
115  * are reported. The caller retains ownership over the
116  * DiagnosticHandler passed as parameter.
117  */
118  virtual void
119  registerDiagnosticHandler(DiagnosticHandler* aDiagnosticHandler) = 0;
120 
121  /** \brief Destructor
122  *
123  */
124  virtual ~CollectionManager() {}
125 
126  }; /* class CollectionManager */
127 
128 } /* namespace zorba */
129 #endif
130 
131 /* vim:set et sw=2 ts=2: */
blog comments powered by Disqus