Changeset 26 for cpp/f8-to-f1/conv_f8tof1.h
- Timestamp:
- 06/29/09 22:12:09 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
cpp/f8-to-f1/conv_f8tof1.h
r25 r26 43 43 }; 44 44 45 class ActionP; 46 45 class ActionP; //only declaration 46 47 /// superclass of all actions, e.g. Production, PrimitiveProduction etc. 47 48 class Action { 48 49 public: 50 /// action's name 49 51 SString name; 52 /// if true action should ignore params passed to it 50 53 bool ignoreParams; 54 /// gets string representaion of this action in f1 format 51 55 virtual const SString getF1Genotype(vector<double> params) = 0; 56 /// gets list of actions with double parameters to each of them 57 /// @param params parameters passed to this action 52 58 virtual const list<ActionP> getActionList(const vector<double> params) = 0; 59 /// gets string representaion of this action in f8 format 53 60 virtual const SString getF8Representation() = 0; 54 61 virtual ~Action() {} 55 62 }; 56 63 64 /// this class consists of pointer to some action and a list of parameters to that action; 65 /// parameters are kept as strings 57 66 class ActionStrP { 58 67 public: … … 61 70 }; 62 71 72 /// this class consists of pointer to some action and a list of parameters to that action; 73 /// parameters are kept as doubles 63 74 class ActionP { 64 75 public: … … 67 78 }; 68 79 80 /// part of production which is used in translation only if all the conditions are met 69 81 class SubProduction { 70 82 public: 83 /// list of conditions necessary to be met 71 84 vector<Condition> conditions; 85 /// actions with params (as strings) 72 86 vector<ActionStrP> actions; 73 87 }; 74 88 89 /// primitive production; it's directly translated to its f1 equivalent 90 /// e.g. X, r, R etc. 75 91 class PrimitiveProduction : public Action { 76 92 public: … … 84 100 }; 85 101 102 /// param production; all param productions during translation are replaced with the current value of parameter 103 /// pointed by this production 86 104 class ParamProduction : public Action { 87 105 public: … … 94 112 }; 95 113 114 /// neuron production; it is directly translated to f1 without any change 96 115 class NeuronProduction : public Action { 97 116 public: … … 104 123 }; 105 124 106 /** 107 * Pozycje liczone od 1 a nie od 0! 108 */ 125 /// class which keeps all parameters of a production and enables to access them in convenient way 126 /// IMPORTANT! All indices (positions) begins with 1 (not 0)! 109 127 class ParameterCollection { 110 128 public: 129 /// returns parameter's value 130 /// @param position parameter's position (first parameter has an index 1!) 111 131 const double getValue(int position); 132 /// returns parameter's value 133 /// @param name parameter's name 112 134 const double getValue(SString name); 135 /// returns parameter's name 136 /// @param position parameter's position (first parameter has an index 1!) 113 137 const SString getParameterName(int position); 114 const int getParameterPosition(SString name); //zwróci index liczony od 1! 138 /// returns parameter's position (first parameter has an index 1!) 139 /// @param name parameter's name 140 const int getParameterPosition(SString name); 141 /// sets parameter's value 142 /// @param position parameter's position 143 /// @param value parameter's new value 115 144 void setValue(int position, double value); 145 /// sets parameter's value 146 /// @param name parameter's name 147 /// @param value parameter's new value 116 148 void setValue(SString name, double value); 149 /// adds parameter 150 /// @param name parameter's name 151 /// @param position desired parameter's position; defualts to -1 which means it will have first available position 152 /// @param value parameter's value; defaults to 0.0 117 153 void addParameter(SString name, int position = -1, double value = 0.0); 154 /// returns the number of parameters kept in this class 118 155 const int size(); 156 /// removes a parameter 157 /// @param position position of parameter to be deleted 119 158 void removeParameter(int position); 159 /// removes a parameter 160 /// @param name name of parameter to be deleted 120 161 void removeParameter(SString name); 162 /// returns true if parameter with given name exists 163 /// @param name parameter's name 121 164 bool paramExist(SString name); 122 165 protected: … … 125 168 }; 126 169 170 /// represents a general rule in L-systems 171 /// only "calls" to Production in genotype are replaced in translation procedure 127 172 class Production : public Action { 128 173 public: 174 /// parameters of this production 129 175 ParameterCollection parameters; 176 /// list of subproductions 130 177 vector<SubProduction> subproductions; 131 178 … … 137 184 }; 138 185 186 /// Main class that represents a genotype in f8 format 139 187 class Lsystem { 140 188 public: 189 /// number of iterations in f8->f1 translation procedure 141 190 int iterations; 191 /// map of parameters of start production; key - parameter's name, value - parameter's value 142 192 map<string, double> startParams; 193 /// map of productions of L-system; key - productions's name, value - pointer to production 143 194 map<string, Production*> productions; 195 /// collection of neuron productions held in L-system 144 196 vector<NeuronProduction*> neuronProductions; 197 /// first production's name 145 198 string firstProductionName; 146 199 147 200 Lsystem(); 148 201 ~Lsystem(); 202 /// returns a primitive production of a given name 203 /// @param name primitive production's name 149 204 PrimitiveProduction* getPrimitiveProduction(SString name); 205 /// returns a param production of a given name 206 /// @param name param production's name 150 207 ParamProduction* getParamProduction(SString name); 208 /// gets string representation of this L-system (f8 genotype) 151 209 SString toString(); 210 /// returns all actions 211 /// @param normal if true all normal actions will be included 212 /// @param primitives if true all primitive actions will be included 213 /// @param params if true all param actions will be included 214 /// @param neurons if true all neuron actions will be included 152 215 vector<Action*> getAllActions(bool normal, bool primitives, bool params, bool neurons); 153 216 protected: … … 158 221 }; 159 222 223 /// Converter between f8 and f1 format 160 224 class GenoConv_F8ToF1 : public GenoConverter { 161 225 public: 226 /// Default constructor 162 227 GenoConv_F8ToF1() { 163 228 name = "f8 to f1 converter"; … … 169 234 } 170 235 236 /// Constructor with parameter 237 /// @param f1LengthLimit If resulting f1 genotype is longer than f1LengthLimit, converter aborts its job 171 238 GenoConv_F8ToF1(int f1LengthLimit) { 172 239 name = "f8 to f1 converter"; … … 181 248 182 249 SString convert(SString &in, MultiMap *map); 250 251 /// check syntax of given f8 genotype 252 /// @param geno f8 genotype to be checked 183 253 bool checkSyntax(const char *geno); 254 255 /// returns names of productions in a given genotype 256 /// @param in f8 genotype 184 257 vector<SString> readProductionNames(const SString &in); 185 258 //Lsystem* createLsystem(const SString &in); 259 260 /// creates Lsystem object based on input genotype 261 /// @param f8 genotype 186 262 Lsystem* createLsystem(SString in); 187 263 protected:
Note: See TracChangeset
for help on using the changeset viewer.