Changeset 2162
- Timestamp:
- Nov 9, 2008, 11:08:24 AM (16 years ago)
- Location:
- code/branches/objecthierarchy/src
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/objecthierarchy/src/orxonox/objects/worldentities/Camera.cc
r2161 r2162 53 53 54 54 if (!this->getScene() || !this->getScene()->getSceneManager()) 55 throw AbortLoadingException("Can't create Camera, no scene or no scene manager given.");55 ThrowException(AbortLoading, "Can't create Camera, no scene or no scene manager given."); 56 56 57 57 this->camera_ = this->getScene()->getSceneManager()->createCamera(getUniqueNumberString()); -
code/branches/objecthierarchy/src/orxonox/objects/worldentities/ParticleEmitter.cc
r2161 r2162 51 51 52 52 if (!this->getScene() || !this->getScene()->getSceneManager()) 53 throw AbortLoadingException("Can't create Camera, no scene or no scene manager given.");53 ThrowException(AbortLoading, "Can't create Camera, no scene or no scene manager given."); 54 54 55 55 this->particles_ = 0; -
code/branches/objecthierarchy/src/orxonox/objects/worldentities/WorldEntity.cc
r2161 r2162 54 54 55 55 if (!this->getScene() || !this->getScene()->getRootSceneNode()) 56 throw AbortLoadingException("Can't create WorldEntity, no scene or no root-scenenode given.");56 ThrowException(AbortLoading, "Can't create WorldEntity, no scene or no root-scenenode given."); 57 57 58 58 this->node_ = this->getScene()->getRootSceneNode()->createChildSceneNode(); -
code/branches/objecthierarchy/src/orxonox/overlays/OrxonoxOverlay.cc
r2161 r2162 62 62 63 63 if (!Core::showsGraphics()) 64 throw NoGraphicsException("Can't create OrxonoxOverlay, graphics engine not initialized");64 ThrowException(NoGraphics, "Can't create OrxonoxOverlay, graphics engine not initialized"); 65 65 66 66 // add this overlay to the static map of OrxonoxOverlays -
code/branches/objecthierarchy/src/util/Exception.h
r2161 r2162 43 43 #include "Debug.h" 44 44 45 // Define some ugly macros to make things more clear46 #define CREATE_ORXONOX_EXCEPTION(name) typedef SpecificException<Exception::name> name##Exception;47 #define RETURN_EXCEPTION_CODE(name) \48 case Exception::name: \49 return #name;50 51 52 45 namespace orxonox 53 46 { … … 55 48 { 56 49 public: 57 enum ExceptionType58 {59 General,60 FileNotFound,61 Argument,62 PluginsNotFound,63 InitialisationFailed,64 NotImplemented,65 GameState,66 NoGraphics,67 AbortLoading68 };69 50 70 51 Exception(const std::string& description, int lineNumber, … … 76 57 77 58 virtual const std::string& getFullDescription() const; 78 virtual ExceptionType getType() const = 0;79 59 virtual std::string getTypeName() const = 0; 80 60 virtual const std::string& getDescription() const { return this->description_; } … … 95 75 96 76 97 template <Exception::ExceptionType Type> 98 class SpecificException : public Exception 99 { 100 public: 101 SpecificException(const std::string& description, int lineNumber, 102 const char* filename, const char* functionName) 103 : Exception(description, lineNumber, filename, functionName) 104 { 105 // let the catcher decide whether to display the message below level 4 106 COUT(4) << this->getFullDescription() << std::endl; 107 } 108 109 SpecificException(const std::string& description) 110 : Exception(description) 111 { 112 // let the catcher decide whether to display the message below level 4 113 COUT(4) << this->getFullDescription() << std::endl; 114 } 115 116 ~SpecificException() throw() { } 117 118 ExceptionType getType() const { return Type; } 119 std::string getTypeName() const 120 { 121 // note: break is not necessary due to the return in the macros. 122 switch (Type) 123 { 124 RETURN_EXCEPTION_CODE(General) 125 RETURN_EXCEPTION_CODE(FileNotFound); 126 RETURN_EXCEPTION_CODE(Argument); 127 RETURN_EXCEPTION_CODE(PluginsNotFound); 128 RETURN_EXCEPTION_CODE(InitialisationFailed); 129 RETURN_EXCEPTION_CODE(NotImplemented); 130 RETURN_EXCEPTION_CODE(GameState); 131 RETURN_EXCEPTION_CODE(NoGraphics); 132 RETURN_EXCEPTION_CODE(AbortLoading); 133 default: 134 return ""; 135 } 136 } 77 #define CREATE_ORXONOX_EXCEPTION(ExceptionName) \ 78 class ExceptionName##Exception : public Exception \ 79 { \ 80 public: \ 81 ExceptionName##Exception(const std::string& description, int lineNumber, \ 82 const char* filename, const char* functionName) \ 83 : Exception(description, lineNumber, filename, functionName) \ 84 { \ 85 /* Let the catcher decide whether to display the message below level 4 \ 86 Note: Don't place this code in Exception c'tor because getTypeName() \ 87 is still pure virtual at that time. */ \ 88 COUT(4) << this->getFullDescription() << std::endl; \ 89 } \ 90 \ 91 ExceptionName##Exception(const std::string& description) \ 92 : Exception(description) \ 93 { COUT(4) << this->getFullDescription() << std::endl; } \ 94 \ 95 ~ExceptionName##Exception() throw() { } \ 96 \ 97 std::string getTypeName() const { return #ExceptionName; } \ 137 98 }; 138 99 139 // define the template spcialisations 100 // Creates all possible exception types. 101 // If you want to add a new type, simply copy and adjust a new line here. 140 102 CREATE_ORXONOX_EXCEPTION(General); 141 103 CREATE_ORXONOX_EXCEPTION(FileNotFound); … … 149 111 } 150 112 151 #define ThrowException( type, description) \152 throw SpecificException<Exception::type>(description, __LINE__, __FILE__, __FUNCTIONNAME__)113 #define ThrowException(Type, Description) \ 114 throw Type##Exception(Description, __LINE__, __FILE__, __FUNCTIONNAME__) 153 115 154 116 // define an assert macro that can display a message 155 117 #ifndef NDEBUG 156 #define OrxAssert( assertion, errorMessage) \157 assertion ? ((void)0) : (void)(orxonox::OutputHandler::getOutStream().setOutputLevel(ORX_ERROR) << errorMessage << std::endl); \158 assert( assertion)118 #define OrxAssert(Assertion, ErrorMessage) \ 119 Assertion ? ((void)0) : (void)(orxonox::OutputHandler::getOutStream().setOutputLevel(ORX_ERROR) << ErrorMessage << std::endl); \ 120 assert(Assertion) 159 121 #else 160 122 #define OrxAssert(condition, errorMessage) ((void)0)
Note: See TracChangeset
for help on using the changeset viewer.