root/juggler/branches/1.0/Config/vjPropertyDesc.h
| Revision 8789, 5.9 kB (checked in by patrickh, 7 years ago) | |
|---|---|
| |
| Line | |
|---|---|
| 1 | /*************** <auto-copyright.pl BEGIN do not edit this line> ************** |
| 2 | * |
| 3 | * VR Juggler is (C) Copyright 1998, 1999, 2000, 2001, 2002 |
| 4 | * by Iowa State University |
| 5 | * |
| 6 | * Original Authors: |
| 7 | * Allen Bierbaum, Christopher Just, |
| 8 | * Patrick Hartling, Kevin Meinert, |
| 9 | * Carolina Cruz-Neira, Albert Baker |
| 10 | * |
| 11 | * This library is free software; you can redistribute it and/or |
| 12 | * modify it under the terms of the GNU Library General Public |
| 13 | * License as published by the Free Software Foundation; either |
| 14 | * version 2 of the License, or (at your option) any later version. |
| 15 | * |
| 16 | * This library is distributed in the hope that it will be useful, |
| 17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 19 | * Library General Public License for more details. |
| 20 | * |
| 21 | * You should have received a copy of the GNU Library General Public |
| 22 | * License along with this library; if not, write to the |
| 23 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
| 24 | * Boston, MA 02111-1307, USA. |
| 25 | * |
| 26 | * ----------------------------------------------------------------- |
| 27 | * File: $RCSfile$ |
| 28 | * Date modified: $Date$ |
| 29 | * Version: $Revision$ |
| 30 | * ----------------------------------------------------------------- |
| 31 | * |
| 32 | *************** <auto-copyright.pl END do not edit this line> ***************/ |
| 33 | |
| 34 | |
| 35 | |
| 36 | #ifndef _VJ_PROPERTY_DESC_H_ |
| 37 | #define _VJ_PROPERTY_DESC_H_ |
| 38 | |
| 39 | #include <vjConfig.h> |
| 40 | #include <Config/vjEnumEntry.h> |
| 41 | |
| 42 | |
| 43 | //------------------------------------------------------------ |
| 44 | //: A Description used to instantiate a vjProperty |
| 45 | // |
| 46 | // Information stored in a vjPropertyDesc includes vjProperty |
| 47 | // Name, Type, number of allowed values, and a Help string |
| 48 | // describing the purpose of the particular property. |
| 49 | // vjPropertyDescs also include information for parsing a |
| 50 | // vjProperty, and (optional) enumeration data for T_INT |
| 51 | // type Properties. |
| 52 | // Note: Frequently the docs for this class will refer to 'this |
| 53 | // vjProperty', which refers to any object of class vjProperty |
| 54 | // instantiated |
| 55 | // using this description. |
| 56 | // |
| 57 | // @author: Christopher Just |
| 58 | //------------------------------------------------------------ |
| 59 | |
| 60 | class vjPropertyDesc { |
| 61 | |
| 62 | public: |
| 63 | |
| 64 | //: Constructor |
| 65 | //!POST: name, token, help = NULL, type = T_INVALID, num = 0, |
| 66 | //+ valuelabels & enumerations are empty. |
| 67 | vjPropertyDesc (); |
| 68 | |
| 69 | |
| 70 | |
| 71 | //:Copy Constructor |
| 72 | vjPropertyDesc (const vjPropertyDesc& d); |
| 73 | |
| 74 | |
| 75 | |
| 76 | //: Convenience constructor |
| 77 | //!POST: name = token = n, help = h, num = i, type = t, |
| 78 | //+ valuelabels & enumerations are empty. |
| 79 | vjPropertyDesc (const std::string& n, int i, VarType t, const std::string& h); |
| 80 | |
| 81 | |
| 82 | //: Destroys a vjPropertyDesc, and frees all allocated memory. |
| 83 | ~vjPropertyDesc (); |
| 84 | |
| 85 | |
| 86 | |
| 87 | #ifdef VJ_DEBUG |
| 88 | void assertValid () const; |
| 89 | #else |
| 90 | inline void assertValid () const { |
| 91 | ; |
| 92 | } |
| 93 | #endif |
| 94 | |
| 95 | |
| 96 | |
| 97 | //: returns the token string for |
| 98 | inline std::string& getToken () { |
| 99 | return token; |
| 100 | } |
| 101 | |
| 102 | |
| 103 | inline std::string& getName () { |
| 104 | return name; |
| 105 | } |
| 106 | |
| 107 | |
| 108 | |
| 109 | inline VarType getType () { |
| 110 | return type; |
| 111 | } |
| 112 | |
| 113 | |
| 114 | inline int getNumAllowed () { |
| 115 | return num; |
| 116 | } |
| 117 | |
| 118 | |
| 119 | //: Returns the number of individual value labels |
| 120 | inline int getValueLabelsSize () { |
| 121 | return valuelabels.size(); |
| 122 | } |
| 123 | |
| 124 | |
| 125 | //: Returns the ith value label |
| 126 | std::string getValueLabel (unsigned int index); |
| 127 | |
| 128 | |
| 129 | |
| 130 | //: Returns the enumeration entry at index ind |
| 131 | //! ARGS: index - index of EnumEntry to retrieve (0-base) |
| 132 | //! RETURNS: NULL - if index is < 0 or out of range |
| 133 | //! RETURNS: enumentry* - otherwise |
| 134 | vjEnumEntry* getEnumEntryAtIndex (unsigned int index); |
| 135 | |
| 136 | |
| 137 | //: Returns an enumentry with val matching val... |
| 138 | vjEnumEntry* getEnumEntryWithValue (vjVarValue& val); |
| 139 | |
| 140 | |
| 141 | //: Returns the enumentry named _name |
| 142 | //! RETURNS: NULL - if no match if found |
| 143 | //! RETURNS: vjEnumEntry* - otherwise |
| 144 | vjEnumEntry* getEnumEntry (const std::string& _name); |
| 145 | |
| 146 | |
| 147 | //: Writes a vjPropertyDesc to the given ostream |
| 148 | //!NOTE: output format is: |
| 149 | //+ name typename num token { enum1 enum2=42 } "help string" |
| 150 | friend std::ostream& operator << (std::ostream& out, vjPropertyDesc& self); |
| 151 | |
| 152 | |
| 153 | |
| 154 | //: Reads a vjPropertyDesc from the named istream |
| 155 | //!NOTE: format is the same as that written out by << |
| 156 | friend std::istream& operator >> (std::istream& in, vjPropertyDesc& self); |
| 157 | |
| 158 | |
| 159 | vjPropertyDesc& operator= (const vjPropertyDesc& pd); |
| 160 | |
| 161 | //: Equality Operator |
| 162 | // BUG (IPTHACK) - doesn't check equality of enumerations and valuelabels |
| 163 | bool operator== (const vjPropertyDesc& pd); |
| 164 | |
| 165 | //: Inequality Operator |
| 166 | inline bool operator!= (const vjPropertyDesc& pd) { |
| 167 | return !(*this == pd); |
| 168 | } |
| 169 | |
| 170 | private: |
| 171 | |
| 172 | //: Descriptive name of the vjProperty this object describes. Used in GUI. |
| 173 | std::string name; |
| 174 | |
| 175 | //: Short name for this vjPropertyDesc. Used in app/library code. |
| 176 | std::string token; |
| 177 | |
| 178 | //: One line of help information for this vjPropertyDesc. |
| 179 | std::string help; |
| 180 | |
| 181 | //: Type of values allowed in this vjProperty. |
| 182 | VarType type; |
| 183 | |
| 184 | //: Number of value entries allowed for this vjProperty. (-1 for variable) |
| 185 | // Typically this is an integer > 0. For example, a tracker |
| 186 | // position offset might be described with 3 Float values (xyz). |
| 187 | // A value of -1 indicates that this vjProperty may have a variable |
| 188 | // number of values (e.g. for a list of active Walls). |
| 189 | int num; |
| 190 | |
| 191 | //: Labels for individual values of this Property (ie. "width", "height") |
| 192 | std::vector<vjEnumEntry*> valuelabels; |
| 193 | |
| 194 | //: A list of labeled values that are allowed. |
| 195 | // string/int pairs for T_INTs, |
| 196 | // valid string values for T_STRINGS, and names of acceptable chunk |
| 197 | // types for T_CHUNK. Note that in the T_CHUNK case, an empty enumv |
| 198 | // means _all_ chunk types are accepted |
| 199 | std::vector<vjEnumEntry*> enumv; |
| 200 | |
| 201 | unsigned int validation; |
| 202 | |
| 203 | }; |
| 204 | |
| 205 | |
| 206 | #endif |
Note: See TracBrowser for help on using the browser.
