astra_exception.h
Go to the documentation of this file.
00001 /*
00002  * Software License Agreement (BSD License)
00003  *
00004  *  Copyright (c) 2011, Willow Garage, Inc.
00005  *  Copyright (c) 2016, Orbbec Ltd.
00006  *     Tim Liu <liuhua@orbbec.com>
00007  *
00008  *  All rights reserved.
00009  *
00010  *  Redistribution and use in source and binary forms, with or without
00011  *  modification, are permitted provided that the following conditions
00012  *  are met:
00013  *
00014  *   * Redistributions of source code must retain the above copyright
00015  *     notice, this list of conditions and the following disclaimer.
00016  *   * Redistributions in binary form must reproduce the above
00017  *     copyright notice, this list of conditions and the following
00018  *     disclaimer in the documentation and/or other materials provided
00019  *     with the distribution.
00020  *   * Neither the name of Willow Garage, Inc. nor the names of its
00021  *     contributors may be used to endorse or promote products derived
00022  *     from this software without specific prior written permission.
00023  *
00024  *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00025  *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00026  *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
00027  *  FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
00028  *  COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
00029  *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
00030  *  BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
00031  *  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
00032  *  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
00033  *  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
00034  *  ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00035  *  POSSIBILITY OF SUCH DAMAGE.
00036  *
00037  */
00038 #ifndef __ASTRA_EXCEPTION__
00039 #define __ASTRA_EXCEPTION__
00040 
00041 #include <cstdarg>
00042 #include <cstdio>
00043 #include <exception>
00044 #include <string>
00045 
00046 #if defined _WIN32 && defined _MSC_VER
00047 # define __PRETTY_FUNCTION__ __FUNCTION__
00048 #endif
00049 #define THROW_OPENNI_EXCEPTION(format,...) throwOpenNIException( __PRETTY_FUNCTION__, __FILE__, __LINE__, format , ##__VA_ARGS__ )
00050 
00051 namespace astra_wrapper
00052 {
00058 class AstraException : public std::exception
00059 {
00060 public:
00061   AstraException(const std::string& function_name,
00062                    const std::string& file_name,
00063                    unsigned line_number,
00064                    const std::string& message);
00065 
00066   virtual ~AstraException() throw();
00067   AstraException & operator=(const AstraException& exception);
00068   virtual const char* what() const throw();
00069 
00070   const std::string& getFunctionName() const;
00071   const std::string& getFileName() const;
00072   unsigned getLineNumber() const;
00073 
00074 protected:
00075   std::string function_name_;
00076   std::string file_name_;
00077   unsigned line_number_;
00078   std::string message_;
00079   std::string message_long_;
00080 };
00081 
00082 inline void throwOpenNIException(const char* function, const char* file, unsigned line, const char* format, ...)
00083 {
00084   static char msg[1024];
00085   va_list args;
00086   va_start(args, format);
00087   vsprintf(msg, format, args);
00088   throw AstraException(function, file, line, msg);
00089 }
00090 } // namespace astra_camera
00091 #endif


astra_camera
Author(s): Tim Liu
autogenerated on Wed Jul 10 2019 03:18:54