csutil/nobjvec.h
Go to the documentation of this file.00001 /* 00002 Crystal Space: Named Object Vector class 00003 Copyright (C) 1998,1999 by Andrew Zabolotny <bit@eltech.ru> 00004 00005 This library is free software; you can redistribute it and/or 00006 modify it under the terms of the GNU Library 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 Library General Public 00016 License along with this library; if not, write to the Free 00017 Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 00018 */ 00019 00020 #ifndef __CS_NOBJVEC_H__ 00021 #define __CS_NOBJVEC_H__ 00022 00023 #include "refarr.h" 00024 #include "iutil/object.h" 00025 00036 template <class T> 00037 class csRefArrayObject : public csRefArray<T> 00038 { 00039 public: 00040 csRefArrayObject (int ilimit = 0, int ithreshold = 0) 00041 : csRefArray<T> (ilimit, ithreshold) 00042 { 00043 } 00044 00045 int GetIndexByName (const char* name) const 00046 { 00047 int i; 00048 for (i = 0 ; i < Length () ; i++) 00049 { 00050 T* o = (*this)[i]; 00051 const char* n = o->QueryObject ()->GetName (); 00052 if (n && !strcmp (n, name)) 00053 return i; 00054 } 00055 return -1; 00056 } 00057 00058 T* FindByName (const char* name) const 00059 { 00060 int i = GetIndexByName (name); 00061 if (i != -1) 00062 return (*this)[i]; 00063 else 00064 return 0; 00065 } 00066 }; 00067 00068 00069 #endif // __CS_NOBJVEC_H__
Generated for Crystal Space by doxygen 1.2.18