1 #ifndef _RSGVARIABLE_HPP 2 #define _RSGVARIABLE_HPP 3 /*------------------------------------------------------------------------- 4 * drawElements Quality Program Random Shader Generator 5 * ---------------------------------------------------- 6 * 7 * Copyright 2014 The Android Open Source Project 8 * 9 * Licensed under the Apache License, Version 2.0 (the "License"); 10 * you may not use this file except in compliance with the License. 11 * You may obtain a copy of the License at 12 * 13 * http://www.apache.org/licenses/LICENSE-2.0 14 * 15 * Unless required by applicable law or agreed to in writing, software 16 * distributed under the License is distributed on an "AS IS" BASIS, 17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 * See the License for the specific language governing permissions and 19 * limitations under the License. 20 * 21 *//*! 22 * \file 23 * \brief Variable class. 24 *//*--------------------------------------------------------------------*/ 25 26 #include "rsgDefs.hpp" 27 #include "rsgVariableType.hpp" 28 #include "rsgToken.hpp" 29 30 #include <string> 31 32 namespace rsg 33 { 34 35 class GeneratorState; 36 37 class Variable 38 { 39 public: 40 enum Storage 41 { 42 STORAGE_LOCAL, 43 STORAGE_SHADER_IN, 44 STORAGE_SHADER_OUT, 45 STORAGE_UNIFORM, 46 STORAGE_CONST, 47 STORAGE_PARAMETER_IN, 48 STORAGE_PARAMETER_OUT, 49 STORAGE_PARAMETER_INOUT, 50 51 STORAGE_LAST 52 }; 53 54 Variable(const VariableType &type, Storage storage, const char *name); 55 ~Variable(void); 56 getType(void) const57 const VariableType &getType(void) const 58 { 59 return m_type; 60 } getStorage(void) const61 Storage getStorage(void) const 62 { 63 return m_storage; 64 } getName(void) const65 const char *getName(void) const 66 { 67 return m_name.c_str(); 68 } getLayoutLocation(void) const69 int getLayoutLocation(void) const 70 { 71 return m_layoutLocation; 72 } hasLayoutLocation(void) const73 bool hasLayoutLocation(void) const 74 { 75 return m_layoutLocation >= 0; 76 } 77 setStorage(Storage storage)78 void setStorage(Storage storage) 79 { 80 m_storage = storage; 81 } setLayoutLocation(int location)82 void setLayoutLocation(int location) 83 { 84 m_layoutLocation = location; 85 } 86 87 bool isWritable(void) const; 88 89 void tokenizeDeclaration(GeneratorState &state, TokenStream &str) const; 90 91 private: 92 VariableType m_type; 93 Storage m_storage; 94 std::string m_name; 95 int m_layoutLocation; 96 }; 97 98 } // namespace rsg 99 100 #endif // _RSGVARIABLE_HPP 101