00001 /******************************************************************************* 00002 * arch-tag: Matthieu MOY, Fri Apr 16 15:52:37 2004 (scp-utils.h) 00003 *------------------------------------------------------------------------------ 00004 * Copyright (c) STMicroelectronics,Verimag 00005 * Pinapa is free software; you can redistribute it and/or 00006 * modify it under the terms of the GNU Lesser General Public 00007 * License as published by the Free Software Foundation; either 00008 * version 2 of the License, or (at your option) any later version. 00009 * 00010 * This library is distributed in the hope that it will be useful, 00011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00013 * Library General Public License for more details. 00014 * 00015 * You should have received a copy of the GNU Lesser General Public 00016 * License along with this library; if not, write to the Free 00017 * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, 00018 * MA 02111-1307, USA 00019 *------------------------------------------------------------------------------ 00020 * System Platform Group - HPC 00021 *******************************************************************************/ 00022 00031 #include "pinapa-parser-all.h" 00032 00033 #ifndef PINAPA_UTILS_H 00034 #define PINAPA_UTILS_H 00035 00036 #include <vector> 00037 00038 namespace pinapa { 00039 00045 template <typename T> 00046 class resizeable_array : public vector<T> { 00047 public: 00049 T& operator[](size_t __n) { 00050 if (__n >= vector<T>::size()) vector<T>::resize(__n + 1); return *(vector<T>::begin() + __n); } 00053 const T& operator[](size_t __n) const { 00054 PINAPA_ASSERT(__n >= vector<T>::size(), "Const array too small !"); 00055 return *(vector<T>::begin() + __n); } 00056 }; 00057 00061 template <typename T, typename P> 00062 bool instance_of( P p){ 00063 return NULL != dynamic_cast<T>(p); 00064 } 00065 00066 } 00067 00068 #endif // PINAPA_UTILS_H