CrystalSpace

Public API Reference

Main Page   Modules   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Related Pages  

symtable.h

00001 /*
00002     Copyright (C) 2003 by Mat Sutcliffe <oktal@gmx.co.uk>
00003 
00004     This library is free software; you can redistribute it and/or
00005     modify it under the terms of the GNU Lesser General Public
00006     License as published by the Free Software Foundation; either
00007     version 2 of the License, or (at your option) any later version.
00008 
00009     This library is distributed in the hope that it will be useful,
00010     but WITHOUT ANY WARRANTY; without even the implied warranty of
00011     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012     Library General Public License for more details.
00013 
00014     You should have received a copy of the GNU Library General Public
00015     License along with this library; if not, write to the Free
00016     Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00017 */
00018 
00019 #ifndef __CS_CSUTIL_SYMTABLE_H__
00020 #define __CS_CSUTIL_SYMTABLE_H__
00021 
00022 #include "csutil/scf.h"
00023 #include "csutil/ref.h"
00024 #include "csutil/strhash.h"
00025 #include "csutil/array.h"
00026 
00027 class csShaderVariable;
00028 
00037 class csSymbolTable
00038 {
00039 private:
00040   struct Stack
00041   {
00042     struct Symbol
00043     {
00044       csSymbolTable *Owner;
00045       csRef<csShaderVariable> Val;
00046 
00047       inline Symbol (csShaderVariable *value, csSymbolTable *owner);
00048       inline Symbol (const Symbol &other);
00049     };
00050     csArray<Symbol> Vals;
00051     csStringID Name;
00052 
00053     inline Stack (csStringID id);
00054     inline Stack (csStringID id, const csArray<Symbol> &vals);
00055     inline Stack (csStringID id, csShaderVariable *value, csSymbolTable *owner);
00056   };
00057 
00058 protected:
00059   csHashMap Hash;
00060 
00061   csArray<csSymbolTable*> Children;
00062   csSymbolTable *Parent;
00063 
00064   void Propagate (const Stack *stack);
00065 
00066 public:
00072   csSymbolTable (int size = 53) : Hash (size), Parent (0) {}
00073 
00080   csSymbolTable (const csSymbolTable &other, int size = 53);
00081 
00085   ~csSymbolTable ();
00086 
00088   void AddChild (csSymbolTable *);
00089 
00091   void AddChildren (csArray<csSymbolTable*> &);
00092 
00094   csArray<csSymbolTable *> GetChildren ();
00095 
00097   void SetSymbol (csStringID name, csShaderVariable *value);
00098 
00100   void SetSymbols (const csArray<csStringID>&names,csArray<csShaderVariable*>&);
00101 
00103   bool DeleteSymbol (csStringID name);
00104 
00106   bool DeleteSymbols (const csArray<csStringID> &names);
00107 
00109   csShaderVariable* GetSymbol (csStringID name);
00110 
00112   csArray<csShaderVariable *> GetSymbols (const csArray<csStringID> &names);
00113 
00115   csArray<csShaderVariable *> GetSymbols ();
00116 
00118   bool SymbolExists (csStringID name) const;
00119 
00121   bool SymbolsExist (const csArray<csStringID> &names) const;
00122 };
00123 
00124 #endif

Generated for Crystal Space by doxygen 1.2.14