IMP logo
IMP Reference Guide  develop.63b38c487d,2024/12/21
The Integrative Modeling Platform
raii_macros.h File Reference

Macros to aid in writing RAII-style classes. More...

#include <IMP/kernel_config.h>
#include "showable_macros.h"
#include "RAII.h"
+ Include dependency graph for raii_macros.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define IMP_RAII(Name, args, Initialize, Set, Reset, Show)
 Declares RAII-style methods in a class. More...
 

Detailed Description

Macros to aid in writing RAII-style classes.

Copyright 2007-2022 IMP Inventors. All rights reserved.

Definition in file raii_macros.h.

Macro Definition Documentation

#define IMP_RAII (   Name,
  args,
  Initialize,
  Set,
  Reset,
  Show 
)

Declares RAII-style methods in a class.

Since such class methods are typically quite small and simple, all the implementation is inline. The macro declares

  • default constructor
  • explicit constructor
  • RAII::set()
  • RAII::reset()
  • destructor
Parameters
Namethe class name
argsthe argument string (in parentheses) for the explicit constructor and set()
Initializecode called from any constructor, including the default
Setthe code called from the explicit constructor or the set() function
Resetthe code called from the destructor, and in set before calling the Set code
Showthe code for the show() method

Definition at line 34 of file raii_macros.h.