Choreonoid  1.8
BodyHandler.h
Go to the documentation of this file.
1 #ifndef CNOID_BODY_BODY_HANDLER_H
2 #define CNOID_BODY_BODY_HANDLER_H
3 
4 #include <cnoid/Referenced>
5 #include <cnoid/Config>
6 #include <string>
7 #include <iosfwd>
8 #include <memory>
9 #include "exportdecl.h"
10 
11 namespace cnoid {
12 
13 class Body;
14 class BodyHandlerManager;
15 
20 class CNOID_EXPORT BodyHandler : public Referenced
21 {
22 public:
23  static bool checkVersion(const char* name, int version, int internalVersion, std::ostream& os);
24  virtual bool initialize(Body* body, std::ostream& os) = 0;
25  virtual BodyHandler* clone() = 0;
26  const std::string& filename() const { return filename_; }
27 
28 private:
29  std::string filename_;
30 
31  friend class BodyHandlerManager;
32 };
33 
35 
36 }
37 
38 #if defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__NT__)
39 #define CNOID_BODY_HANDLER_EXPORT __declspec(dllexport)
40 #elif __GNUC__ >= 4
41 #define CNOID_BODY_HANDLER_EXPORT __attribute__ ((visibility("default")))
42 #else
43 #define CNOID_BODY_HANDLER_EXPORT
44 #endif
45 
46 #define CNOID_IMPLEMENT_BODY_HANDLER_FACTORY(HandlerClassName) \
47  extern "C" CNOID_BODY_HANDLER_EXPORT cnoid::BodyHandler* createCnoidBodyHandler(std::ostream& os) \
48  {\
49  if(BodyHandler::checkVersion(#HandlerClassName, CNOID_VERSION, CNOID_INTERNAL_VERSION, os)){ \
50  return new HandlerClassName(); \
51  } \
52  return nullptr; \
53  }
54 
55 #endif
cnoid::ref_ptr
Definition: Referenced.h:103
cnoid
Definition: AbstractSceneLoader.h:11
cnoid::BodyHandler
Definition: BodyHandler.h:20
cnoid::Referenced
Definition: Referenced.h:54
cnoid::BodyHandlerManager
Definition: BodyHandlerManager.h:13
cnoid::BodyHandlerPtr
ref_ptr< BodyHandler > BodyHandlerPtr
Definition: BodyHandler.h:34
cnoid::Body
Definition: Body.h:28
cnoid::BodyHandler::filename
const std::string & filename() const
Definition: BodyHandler.h:26