IMP logo
IMP Reference Guide  2.7.0
The Integrative Modeling Platform
writer_macros.h
Go to the documentation of this file.
1 /**
2  * \file IMP/display/writer_macros.h
3  * \brief macros for display classes
4  *
5  * Copyright 2007-2017 IMP Inventors. All rights reserved.
6  */
7 
8 #ifndef IMPDISPLAY_WRITER_MACROS_H
9 #define IMPDISPLAY_WRITER_MACROS_H
10 #include "Writer.h"
11 #include <boost/shared_ptr.hpp>
12 #include <boost/make_shared.hpp>
13 
14 //! Define information for an TextWriter object
15 /** This macro declares the methods do_open, do_close, add_geometry
16  and show, and defines the destructor and get_version_info.
17 */
18 #define IMP_TEXT_WRITER(Name) \
19  Name(TextOutput of) : TextWriter(of) { do_open(); } \
20  Name(std::string name) : TextWriter(name) { \
21  if (name.find("%1%") == std::string::npos) { \
22  TextWriter::open(); \
23  } \
24  } \
25  Name(const char* name) : TextWriter(std::string(name)) { \
26  if (std::string(name).find("%1%") == std::string::npos) { \
27  TextWriter::open(); \
28  } \
29  } \
30  IMP_OBJECT_METHODS(Name); \
31  \
32  protected: \
33  virtual void do_destroy() IMP_OVERRIDE { do_close(); } \
34  virtual void do_open(); \
35  virtual void do_close()
36 
37 #define IMP_WRITER(Name) \
38  IMP_OBJECT_METHODS(Name); \
39  \
40  protected: \
41  virtual void do_destroy() IMP_OVERRIDE { do_close(); } \
42  virtual void do_open(); \
43  virtual void do_close()
44 
45 #if !defined(IMP_DOXYGEN) && !defined(SWIG)
46 #define IMP_REGISTER_WRITER(Name, suffix) \
47  namespace { \
48  internal::WriterFactoryRegistrar Name##registrar( \
49  suffix, boost::make_shared<internal::WriterFactoryHelper<Name> >()); \
50  }
51 #endif
52 
53 #endif /* IMPDISPLAY_WRITER_MACROS_H */
Base class for writing geometry to a file.