IMP  2.0.1
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-2013 IMP Inventors. All rights reserved.
6  */
7 
8 #ifndef IMPDISPLAY_WRITER_MACROS_H
9 #define IMPDISPLAY_WRITER_MACROS_H
10 #include "Writer.h"
11 
12 //! Define information for an TextWriter object
13 /** This macro declares the methods do_open, do_close, add_geometry
14  and show, and defines the destructor and get_version_info.
15 */
16 #define IMP_TEXT_WRITER(Name) \
17  Name(base::TextOutput of): TextWriter(of) \
18  {do_open();} \
19  Name(std::string name): TextWriter(name){ \
20  if (name.find("%1%") == std::string::npos) { \
21  TextWriter::open(); \
22  } \
23  } \
24  Name(const char* name): TextWriter(std::string(name)){ \
25  if (std::string(name).find("%1%") == std::string::npos) { \
26  TextWriter::open(); \
27  } \
28  } \
29  IMP_OBJECT_INLINE(Name,if (0) out << "Hi",do_close()); \
30 protected: \
31  IMP_IMPLEMENT(virtual void do_open()); \
32  IMP_IMPLEMENT(virtual void do_close())
33 
34 
35 #define IMP_WRITER(Name) \
36  IMP_OBJECT_INLINE(Name,if (0) out << "Hi",do_close()); \
37 protected: \
38  IMP_IMPLEMENT(virtual void do_open()); \
39  IMP_IMPLEMENT(virtual void do_close())
40 
41 #if !defined(IMP_DOXYGEN) && !defined(SWIG)
42 #define IMP_REGISTER_WRITER(Name, suffix) \
43  namespace { \
44  internal::WriterFactoryRegistrar Name##registrar(suffix, \
45  new internal::WriterFactoryHelper<Name>()); \
46  }
47 #endif
48 
49 
50 #endif /* IMPDISPLAY_WRITER_MACROS_H */