IMP logo
IMP Reference Guide  2.22.0
The Integrative Modeling Platform
container_macros.h File Reference

Macros to define containers of objects. More...

#include <IMP/kernel_config.h>
#include <IMP/check_macros.h>
#include <IMP/internal/Vector.h>
#include <IMP/SetCheckState.h>
#include <IMP/log_macros.h>
#include <IMP/doxygen_macros.h>
#include <algorithm>
+ Include dependency graph for container_macros.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define IMP_CONTAINER_ACCESS(ContainerType, container, operation)
 
#define IMP_CONTAINER_FOREACH(ContainerType, container, operation)   IMP_CONTAINER_FOREACH_IMPL(ContainerType, container, operation, )
 
#define IMP_CONTAINER_FOREACH_IMPL(ContainerType, container, operation, tname)
 
#define IMP_CONTAINER_FOREACH_LOOP(ContainerType, container, operation, tname)
 
#define IMP_CONTAINER_FOREACH_TEMPLATE(ContainerType, container, operation)   IMP_CONTAINER_FOREACH_IMPL(ContainerType, container, operation, typename)
 
#define IMP_EXPOSE_ITERATORS(ContainerType, container_name, Ucname, Ucnames, lcname, lcnames)
 
#define IMP_FORCE_EXPORT(x)   x
 
#define IMP_LIST(protection, Ucname, lcname, Data, PluralData)
 A macro to provide a uniform interface for storing lists of objects. More...
 
#define IMP_LIST_ACTION(protection, Ucname, Ucnames, lcname, lcnames, Data, PluralData, OnAdd, OnChanged, OnRemoved)
 
#define IMP_LIST_ACTION_IMPL(Class, Ucname, Ucnames, lcname, lcnames, Data, PluralData)
 
#define IMP_LIST_IMPL(Class, Ucname, lcname, Data, PluralData)
 This should go in a .cpp file for the respective class. More...
 
#define IMP_LIST_PYTHON_IMPL(lcname, lcnames, ucnames, Ucnames)
 
#define IMP_PROTECTION(protection)   protection:
 

Detailed Description

Macros to define containers of objects.

Copyright 2007-2022 IMP Inventors. All rights reserved.

Definition in file container_macros.h.

Macro Definition Documentation

#define IMP_CONTAINER_ACCESS (   ContainerType,
  container,
  operation 
)

Provide a block that can have efficient, direct access to the contents of the container in the variable imp_indexes.

Definition at line 424 of file container_macros.h.

#define IMP_CONTAINER_FOREACH (   ContainerType,
  container,
  operation 
)    IMP_CONTAINER_FOREACH_IMPL(ContainerType, container, operation, )

These macros avoid various inefficiencies.

The macros take the name of the container and the operation to perform. In operation, _1 is used to refer to the item using its ContainedIndexType (e.g., IMP::ParticleIndex in SingletonContainer, or IMP::ParticleIndexPair in PairContainer). The location of this item in the container itself is _2. Use it like:

IMP_CONTAINER_FOREACH(SingletonContainer, sc, std::cout << "Item "
<< _2 << " has particle index " << _1 << std::endl);

See IMP_CONTAINER_FOREACH_TEMPLATE() if you want to use it in a template function.

Definition at line 418 of file container_macros.h.

#define IMP_CONTAINER_FOREACH_TEMPLATE (   ContainerType,
  container,
  operation 
)    IMP_CONTAINER_FOREACH_IMPL(ContainerType, container, operation, typename)
See Also
IMP_CONTAINER_FOREACH().

This version is for use in a template function. See IMP_FOREACH_INDEX() for another version.

Definition at line 399 of file container_macros.h.

#define IMP_EXPOSE_ITERATORS (   ContainerType,
  container_name,
  Ucname,
  Ucnames,
  lcname,
  lcnames 
)

Internal use only.

Definition at line 29 of file container_macros.h.

#define IMP_LIST (   protection,
  Ucname,
  lcname,
  Data,
  PluralData 
)
Value:
IMP_LIST_ACTION(protection, Ucname, Ucname##s, lcname, lcname##s, Data, \
PluralData, , , )

A macro to provide a uniform interface for storing lists of objects.

This macro is designed to be used in the body of an object to add a set of methods for manipulating a list of contained objects. It adds methods

  • get_foo
  • set_foo
  • set_foos
  • erase_foo
  • foos_begin, foos_end
  • remove_foo
  • remove_foos etc. where foo is the lcname provided. In Python, a 'foos' member is also provided, which acts like a regular Python list (the above methods can also be used if desired).
Parameters
[in]protectionThe level of protection for the container (public, private).
[in]UcnameThe name of the type of container in uppercase.
[in]lcnameThe name of the type of container in lower case.
[in]DataThe type of the data to store.
[in]PluralDataThe plural of the data name. This should be a container type.

An accompanying IMP_LIST_IMPL must go in a .cpp file.

Note
This macro should be given an appropriate name and wrapped in a doxygen comment block such as by starting with a C++ comment like
@name short description
longer description
@{
and ending with one like
@}

Definition at line 127 of file container_macros.h.

#define IMP_LIST_IMPL (   Class,
  Ucname,
  lcname,
  Data,
  PluralData 
)
Value:
IMP_LIST_ACTION_IMPL(Class, Ucname, Ucname##s, lcname, lcname##s, Data, \
PluralData)

This should go in a .cpp file for the respective class.

This code should go in a .cpp file. One macro for each IMP_CONTAINER.

Parameters
[in]ClassThe name of the class containing this container.
[in]UcnameThe name of the type of container in uppercase.
[in]lcnameThe name of the type of container in lower case.
[in]DataThe type of the data to store.
[in]PluralDataThe plural of the data name. This should be a container type.

For all of these the current object is called obj and is of type Data.

Definition at line 356 of file container_macros.h.