macros.h
Go to the documentation of this file.
1 //
2 // macros.h
3 // gepetto-viewer
4 //
5 // Created by Justin Carpentier, Mathieu Geisert in November 2014.
6 // Copyright (c) 2014 LAAS-CNRS. All rights reserved.
7 //
8 
9 #ifndef GEPETTO_VIEWER_MACROS_HH
10 #define GEPETTO_VIEWER_MACROS_HH
11 
12 #if __cplusplus > 199711L
13 #include <memory>
14 namespace gepetto {
15 namespace viewer {
16  using std::shared_ptr;
17  using std::weak_ptr;
18  using std::static_pointer_cast;
19  using std::dynamic_pointer_cast;
20 }
21 }
22 #else
23 #ifndef Q_MOC_RUN
24 #include <boost/shared_ptr.hpp>
25 #include <boost/weak_ptr.hpp>
26 namespace gepetto {
27 namespace viewer {
28  using boost::shared_ptr;
29  using boost::weak_ptr;
30  using boost::static_pointer_cast;
31  using boost::dynamic_pointer_cast;
32 }
33 }
34 #endif
35 #endif
36 
37 #include <osg/ref_ptr>
38 
40 #define ASSERT(condition, message) \
41 do { \
42 if (! (condition)) { \
43 std::cerr << "Assertion `" #condition "` failed in " << __FILE__ \
44 << " line " << __LINE__ << ": " << message << std::endl; \
45 std::exit(EXIT_FAILURE); \
46 } \
47 } while (false)
48 
50 #define DEF_CLASS_SMART_PTR(className) \
51 class className; \
52 typedef ::gepetto::viewer::shared_ptr<className> className##Ptr_t; \
53 typedef ::gepetto::viewer::shared_ptr<const className> className##ConstPtr_t; \
54 typedef ::gepetto::viewer::weak_ptr<className> className##WeakPtr; \
55 typedef ::gepetto::viewer::weak_ptr<const className> className##ConstWeakPtr; \
56 
57 #define DEF_OSG_CLASS_REF_PTR(className) \
58  /*class className;*/ \
59  typedef ::osg::ref_ptr< className > className##RefPtr; \
60  typedef ::osg::observer_ptr< className > className##ObserverPtr;
61 
62 #define SCENE_VIEWER_ACCEPT_VISITOR \
63  \
64  virtual void accept (NodeVisitor& nv) { if (nv.valid(*this)) { nv.apply (*this); } } \
65 
66 #endif // GEPETTO_VIEWER_MACROS_HH
Definition: action-search-bar.hh:27