Changeset 3166 for code/branches/pch
- Timestamp:
- Jun 14, 2009, 12:43:52 PM (15 years ago)
- Location:
- code/branches/pch/src
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/pch/src/core/Core.cc
r3103 r3166 29 29 30 30 /** 31 @file 32 @brief Implementation of the Core class. 31 @file 32 @brief 33 Implementation of the Core singleton with its global variables (avoids boost include) 33 34 */ 34 35 … … 81 82 static boost::filesystem::path logPath_g; //!< Path to the log file folder 82 83 84 //! Static pointer to the singleton 83 85 Core* Core::singletonRef_s = 0; 84 86 … … 472 474 If found it means that this is not an installed run, hence we 473 475 don't write the logs and config files to ~/.orxonox 476 @throws 477 GeneralException 474 478 */ 475 479 void Core::checkDevBuild() … … 532 536 Checks for the log and the config directory and creates them 533 537 if necessary. Otherwise me might have problems opening those files. 538 @throws 539 orxonox::GeneralException if the directory to be created is a file. 534 540 */ 535 541 void Core::createDirectories() 536 542 { 537 543 std::vector<std::pair<boost::filesystem::path, std::string> > directories; 538 directories.push_back(std::pair<boost::filesystem::path, std::string> 539 (boost::filesystem::path(configPath_g), "config")); 540 directories.push_back(std::pair<boost::filesystem::path, std::string> 541 (boost::filesystem::path(logPath_g), "log")); 544 directories.push_back(std::make_pair(boost::filesystem::path(configPath_g), "config")); 545 directories.push_back(std::make_pair(boost::filesystem::path(logPath_g), "log")); 542 546 543 547 for (std::vector<std::pair<boost::filesystem::path, std::string> >::iterator it = directories.begin(); -
code/branches/pch/src/core/Core.h
r3156 r3166 29 29 30 30 /** 31 @file 32 @brief Declaration of the Core class. 33 31 @file 32 @brief 33 Declaration of the Core class. 34 @details 34 35 The Core class is a singleton, only used to configure some variables 35 36 in the core through the config-file. … … 47 48 namespace orxonox 48 49 { 49 //! The Core class is a singleton, only used to configure some config-values. 50 /** 51 @brief 52 The Core class is a singleton used to configure the program basics. 53 @details 54 The class provides information about the media, config and log path. 55 It determines those by the use of platform specific functions. 56 */ 50 57 class _CoreExport Core : public OrxonoxClass 51 58 { 52 59 public: 60 /** 61 @brief 62 Determines the executable path, checks for build directory runs, creates 63 the output directories and sets up the other core library singletons. 64 @throws 65 GeneralException 66 */ 53 67 Core(); 54 68 ~Core(); … … 68 82 static void tsetMediaPath(const std::string& path) 69 83 { assert(singletonRef_s); singletonRef_s->_tsetMediaPath(path); } 84 //! Returns the path to the config files as boost::filesystem::path 70 85 static const boost::filesystem::path& getMediaPath(); 86 //! Returns the path to the config files as boost::filesystem::path 71 87 static const boost::filesystem::path& getConfigPath(); 88 //! Returns the path to the log files as boost::filesystem::path 72 89 static const boost::filesystem::path& getLogPath(); 90 //! Returns the path to the data files as std::string 73 91 static std::string getMediaPathString(); 92 //! Returns the path to the config files as std::string 74 93 static std::string getConfigPathString(); 94 //! Returns the path to the log files as std::string 75 95 static std::string getLogPathString(); 76 96 77 97 private: 78 Core(const Core&); 98 Core(const Core&); //!< Don't use (undefined symbol) 79 99 80 100 void checkDevBuild(); -
code/branches/pch/src/util/Exception.cc
r3068 r3166 37 37 namespace orxonox 38 38 { 39 Exception::Exception(const std::string& description, int lineNumber,39 Exception::Exception(const std::string& description, unsigned int lineNumber, 40 40 const char* filename, const char* functionName) 41 41 : description_(description) … … 52 52 { } 53 53 54 /** 55 @remarks 56 The composed full description gets stored to fullDescription_. But for compliance 57 with std::exception, this method has to be const. Hence fullDescription_ is declared 58 as mutable. 59 */ 54 60 const std::string& Exception::getFullDescription() const 55 61 { -
code/branches/pch/src/util/Exception.h
r3162 r3166 30 30 @file 31 31 @brief 32 Declaration of the Exception class.32 Declaration of facilities to handle exceptions. 33 33 */ 34 34 … … 45 45 namespace orxonox 46 46 { 47 /** 48 @brief 49 Base class for all exceptions (derived from std::exception). 50 @details 51 This class provides support for information about the file, the line 52 and the function the error occured. 53 */ 47 54 class _UtilExport Exception : public std::exception 48 55 { 49 56 public: 50 51 Exception(const std::string& description, int lineNumber, 57 /** 58 @brief 59 Creates the exception but doesn't yet compose the full descrption (because of the virtual functions) 60 @param description 61 Exception description as string. This message is supposed to help developers! 62 */ 63 Exception(const std::string& description, unsigned int lineNumber, 52 64 const char* filename, const char* functionName); 65 //! Simplified constructor with just a description. If you need more, use the other one. 53 66 Exception(const std::string& description); 54 67 55 // / Needed for compatibility with std::exception (from Ogre::Exception)68 //! Needed for compatibility with std::exception 56 69 virtual ~Exception() throw() { } 57 70 71 //! Returns a full description with type, line, file and function 58 72 virtual const std::string& getFullDescription() const; 73 //! Returns the string name of the exception type 59 74 virtual std::string getTypeName() const = 0; 75 //! Returns the short developer written exception 60 76 virtual const std::string& getDescription() const { return this->description_; } 61 virtual const int getLineNumber() const { return this->lineNumber_; } 77 //! Returns the line number on which the exception occurred. 78 virtual const unsigned int getLineNumber() const { return this->lineNumber_; } 79 //! Returns the function in which the exception occurred. 62 80 virtual const std::string& getFunctionName() const { return this->functionName_; } 81 //! Returns the filename in which the exception occurred. 82 virtual const std::string& getFilename() const { return this->filename_; } 63 83 64 // / Override std::exception::what (from Ogre::Exception)84 //! Returns a full description of the error. 65 85 const char* what() const throw() { return getFullDescription().c_str(); } 66 86 67 87 protected: 68 std::string description_; 69 int lineNumber_;70 std::string functionName_; 71 std::string filename_; 88 std::string description_; //!< User typed text about why the exception occurred 89 unsigned int lineNumber_; //!< Line on which the exception occurred 90 std::string functionName_; //!< Function (including namespace and class) where the exception occurred 91 std::string filename_; //!< File where the exception occurred 72 92 // mutable because "what()" is a const method 73 mutable std::string fullDescription_; 93 mutable std::string fullDescription_; //!< Full description with line, file and function 74 94 }; 75 95 76 96 //! Creates a new type of exception that inherits from tracker::Exception 77 97 #define CREATE_ORXONOX_EXCEPTION(ExceptionName) \ 78 98 class ExceptionName##Exception : public Exception \ 79 99 { \ 80 100 public: \ 81 ExceptionName##Exception(const std::string& description, int lineNumber, \ 82 const char* filename, const char* functionName) \ 83 : Exception(description, lineNumber, filename, functionName) \ 101 ExceptionName##Exception(const std::string& description, \ 102 unsigned int lineNumber, const char* filename, \ 103 const char* functionName) \ 104 : Exception(description, lineNumber, filename, functionName) \ 84 105 { } \ 85 106 \ 86 107 ExceptionName##Exception(const std::string& description) \ 87 : Exception(description)\108 : Exception(description) \ 88 109 { } \ 89 110 \ … … 91 112 \ 92 113 std::string getTypeName() const { return #ExceptionName; } \ 93 } ;114 } 94 115 95 116 // Creates all possible exception types. 96 117 // If you want to add a new type, simply copy and adjust a new line here. 118 #ifndef DOXYGEN_SHOULD_SKIP_THIS 97 119 CREATE_ORXONOX_EXCEPTION(General); 98 120 CREATE_ORXONOX_EXCEPTION(FileNotFound); … … 106 128 CREATE_ORXONOX_EXCEPTION(NoGraphics); 107 129 CREATE_ORXONOX_EXCEPTION(AbortLoading); 108 } 130 #endif 109 131 110 132 /** 111 133 @brief 112 Helper function that creates an exception, displays the message, but doesn't throw it. 134 Helper function that forwards an exception and displays the message. 135 @details 136 This is necessary because only when using 'throw' the objects storage is managed. 113 137 */ 114 138 template <class T> 115 inline const T& InternalHandleException(const T& exception)139 inline const T& exceptionThrowerHelper(const T& exception) 116 140 { 117 141 // let the catcher decide whether to display the message below level 4 … … 120 144 } 121 145 122 #define ThrowException(type, description) \ 123 throw InternalHandleException(type##Exception(static_cast<std::ostringstream&>(std::ostringstream().flush() << description).str(), __LINE__, __FILE__, __FUNCTIONNAME__)) 146 /** 147 @brief 148 Throws an exception and logs a message beforehand. 149 @param type 150 Type of the exception as literal (General, Initialisation, etc.) 151 @param description 152 Exception description as string 153 */ 154 #define ThrowException(type, description, ...) \ 155 throw orxonox::exceptionThrowerHelper(type##Exception(static_cast<std::ostringstream&>(std::ostringstream().flush() << description).str(), __LINE__, __FILE__, __FUNCTIONNAME__)) 156 157 } /* namespace orxonox */ 124 158 125 159 #endif /* _Exception_H__ */ -
code/branches/pch/src/util/Sleep.cc
r3146 r3166 28 28 29 29 /** 30 @file 31 @brief Implementation of three sleep functions. 30 @file 31 @brief 32 Implementation of three sleep functions. Avoids including windows.h 32 33 */ 33 34 -
code/branches/pch/src/util/Sleep.h
r2773 r3166 28 28 29 29 /** 30 31 32 Functions for using sleep() and usleep() on windows.30 @file 31 @brief 32 Functions declarations to make the current thread sleep. 33 33 */ 34 34 … … 40 40 namespace orxonox 41 41 { 42 //! Makes the thread sleep for a few @a microseconds 42 43 _UtilExport void usleep(unsigned long microseconds); 44 //! Makes the thread sleep for a few @a milliseconds 43 45 _UtilExport void msleep(unsigned long milliseconds); 46 //! Makes the thread sleep for a few @a seconds 44 47 _UtilExport void sleep (unsigned long seconds); 45 48 }
Note: See TracChangeset
for help on using the changeset viewer.