AGX Dynamics  2.35.0.1
SourceCodeInfo.h
Go to the documentation of this file.
1 /*
2 Copyright 2007-2022. Algoryx Simulation AB.
3 
4 All AGX source code, intellectual property, documentation, sample code,
5 tutorials, scene files and technical white papers, are copyrighted, proprietary
6 and confidential material of Algoryx Simulation AB. You may not download, read,
7 store, distribute, publish, copy or otherwise disseminate, use or expose this
8 material unless having a written signed agreement with Algoryx Simulation AB, or having been
9 advised so by Algoryx Simulation AB for a time limited evaluation, or having purchased a
10 valid commercial license from Algoryx Simulation AB.
11 
12 Algoryx Simulation AB disclaims all responsibilities for loss or damage caused
13 from using this software, unless otherwise stated in written agreements with
14 Algoryx Simulation AB.
15 */
16 
17 #ifndef AGXUNIT_SOURCECODEINFO_H
18 #define AGXUNIT_SOURCECODEINFO_H
19 
20 #include <agx/config.h>
21 #include <agx/config/AGX_USE_UNIT_TESTS.h>
22 
23 
24 #if AGX_USE_UNIT_TESTS()
25 
26 #include <agx/agxPhysics_export.h>
27 #include <agx/String.h>
28 #include <iosfwd>
29 
30 
31 #ifdef _MSC_VER
32 # pragma warning(push)
33 # pragma warning(disable: 4251) // warning C4251: class X needs to have dll-interface to be used by clients of class Y
34 #endif
35 
36 
37 namespace agxUnit
38 {
39  class AGXPHYSICS_EXPORT SourceCodeInfo
40  {
41  public:
42  SourceCodeInfo() : m_line(0) {}
43  SourceCodeInfo(int line, const agx::String& file, const agx::String& function) : m_line(line), m_file(file), m_function(function) {}
44 
45  SourceCodeInfo & operator =( const SourceCodeInfo &other )
46  {
47  if ( this != &other )
48  {
49  m_file = other.m_file.c_str();
50  m_line = other.m_line;
51  m_function = other.m_function.c_str();
52  }
53  return *this;
54  }
55 
56  SourceCodeInfo( const SourceCodeInfo &other )
57  : m_line( other.m_line ), m_file( other.m_file.c_str() ), m_function( other.m_function.c_str() )
58  {
59  }
60 
61 
62  bool operator ==( const SourceCodeInfo &other ) const {
63  return m_line == other.m_line && m_file == other.m_file&& m_function==other.m_function;
64  }
65 
66  bool operator !=( const SourceCodeInfo &other ) const { return !(*this == other); }
67 
68  agx::String filename() const { return m_file; }
69  agx::String function() const { return m_function; }
70  int line() const { return m_line; }
71 
72  friend std::ostream& operator <<( std::ostream& os, const SourceCodeInfo &info ) {
73  os << "File: " << info.filename();
74 #ifdef __linux__
75  os << ":" << info.line() << " ";
76 #else
77  os << "(" << info.line() << ") ";
78 #endif
79  os << "Function: " << info.function();
80  return os;
81  }
82 
83  private:
84  int m_line;
85  agx::String m_file;
86  agx::String m_function;
87  };
88 
89 
90 }
91 
92 #ifdef _MSC_VER
93 # pragma warning(pop)
94 #endif
95 
96 
97 #endif // AGX_USE_UNIT_TESTS()
98 
99 
100 
101 #endif //AGXUNIT_SOURCECODEINFO_H
std::ostream & operator<<(std::ostream &o, const agx::Vec6 &v)
Definition: Vec6.h:230
#define AGXPHYSICS_EXPORT
bool operator!=(T val, InvalidIndexStruct)
Definition: agx.h:196
bool operator==(T val, InvalidIndexStruct)
Definition: agx.h:190