OKVIS
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
source_file_pos.hpp
Go to the documentation of this file.
1 /*********************************************************************************
2  * OKVIS - Open Keyframe-based Visual-Inertial SLAM
3  * Copyright (c) 2015, Autonomous Systems Lab / ETH Zurich
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are met:
7  *
8  * * Redistributions of source code must retain the above copyright notice,
9  * this list of conditions and the following disclaimer.
10  * * Redistributions in binary form must reproduce the above copyright notice,
11  * this list of conditions and the following disclaimer in the documentation
12  * and/or other materials provided with the distribution.
13  * * Neither the name of Autonomous Systems Lab / ETH Zurich nor the names of
14  * its contributors may be used to endorse or promote products derived from
15  * this software without specific prior written permission.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
21  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27  * POSSIBILITY OF SUCH DAMAGE.
28  *
29  * Created on:
30  * Author: Paul Furgale
31  * Modified: Stefan Leutenegger (s.leutenegger@imperial.ac.uk)
32  *********************************************************************************/
33 
41 #ifndef OKVIS_SOURCE_FILE_POS_HPP
42 #define OKVIS_SOURCE_FILE_POS_HPP
43 
44 #include <string>
45 #include <iostream>
46 #include <sstream>
47 // A class and macro that gives you the current file position.
48 
50 namespace okvis {
51 
53  {
54  public:
55  std::string function;
56  std::string file;
57  int line;
58 
59  source_file_pos(std::string function, std::string file, int line) :
60  function(function), file(file), line(line) {}
61 
62  operator std::string()
63  {
64  return toString();
65  }
66 
67  std::string toString() const
68  {
69  std::stringstream s;
70  s << file << ":" << line << ": " << function << "()";
71  return s.str();
72  }
73 
74  };
75 
76 }// namespace okvis
77 
78 inline std::ostream & operator<<(std::ostream & out, const okvis::source_file_pos & sfp)
79 {
80  out << sfp.file << ":" << sfp.line << ": " << sfp.function << "()";
81  return out;
82 }
83 
84 
85 #define OKVIS_SOURCE_FILE_POS okvis::source_file_pos(__FUNCTION__,__FILE__,__LINE__)
86 
87 #endif // OKVIS_SOURCE_FILE_POS_HPP
int line
Definition: source_file_pos.hpp:57
Definition: source_file_pos.hpp:52
source_file_pos(std::string function, std::string file, int line)
Definition: source_file_pos.hpp:59
std::string file
Definition: source_file_pos.hpp:56
std::ostream & operator<<(std::ostream &out, const okvis::source_file_pos &sfp)
Definition: source_file_pos.hpp:78
std::string toString() const
Definition: source_file_pos.hpp:67
std::string function
Definition: source_file_pos.hpp:55