pdf/plugin_impl/marker_entry_impl.h

Go to the documentation of this file.
00001 /*
00002  * File Name: marker_entry_impl.h
00003  */
00004 
00005 /*
00006  * This file is part of uds-plugin-pdf.
00007  *
00008  * uds-plugin-pdf is free software: you can redistribute it and/or modify
00009  * it under the terms of the GNU General Public License as published by
00010  * the Free Software Foundation, either version 2 of the License, or
00011  * (at your option) any later version.
00012  *
00013  * uds-plugin-pdf is distributed in the hope that it will be useful,
00014  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00015  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00016  * GNU General Public License for more details.
00017  *
00018  * You should have received a copy of the GNU General Public License
00019  * along with this program. If not, see <http://www.gnu.org/licenses/>.
00020  */
00021 
00022 /**
00023  * Copyright (C) 2008 iRex Technologies B.V.
00024  * All rights reserved.
00025  */
00026 
00027 #ifndef PDF_MARKER_ENTRY_IMPL_H_
00028 #define PDF_MARKER_ENTRY_IMPL_H_
00029 
00030 #include "plugin_inc.h"
00031 #include "pdf_collection.h"
00032 #include "string_impl.h"
00033 #include "log.h"
00034 
00035 namespace pdf
00036 {
00037 
00038 // Function to allocate a MarkerEntry structure.
00039 MarkerEntry* marker_entry_new(unsigned int uds_private_size);
00040 
00041 // Release the whole marker tree pointed by self.
00042 void marker_entry_free_recursive(MarkerEntry* self);
00043 
00044 template <>
00045 class PDFCollection<MarkerEntry *> : public PDFCollectionBase
00046 {
00047 public:
00048     PDFCollection(): vect() {}
00049     virtual ~PDFCollection() {clear();}
00050 
00051     virtual bool get_first_element(void **data_ptr)
00052     {
00053         if (size())
00054         {
00055             *data_ptr = static_cast<void *>(&vect[0]);
00056             return true;
00057         }
00058         return false;
00059     }
00060 
00061     virtual int get_count()
00062     {
00063         return size();
00064     }
00065 
00066     void add(MarkerEntry* t)
00067     {
00068         vect.push_back(t);
00069     }
00070 
00071     void clear()
00072     {
00073         VectIter begin = vect.begin();
00074         VectIter end   = vect.end();
00075         VectIter iter  = begin;
00076         for(; iter != end; ++iter)
00077         {
00078             MarkerEntry* first_child = reinterpret_cast<MarkerEntry *>(*iter);
00079             marker_entry_free_recursive(first_child);
00080         }
00081         vect.clear();
00082     }
00083 
00084     MarkerEntry* get(int num)
00085     {
00086         assert(num >= 0 && num < static_cast<int>(vect.size()));
00087 
00088         return vect[num];
00089     }
00090 
00091     MarkerEntry* front()
00092     {
00093         if (size() > 0)
00094         {
00095             return vect[0];
00096         }
00097         return 0;
00098     }
00099 
00100     MarkerEntry* back()
00101     {
00102         if (size() > 0)
00103         {
00104             return vect[size()-1];
00105         }
00106         return 0;
00107     }
00108 
00109     int size()
00110     {
00111         return static_cast<int>(vect.size());
00112     }
00113 
00114 private:
00115     typedef std::vector<MarkerEntry *> Vect;
00116     typedef std::vector<MarkerEntry *>::iterator VectIter;
00117 
00118 private:
00119     Vect vect;
00120 };
00121 
00122 };  // namespace pdf
00123 
00124 #endif
Generated by  doxygen 1.6.2-20100208