collection.h

Go to the documentation of this file.
00001 /*
00002  * Copyright 2006-2008 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_COLLECTION_API_H
00017 #define ZORBA_COLLECTION_API_H
00018 
00019 #include <zorba/api_shared_types.h>
00020 #include <zorba/item.h>
00021 
00022 namespace zorba {
00023 
00024 /** \brief A Collection is a sequence of Node Items.
00025  *
00026  * Each Collection is created by the XmlDataManager and referenced by a URI.
00027  * The URI can be accessed in a query's fn:collection function.
00028  */
00029 class Collection
00030 {
00031   public:
00032     /** \brief Destructor
00033      */
00034     virtual ~Collection() {}
00035 
00036     /** \brief Get the URI of a collection as an anyURI Item.
00037      *
00038      * @return Item the anyURI Item of the Collection.
00039      */
00040     virtual Item
00041     getUri() = 0;
00042 
00043     /** \brief Adds a Node Item to the Collection
00044      *
00045      * @param aItem the Node Item to add.
00046      * @return true if the Node Item was added to the Collection, false otherwise.
00047      */
00048     virtual bool
00049     addItem(const Item& aItem) = 0;
00050 
00051     /** \brief Deletes the given Item from the Collection.
00052      *
00053      * @param aItem the Node Item to delete
00054      * @return true if the given Node Item was deleted, false otherwise.
00055      */
00056     virtual bool
00057     deleteItem(const Item& aItem) = 0;
00058 
00059     /** \brief Adds the Node Items retrieved from the given ResultIterator to the Collection.
00060      *
00061      * @param aResultIterator the ResultIterator that produces the Node Items to add.
00062      * @return true if all the Node Items of the given ResultIterator were added to the Collection,
00063      *         false otherwise.
00064      */
00065     virtual bool
00066     addItems(const ResultIterator_t& aResultIterator) = 0;
00067 
00068     /** \brief Adds the document retrieved from the given input stream to the Collection.
00069      *
00070      * @param aInStream the input stream from which to parse the document.
00071      * @return true if the document was added to the collection (e.g. was a valid document), 
00072      *         false otherwise.
00073      */
00074     virtual bool
00075     addDocument(std::istream& aInStream) = 0;
00076 
00077 }; /* class Collection */
00078 
00079 } /* namespace zorba */
00080 
00081 #endif