entries_allocation_table.h
Go to the documentation of this file.
00001 /****************************************************************************
00002 * VCGLib                                                            o o     *
00003 * Visual and Computer Graphics Library                            o     o   *
00004 *                                                                _   O  _   *
00005 * Copyright(C) 2004                                                \/)\/    *
00006 * Visual Computing Lab                                            /\/|      *
00007 * ISTI - Italian National Research Council                           |      *
00008 *                                                                    \      *
00009 * All rights reserved.                                                      *
00010 *                                                                           *
00011 * This program is free software; you can redistribute it and/or modify      *   
00012 * it under the terms of the GNU General Public License as published by      *
00013 * the Free Software Foundation; either version 2 of the License, or         *
00014 * (at your option) any later version.                                       *
00015 *                                                                           *
00016 * This program is distributed in the hope that it will be useful,           *
00017 * but WITHOUT ANY WARRANTY; without even the implied warranty of            *
00018 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the             *
00019 * GNU General Public License (http://www.gnu.org/licenses/gpl.txt)          *
00020 * for more details.                                                         *
00021 *                                                                           *
00022 ****************************************************************************/
00023 
00024 #ifndef __VCGLIB_ENTRIES__
00025 #define __VCGLIB_ENTRIES__
00026 
00027 
00028 namespace vcg {
00029 
00030 // EntryCATBase: base class for the entry of the allocation table
00031 // templated over the container type
00032 template <class STL_CONT>
00033 class EntryCATBase{
00034 public:
00035 EntryCATBase(STL_CONT & _c):c(_c){};
00036 typename STL_CONT::value_type * Start() const;
00037 virtual bool Empty(){return true;};
00038 const STL_CONT *  C();
00039 virtual void Push_back(const int &){};
00040 
00041 virtual void Reserve(const int & s){};
00042 virtual void Resize(const int & s){};
00043 
00044 const bool operator < (const EntryCATBase<STL_CONT> & other) const;
00045 
00046 private:
00047         STL_CONT & c;
00048 };
00049 
00050 //EntryCAT: entry for the case of optional core types (matches with CAT)
00051 template <class STL_CONT,class ATTR_TYPE >
00052 struct EntryCAT: public EntryCATBase<STL_CONT>{
00053 typedef ATTR_TYPE attr_type;
00054 EntryCAT(STL_CONT & _c) : EntryCATBase<STL_CONT>(_c){};
00055 std::vector<ATTR_TYPE> & Data(){return data;}
00056 void Push_back(const int & n){ for(int i = 0; i < n ; ++i) data.push_back(ATTR_TYPE());}
00057 virtual void Reserve(const int & s){data.reserve(s);};
00058 virtual void Resize(const int & s){data.resize(s);};
00059 
00060 
00061 private:
00062 std::vector<ATTR_TYPE> data;
00063 };
00064 
00065 //----------------------EntryCAT: implementation ----------------------------------------
00066 template <class STL_CONT>
00067 const bool EntryCATBase<STL_CONT>:: operator < (const EntryCATBase<STL_CONT> & other) const{
00068         return (Start() < other.Start());
00069 }
00070 
00071 template <class STL_CONT>
00072  typename STL_CONT::value_type  * EntryCATBase<STL_CONT>::Start()const {
00073         return  c.Pointer2begin();
00074         }
00075 
00076 template <class STL_CONT>
00077         const STL_CONT * EntryCATBase<STL_CONT>::C(){
00078         return &c;
00079         }
00080 
00081 
00082 
00083 }; // end namespace vcg
00084 
00085 #endif


shape_reconstruction
Author(s): Roberto Martín-Martín
autogenerated on Sat Jun 8 2019 18:30:49