IMP  2.4.0
The Integrative Modeling Platform
Macros
kernel/container_macros.h File Reference

Macros to define containers of objects. More...

#include <IMP/kernel/kernel_config.h>
#include <IMP/base/check_macros.h>
#include <IMP/base/internal/Vector.h>
#include <IMP/base/SetCheckState.h>
#include <IMP/base/log_macros.h>
#include <IMP/base/doxygen_macros.h>
#include <algorithm>
+ Include dependency graph for kernel/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_DEPENDENCIES(Name, input_deps)
 
#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_PROTECTION(protection)   protection:
 

Detailed Description

Macros to define containers of objects.

Copyright 2007-2015 IMP Inventors. All rights reserved.

Definition in file kernel/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 389 of file kernel/container_macros.h.

#define IMP_CONTAINER_DEPENDENCIES (   Name,
  input_deps 
)

Report dependencies of the container Name. Add the line deps_(new DependenciesScoreState(this), model) to the constructor initializer list. The input_deps argument should add the input containers to a variable ret.

Definition at line 308 of file kernel/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 peform. In operation, _1 is used to refer to the item using its ContainedIndexType (e.g., IMP::kernel::ParticleIndex in SingletonContainer, or IMP::kernel::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 383 of file kernel/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 364 of file kernel/container_macros.h.

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

Internal use only.

Definition at line 29 of file kernel/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
  • foos_begin, foos_end
  • remove_foo
  • remove_foos etc. where foo is the lcname provided.
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 90 of file kernel/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 289 of file kernel/container_macros.h.