Changeset 9777 in orxonox.OLD for branches/new_class_id/src/lib/util
- Timestamp:
- Sep 20, 2006, 9:49:13 AM (18 years ago)
- Location:
- branches/new_class_id/src/lib/util
- Files:
-
- 1 deleted
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/new_class_id/src/lib/util/Makefile.am
r9768 r9777 19 19 loading/game_loader.cc \ 20 20 loading/load_param.cc \ 21 loading/load_param_xml.cc \22 21 loading/load_param_description.cc \ 23 22 loading/load_param_class_description.cc \ -
branches/new_class_id/src/lib/util/loading/load_param.cc
r9776 r9777 106 106 return NULL; 107 107 } 108 109 110 -
branches/new_class_id/src/lib/util/loading/load_param_class_description.cc
r9776 r9777 114 114 } 115 115 116 117 118 119 116 /** 120 117 * @brief prints out all loadable Classes, and their parameters 121 118 * @param fileName prints the output to a File 122 * @ todo implement it119 * @param withComments if Comments should be included. 123 120 */ 124 void LoadParamClassDescription::printAll(const std::string& fileName )121 void LoadParamClassDescription::printAll(const std::string& fileName, bool withComments) 125 122 { 126 PRINT(0)("===============================================================\n"); 127 PRINT(0)(" Listing all the Loadable Options (loaded since Game started).\n\n"); 123 printf("================== function called\n"); 124 125 FILE* stream; 126 if( (stream = fopen (fileName.c_str(), "w")) == NULL) 127 { 128 PRINTF(2)("File '%s' could not be opened for writing\n Printing to stdout\n", fileName.c_str()); 129 LoadParamClassDescription::printAllTo(stdout, withComments); 130 return; 131 } 132 else 133 LoadParamClassDescription::printAllTo(stream, withComments); 134 135 fclose (stream); 136 } 137 138 /** 139 * @brief prints out all loadable Classes, and their parameters to a stream 140 * @param stream the stream to print to. 141 * @param withComments if Comments should be included. 142 */ 143 void LoadParamClassDescription::printAllTo(FILE* stream, bool withComments) 144 { 145 fprintf(stream, "===============================================================\n"); 146 fprintf(stream, " Listing all the Loadable Options (loaded since Game started).\n\n"); 128 147 for (ClassDescriptionMap::const_iterator classIt = LoadParamClassDescription::_classList.begin(); 129 148 classIt != LoadParamClassDescription::_classList.end(); 130 149 classIt ++) 131 150 { 132 PRINT(0)("<%s>\n", (*classIt).second._className.c_str());151 fprintf(stream, "<%s>\n", (*classIt).second._className.c_str()); 133 152 for (ParamDescriptionMap::const_iterator param = (*classIt).second._parameters.begin(); 134 153 param != (*classIt).second._parameters.end(); 135 154 ++param) 136 155 { 137 (*param).second.print( );156 (*param).second.print(stream, withComments); 138 157 } 139 PRINT(0)("</%s>\n\n", (*classIt).second._className.c_str());158 fprintf(stream, "</%s>\n\n", (*classIt).second._className.c_str()); 140 159 } 141 PRINT(0)("===============================================================\n");160 fprintf(stream, "===============================================================\n"); 142 161 } -
branches/new_class_id/src/lib/util/loading/load_param_class_description.h
r9776 r9777 25 25 #include "class_id.h" 26 26 #include <map> 27 #include <set>28 27 // Forward Declaration // 29 28 class MultiType; … … 59 58 static void deleteAllDescriptions(); 60 59 61 static void printAll(const std::string& fileName = ""); 60 static void printAll(const std::string& fileName = "", bool withComments = true); 61 static void printAllTo(FILE* stream = stdout, bool withComments = true); 62 62 63 63 private: -
branches/new_class_id/src/lib/util/loading/load_param_description.cc
r9776 r9777 56 56 57 57 /** 58 * prints out this parameter, its input method and the description (if availiable) 58 * @brief prints out this parameter, its input method and the description (if availiable) 59 * @param stream the stream to print to. 60 * @param withComments if the comments should be appended. 59 61 */ 60 void LoadParamDescription::print( ) const62 void LoadParamDescription::print(FILE* stream, bool withComments) const 61 63 { 62 PRINT(0)(" <%s>", this->_name.c_str());64 fprintf(stream, " <%s>", this->_name.c_str()); 63 65 for (unsigned int i = 0; i < this->_parameterCount; i++) 64 66 { 65 67 if (i > 0) 66 PRINT(0)(",");67 PRINT(0)("%s", this->_types[i].c_str());68 fprintf(stream, ","); 69 fprintf(stream, "%s", this->_types[i].c_str()); 68 70 } 69 PRINT(0)("</%s>", this->_name.c_str());71 fprintf(stream, "</%s>", this->_name.c_str()); 70 72 if (!this->_description.empty()) 71 PRINT(0)(" <!-- %s", this->_description.c_str());73 fprintf(stream, " <!-- %s", this->_description.c_str()); 72 74 // default values 73 75 if (this->_parameterCount > 0) 74 76 { 75 PRINT(0)(" (Default: ");77 fprintf(stream, " (Default: "); 76 78 for (unsigned int i = 0; i < this->_parameterCount; i++) 77 79 { 78 80 if (i > 0) 79 PRINT(0)(", ");81 fprintf(stream, ", "); 80 82 if (this->_types[i] == "string") 81 83 { // leave brackets !! 82 PRINT(0)("\"%s\"", this->_defaultValues[i].c_str());84 fprintf(stream, "\"%s\"", this->_defaultValues[i].c_str()); 83 85 } 84 86 else 85 87 { 86 PRINT(0)("%s", this->_defaultValues[i].c_str());88 fprintf(stream, "%s", this->_defaultValues[i].c_str()); 87 89 } 88 90 } 89 PRINT(0)(")");91 fprintf(stream, ")"); 90 92 } 91 93 if (!this->_description.empty() || this->_parameterCount > 0) 92 PRINT(0)(" -->");94 fprintf(stream, " -->"); 93 95 94 PRINT(0)("\n");96 fprintf(stream, "\n"); 95 97 } 96 98 -
branches/new_class_id/src/lib/util/loading/load_param_description.h
r9776 r9777 46 46 void setDescription(const std::string& descriptionText); 47 47 void setValues(unsigned int paramCount, 48 const MultiType* const defaultValues, 49 bool retVal = false); 48 const MultiType* const defaultValues, 49 bool retVal = false); 50 50 51 /** @returns the descriptionString */ 51 52 const std::string& description() { return this->_description; }; 52 53 53 void print( ) const;54 void print(FILE* stream = stdout, bool withComments = true) const; 54 55 55 56 private:
Note: See TracChangeset
for help on using the changeset viewer.