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/config.h>
00020 #include <zorba/api_shared_types.h>
00021 #include <zorba/item.h>
00022 
00023 namespace zorba {
00024 
00025 /** \brief A Collection is a sequence of Node Items.
00026  *
00027  * Each Collection is created by the XmlDataManager and referenced by a URI.
00028  * The URI can be accessed in a query's fn:collection function.
00029  *
00030  * Note: This class is reference counted. When writing multi-threaded clients,
00031  * it is the responibility of the client code to synchronize assignments to the
00032  * SmartPtr holding this object.
00033  */
00034 class ZORBA_EXTERN_DECL Collection : public SmartObject
00035 {
00036   public:
00037     /** \brief Destructor
00038      */
00039     virtual ~Collection() {}
00040 
00041     /** \brief Get the URI of a collection as an anyURI Item.
00042      *
00043      * @return Item the anyURI Item of the Collection.
00044      */
00045     virtual Item
00046     getUri() = 0;
00047 
00048     /** \brief Adds a Node Item to the Collection
00049      *
00050      * @param aNode the Node Item to add.
00051      * @return true if the Node Item was added to the Collection, false otherwise.
00052      */
00053     virtual bool
00054     addNode(const Item& aNode) = 0;
00055 
00056     /** \brief Deletes the given Item from the Collection.
00057      *
00058      * @param aNode the Node Item to delete
00059      * @return true if the given Node Item was deleted, false otherwise.
00060      */
00061     virtual bool
00062     deleteNode(const Item& aNode) = 0;
00063 
00064     /** \brief Adds the Node Items retrieved from the given ResultIterator to the Collection.
00065      *
00066      * @param aResultIterator the ResultIterator that produces the Node Items to add.
00067      * @return true if all the Node Items of the given ResultIterator were added to the Collection,
00068      *         false otherwise.
00069      */
00070     virtual bool
00071     addNodes(const ResultIterator* aResultIterator) = 0;
00072 
00073     /** \brief Adds the document retrieved from the given input stream to the Collection.
00074      *
00075      * @param aInStream the input stream from which to parse the document.
00076      * @return true if the document was added to the collection (e.g. was a valid document), 
00077      *         false otherwise.
00078      */
00079     virtual bool
00080     addDocument(std::istream& aInStream) = 0;
00081 
00082 }; /* class Collection */
00083 
00084 } /* namespace zorba */
00085 
00086 #endif