collection_manager.h
Go to the documentation of this file.
00001 /*
00002  * Copyright 2006-2011 The FLWOR Foundation.
00003  *
00004  * Licensed under the Apache License, Version 2.0 (the "License");
00005  * you may not use this file except in compliance with the License.
00006  * You may obtain a copy of the License at
00007  *
00008  * http://www.apache.org/licenses/LICENSE-2.0
00009  *
00010  * Unless required by applicable law or agreed to in writing, software
00011  * distributed under the License is distributed on an "AS IS" BASIS,
00012  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00013  * See the License for the specific language governing permissions and
00014  * limitations under the License.
00015  */
00016 #ifndef ZORBA_COLLECTIONMANAGER_API_H
00017 #define ZORBA_COLLECTIONMANAGER_API_H
00018 
00019 #include <zorba/config.h>
00020 #include <zorba/api_shared_types.h>
00021 
00022 namespace zorba {
00023 
00024   /** \brief This class defines a set of functions for managing persistent
00025    *         collections.
00026    *
00027    */
00028   class ZORBA_DLL_PUBLIC CollectionManager
00029   {
00030   public:
00031     /**
00032      * This function creates the collection with the given name.
00033      *
00034      * @param aName The name of the collection to create.
00035      *
00036      * @throw XDDY0002 if a collection with the given name already exists.
00037      *
00038      */
00039     virtual void
00040     createCollection(const Item& aName) = 0;
00041 
00042     /**
00043      * This function creates the collection with the given name.
00044      * Moreover, it adds copies of the sequence aContents to the new collection.
00045      *
00046      * @param aName The name of the collection to create.
00047      * @param aContents The sequence of items.
00048      *
00049      * @throw XDDY0002 if a collection with the given name already exists.
00050      *
00051      */
00052     virtual void
00053     createCollection(
00054         const Item& aName,
00055         const ItemSequence_t& aContents) = 0;
00056 
00057     /**
00058      * This function removes the collection with the given name.
00059      *
00060      * @param aName The name of the collection to delete.
00061      *
00062      * @throw XDDY0003 if the collection does not exist.
00063      */
00064     virtual void
00065     deleteCollection(const Item& aName) = 0;
00066 
00067     /**
00068      * Returns a instance of the Collection class which can
00069      * be used to modify and retrieve the contents of the collection
00070      * identified by the given name.
00071      *
00072      * @param aName The name of the collection to retrieve.
00073      *
00074      * @throw XDDY0003 if the collection does not exist.
00075      */
00076     virtual Collection_t
00077     getCollection(const Item& aName) const = 0;
00078 
00079     /**
00080      * This function returns a sequence of names of the collections
00081      * that are available. If this is an instance of the StaticCollectionManager
00082      * class (i.e. returned by any of the getStaticCollectionManager methods),
00083      * the collections returned by this function are also
00084      * statically declared.
00085      *
00086      * @return The list of names of the available collections.
00087      *
00088      */
00089     virtual ItemSequence_t
00090     availableCollections() const = 0;
00091 
00092     /**
00093      * This function returns true if a collection with the given name is available.
00094      * If this is an instance of the StaticCollectionManager class (i.e.
00095      * returned by any of the getStaticCollectionManager() methods),
00096      * the collection also needs to be statically declared.
00097      *
00098      * @param aName The name of the collection that is being checked.
00099      *
00100      * @return true if the collection is available and false otherwise.
00101      *
00102      */
00103     virtual bool
00104     isAvailableCollection(const Item& aName) const = 0;
00105 
00106     /** \brief Register a DiagnosticHandler to which errors
00107      * occuring during the management of collections are reported.
00108      *
00109      * If no DiagnosticHandler has been set using this function or
00110      * the corresponding function of the XmlDataManager then
00111      * subclasses of the ZorbaException class are thrown to report
00112      * errors.
00113      *
00114      * @param aDiagnosticHandler DiagnosticHandler to which errors
00115      *        are reported. The caller retains ownership over the
00116      *        DiagnosticHandler passed as parameter.
00117      */
00118     virtual void
00119     registerDiagnosticHandler(DiagnosticHandler* aDiagnosticHandler) = 0;
00120 
00121     /** \brief Destructor
00122      *
00123      */
00124     virtual ~CollectionManager() {}
00125 
00126   }; /* class CollectionManager */
00127 
00128 } /* namespace zorba */
00129 #endif
00130 
00131 /* vim:set et sw=2 ts=2: */
blog comments powered by Disqus