Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 3166 for code/branches/pch


Ignore:
Timestamp:
Jun 14, 2009, 12:43:52 PM (15 years ago)
Author:
rgrieder
Message:

Merged some code work from the Gruppenarbeit.

Location:
code/branches/pch/src
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • code/branches/pch/src/core/Core.cc

    r3103 r3166  
    2929
    3030/**
    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)
    3334*/
    3435
     
    8182    static boost::filesystem::path logPath_g;                   //!< Path to the log file folder
    8283
     84    //! Static pointer to the singleton
    8385    Core* Core::singletonRef_s  = 0;
    8486
     
    472474        If found it means that this is not an installed run, hence we
    473475        don't write the logs and config files to ~/.orxonox
     476    @throws
     477        GeneralException
    474478    */
    475479    void Core::checkDevBuild()
     
    532536        Checks for the log and the config directory and creates them
    533537        if necessary. Otherwise me might have problems opening those files.
     538    @throws
     539        orxonox::GeneralException if the directory to be created is a file.
    534540    */
    535541    void Core::createDirectories()
    536542    {
    537543        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"));
    542546
    543547        for (std::vector<std::pair<boost::filesystem::path, std::string> >::iterator it = directories.begin();
  • code/branches/pch/src/core/Core.h

    r3156 r3166  
    2929
    3030/**
    31     @file
    32     @brief Declaration of the Core class.
    33 
     31@file
     32@brief
     33    Declaration of the Core class.
     34@details
    3435    The Core class is a singleton, only used to configure some variables
    3536    in the core through the config-file.
     
    4748namespace orxonox
    4849{
    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    */
    5057    class _CoreExport Core : public OrxonoxClass
    5158    {
    5259        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            */
    5367            Core();
    5468            ~Core();
     
    6882            static void tsetMediaPath(const std::string& path)
    6983            { assert(singletonRef_s); singletonRef_s->_tsetMediaPath(path); }
     84            //! Returns the path to the config files as boost::filesystem::path
    7085            static const boost::filesystem::path& getMediaPath();
     86            //! Returns the path to the config files as boost::filesystem::path
    7187            static const boost::filesystem::path& getConfigPath();
     88            //! Returns the path to the log files as boost::filesystem::path
    7289            static const boost::filesystem::path& getLogPath();
     90            //! Returns the path to the data files as std::string
    7391            static std::string getMediaPathString();
     92            //! Returns the path to the config files as std::string
    7493            static std::string getConfigPathString();
     94            //! Returns the path to the log files as std::string
    7595            static std::string getLogPathString();
    7696
    7797        private:
    78             Core(const Core&);
     98            Core(const Core&); //!< Don't use (undefined symbol)
    7999
    80100            void checkDevBuild();
  • code/branches/pch/src/util/Exception.cc

    r3068 r3166  
    3737namespace orxonox
    3838{
    39     Exception::Exception(const std::string& description, int lineNumber,
     39    Exception::Exception(const std::string& description, unsigned int lineNumber,
    4040                         const char* filename, const char* functionName)
    4141        : description_(description)
     
    5252    { }
    5353
     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    */
    5460    const std::string& Exception::getFullDescription() const
    5561    {
  • code/branches/pch/src/util/Exception.h

    r3162 r3166  
    3030@file
    3131@brief
    32     Declaration of the Exception class.
     32    Declaration of facilities to handle exceptions.
    3333*/
    3434
     
    4545namespace orxonox
    4646{
     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    */
    4754    class _UtilExport Exception : public std::exception
    4855    {
    4956    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,
    5264                  const char* filename, const char* functionName);
     65        //! Simplified constructor with just a description. If you need more, use the other one.
    5366        Exception(const std::string& description);
    5467
    55         /// Needed for  compatibility with std::exception (from Ogre::Exception)
     68        //! Needed for compatibility with std::exception
    5669        virtual ~Exception() throw() { }
    5770
     71        //! Returns a full description with type, line, file and function
    5872        virtual const std::string& getFullDescription() const;
     73        //! Returns the string name of the exception type
    5974        virtual std::string        getTypeName()        const = 0;
     75        //! Returns the short developer written exception
    6076        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.
    6280        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_; }
    6383
    64         /// Override std::exception::what (from Ogre::Exception)
     84        //! Returns a full description of the error.
    6585        const char* what() const throw() { return getFullDescription().c_str(); }
    6686
    6787    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
    7292        // mutable because "what()" is a const method
    73         mutable std::string fullDescription_;
     93        mutable std::string fullDescription_; //!< Full description with line, file and function
    7494    };
    7595
    76 
     96//! Creates a new type of exception that inherits from tracker::Exception
    7797#define CREATE_ORXONOX_EXCEPTION(ExceptionName)                                     \
    7898    class ExceptionName##Exception : public Exception                               \
    7999    {                                                                               \
    80100    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)            \
    84105        { }                                                                         \
    85106                                                                                    \
    86107        ExceptionName##Exception(const std::string& description)                    \
    87                   : Exception(description)                                          \
     108            : Exception(description)                                                \
    88109        { }                                                                         \
    89110                                                                                    \
     
    91112                                                                                    \
    92113        std::string getTypeName() const { return #ExceptionName; }                  \
    93     };
     114    }
    94115
    95116    // Creates all possible exception types.
    96117    // If you want to add a new type, simply copy and adjust a new line here.
     118#ifndef DOXYGEN_SHOULD_SKIP_THIS
    97119    CREATE_ORXONOX_EXCEPTION(General);
    98120    CREATE_ORXONOX_EXCEPTION(FileNotFound);
     
    106128    CREATE_ORXONOX_EXCEPTION(NoGraphics);
    107129    CREATE_ORXONOX_EXCEPTION(AbortLoading);
    108 }
     130#endif
    109131
    110132    /**
    111133    @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.
    113137    */
    114138    template <class T>
    115     inline const T& InternalHandleException(const T& exception)
     139    inline const T& exceptionThrowerHelper(const T& exception)
    116140    {
    117141        // let the catcher decide whether to display the message below level 4
     
    120144    }
    121145
    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 */
    124158
    125159#endif /* _Exception_H__ */
  • code/branches/pch/src/util/Sleep.cc

    r3146 r3166  
    2828
    2929/**
    30     @file
    31     @brief Implementation of three sleep functions.
     30@file
     31@brief
     32    Implementation of three sleep functions. Avoids including windows.h
    3233*/
    3334
  • code/branches/pch/src/util/Sleep.h

    r2773 r3166  
    2828
    2929/**
    30  @file
    31  @brief
    32     Functions for using sleep() and usleep() on windows.
     30@file
     31@brief
     32    Functions declarations to make the current thread sleep.
    3333 */
    3434
     
    4040namespace orxonox
    4141{
     42    //! Makes the thread sleep for a few @a microseconds
    4243    _UtilExport void usleep(unsigned long microseconds);
     44    //! Makes the thread sleep for a few @a milliseconds
    4345    _UtilExport void msleep(unsigned long milliseconds);
     46    //! Makes the thread sleep for a few @a seconds
    4447    _UtilExport void sleep (unsigned long seconds);
    4548}
Note: See TracChangeset for help on using the changeset viewer.