IMP logo

macros.h File Reference

Various general useful macros for IMP. More...

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.


Defines

#define IMP_COMPARISONS
 Implement comparison in a class using a compare function.
#define IMP_COMPARISONS_1(field)
 Implement comparison in a class using field as the variable to compare.
#define IMP_COMPARISONS_2(f0, f1)
 Implement comparison in a class using field as the variable to compare.
#define IMP_COMPARISONS_3(f0, f1, f2)
 Implement comparison in a class using field as the variable to compare.
#define IMP_CONSTRAINT(Name)
 Define the basics needed for a ScoreState.
#define IMP_COPY_CONSTRUCTOR(TC)
 Use a copy_from method to create a copy constructor and operator=.
#define IMP_DECLARE_CONTROLLED_KEY_TYPE(Name, Tag)
#define IMP_DECLARE_KEY_TYPE(Name, Tag)
#define IMP_FAILURE_HANDLER(Name)
 Declare a IMP::FailureHandler.
#define IMP_INCREMENTAL_RESTRAINT(Name)
 Define the basic things you need for a Restraint.
#define IMP_INTERNAL_OBJECT(Name)
 Define the basic things needed by any internal Object.
#define IMP_INTERNAL_SINGLETON_MODIFIER(Name,apply_expr)
 Define a simple SingletonModifier.
#define IMP_NEW(Typename, varname, args)   IMP::Pointer<Typename> varname(new Typename args)
 Declare a ref counted pointer to a new object.
#define IMP_NO_DOXYGEN(x)
 Hide something from doxygen.
#define IMP_NO_SWIG(x)   x
 Hide the line when SWIG is compiled or parses it.
#define IMP_OBJECT(Name)
 Define the basic things needed by any Object.
#define IMP_OBJECT_INLINE(Name, show, destructor)
 Define the basic things needed by any Object.
#define IMP_OBJECTS(Name)
 Define the types for storing sets of objects.
#define IMP_ONLY_DOXYGEN(x)   x
 Only show something to doxygen.
#define IMP_OPTIMIZER(Name)
 Define the basic things you need for an Optimizer.
#define IMP_OPTIMIZER_STATE(Name)
 Define the basics needed for an OptimizerState.
#define IMP_OUTPUT_OPERATOR(name)
 Implement operator<< on class name.
#define IMP_OUTPUT_OPERATOR_1(name)
 Implement operator<< on class name, assuming it has one template argument.
#define IMP_OUTPUT_OPERATOR_2(name)
 Implement operator<< on class name, assuming it has two template arguments.
#define IMP_OUTPUT_OPERATOR_D(name)
 Implement operator<< on class name templated by the dimension.
#define IMP_PAIR_CONTAINER(Name)
 Declare the needed functions for a PairContainer.
#define IMP_PAIR_FILTER(Name)
 Declare the needed functions for a PairFilter.
#define IMP_PAIR_MODIFIER(Name)
 Declare the functions needed for a PairModifier.
#define IMP_PAIR_MODIFIER_DA(Name)
 Declare the functions needed for a PairModifier.
#define IMP_PAIR_SCORE(Name)
 Declare the functions needed for a PairScore.
#define IMP_PERIODIC_OPTIMIZER_STATE(Name)
 Define the basics needed for an OptimizerState which acts every n steps.
#define IMP_QUAD_CONTAINER(Name)
 Declare the needed functions for a QuadContainer.
#define IMP_QUAD_FILTER(Name)
 Declare the needed functions for a QuadFilter.
#define IMP_QUAD_SCORE(Name)
 Declare the functions needed for a QuadScore.
#define IMP_RAII(Name, args, Initialize, Set, Reset)
 Declare a RAII-style class.
#define IMP_REF_COUNTED_DESTRUCTOR(Name)
 Ref counted objects should have private destructors.
#define IMP_REF_COUNTED_NONTRIVIAL_DESTRUCTOR(Name)
#define IMP_REFINER(Name)
 Define the basics needed for a particle refiner.
#define IMP_RESTRAINT(Name)
 Define the basic things you need for a Restraint.
#define IMP_SAMPLER(Name)
 Define the basic things you need for a Sampler.
#define IMP_SCORE_STATE(Name)
 Define the basics needed for a ScoreState.
#define IMP_SHOWABLE
 Declare the methods needed by an object that can be printed.
#define IMP_SHOWABLE_INLINE(how_to_show)
 Declare the methods needed by an object that can be printed.
#define IMP_SIMPLE_PAIR_SCORE(Name)
 Declare the functions needed for a SingletonScore.
#define IMP_SIMPLE_REFINER(Name)
 Define the basics needed for a particle refiner.
#define IMP_SIMPLE_SINGLETON_SCORE(Name)
 Declare the functions needed for a SingletonScore.
#define IMP_SIMPLE_TRIPLET_SCORE(Name)
 Declare the functions needed for a TripletScore.
#define IMP_SINGLETON_CONTAINER(Name)
 Declare the needed functions for a SingletonContainer.
#define IMP_SINGLETON_FILTER(Name)
 Declare the needed functions for a SingletonFilter.
#define IMP_SINGLETON_MODIFIER(Name)
 Declare the functions needed for a SingletonModifier.
#define IMP_SINGLETON_MODIFIER_DA(Name)
 Declare the functions needed for a SingletonModifier.
#define IMP_SINGLETON_MODIFIER_FROM_REFINED(Name, refiner)
 Add interaction methods to a SingletonModifer.
#define IMP_SINGLETON_MODIFIER_TO_REFINED(Name, refiner)
 Add interaction methods to a SingletonModifer.
#define IMP_SINGLETON_SCORE(Name)
 Declare the functions needed for a SingletonScore.
#define IMP_SWAP_MEMBER(var_name)   std::swap(var_name, o.var_name);
 Swap two member variables assuming the other object is called o.
#define IMP_SWITCH_DOXYGEN(x, y)   x
#define IMP_TRIPLET_CONTAINER(Name)
 Declare the needed functions for a TripletContainer.
#define IMP_TRIPLET_FILTER(Name)
 Declare the needed functions for a TripletFilter.
#define IMP_TRIPLET_SCORE(Name)
 Declare the functions needed for a TripletScore.
#define IMP_UNARY_FUNCTION(Name)
 Declare the needed functions for a UnaryFunction.
#define IMP_UNARY_FUNCTION_INLINE(Name, value_expression,derivative_expression, show_expression)
 Declare the needed functions for a UnaryFunction which evaluates inline.
#define IMP_VALUES(Name)   class Name##s;
 Define the type for storing sets of values.
Macros to aid with implementing decorators
These macros are here to aid in implementation of IMP::Decorator objects. The first two declare/define the expected methods. The remainder help implement basic functions.

#define IMP_DECORATOR(Name, Parent)
 Define the basic things needed by a Decorator.
#define IMP_DECORATOR_ARRAY_DECL(protection, Class,Name, name, plural,traits, ExternalType, ExternalTypes)
 Define a set of attributes which form an array.
#define IMP_DECORATOR_GET(AttributeKey, Type, has_action, not_has_action)
 Perform actions dependent on whether a particle has an attribute.
#define IMP_DECORATOR_GET_SET(name, AttributeKey, Type, ReturnType)
 Define methods for getting and setting a particular simple field.
#define IMP_DECORATOR_GET_SET_OPT(name, AttributeKey, Type,ReturnType, default_value)
 Define methods for getting and setting an optional simple field.
#define IMP_DECORATOR_SET(AttributeKey, value)
 Set an attribute, creating it if it does not already exist.
#define IMP_DECORATOR_TRAITS(Name, Parent, TraitsType, traits_name,default_traits)
 Define the basic things needed by a Decorator which has a traits object.
#define IMP_DECORATORS(Name, Parent)
 Define the types for storing sets of decorators.
#define IMP_SUMMARY_DECORATOR_DECL(Name, Parent, Members)
 Create a decorator that computes some sort of summary info on a set.
#define IMP_SUMMARY_DECORATOR_DEF(Name, Parent, Members, create_modifier)
Swap helpers
Use the swap_with member function to swap two objects. The two objects mustbe of the same type (Name) and define the method swap_with(). The number suffix is the number of template arguments, all of which must be of class type.

#define IMP_SWAP(Name)   inline void swap(Name &a, Name &b) {a.swap_with(b);}
#define IMP_SWAP_1(Name)
#define IMP_SWAP_2(Name)
#define IMP_SWAP_3(Name)

Detailed Description

Various general useful macros for IMP.

Copyright 2007-2010 IMP Inventors. All rights reserved.


Define Documentation

#define IMP_COMPARISONS

Implement comparison in a class using a compare function.

The macro requires that This be defined as the type of the current class. The compare function should take a const This & and return -1, 0, 1 as appropriate.

#define IMP_COMPARISONS_1 ( field   ) 

Implement comparison in a class using field as the variable to compare.

The macro requires that This be defined as the type of the current class.

#define IMP_COMPARISONS_2 ( f0,
f1   ) 

Implement comparison in a class using field as the variable to compare.

The macro requires that This be defined as the type of the current class.

#define IMP_COMPARISONS_3 ( f0,
f1,
f2   ) 

Implement comparison in a class using field as the variable to compare.

The macro requires that This be defined as the type of the current class.

#define IMP_COPY_CONSTRUCTOR ( TC   ) 

Value:

TC(const TC &o){copy_from(o);} \
  TC& operator=(const TC &o) {copy_from(o); return *this;}
Use a copy_from method to create a copy constructor and operator=.

This macro is there to aid with classes which require a custom copy constructor. It simply forwards operator= and the copy constructor to a method copy_from() which should do the copying.

You should think very hard before implementing a class which requires a custom copy custructor as it is easy to get wrong and you can easily wrap most resources with RAII objects (wikipedia entry).

#define IMP_DECLARE_CONTROLLED_KEY_TYPE ( Name,
Tag   ) 

Define a new key non lazy type where new types have to be created explicitly.

See also:
IMP_DECLARE_KEY_TYPE

#define IMP_DECLARE_KEY_TYPE ( Name,
Tag   ) 

Define a new key type.

It defines two public types: Name, which is an instantiation of KeyBase, and Names which is a vector of Name.

Parameters:
[in] Name The name for the new type.
[in] Tag A (hopefully) unique integer to define this key type.
Note:
We define a new class rather than use a typedef since SWIG has a bug dealing with names that start with ::. A fix has been commited to SVN for SWIG.

The name in the typedef would have to start with IMP so it could be used out of the IMP namespace.

#define IMP_DECORATOR ( Name,
Parent   ) 

Define the basic things needed by a Decorator.

The macro defines the following methods

  • a default constructor Decorator::Decorator()

It also declares:

Finally, it expects methods corresponding to

You also implement static methods get_x_key() to return each of the keys used. These static methods, which must be defined in the .cpp file, should declare the key itself as a static member variable to avoid initializing the key if the decorator is not used.

See IMP::Decorator for a more detailed description of decorators.

Parameters:
[in] Name is the name of the decorator, such as XYZR
[in] Parent The class name for the parent of this class, typically Decorator
See also:
IMP_DECORATOR_TRAITS()

#define IMP_DECORATOR_ARRAY_DECL ( protection,
Class,
Name,
name,
plural,
traits,
ExternalType,
ExternalTypes   ) 

Define a set of attributes which form an array.

The macro defines a set of functions for using the array:

  • get_name(unsigned int)

  • get_number_of_name()

  • add_name(ExternalType)

  • add_name_at(ExternalType, unsigned int)

  • remove_name(unsigned int)

in addition it defines the private methods

  • add_required_attributes_for_name(Particle *)

Parameters:
[in] protection Whether it should be public, protected or private
[in] Class The name of the wrapping class
[in] Name The capitalized name of the prefix to use
[in] name the name prefix to use, see the above method names
[in] plural the plural form of the name
[in] traits the traits object to use to manipulate things. This should inherit from or implement the interface of internal::ArrayOnAttributesHelper
[in] ExternalType The name of the type to wrap the return type with.
[in] ExternalTypes A vector of the return type.

#define IMP_DECORATOR_GET ( AttributeKey,
Type,
has_action,
not_has_action   ) 

Perform actions dependent on whether a particle has an attribute.

A common pattern is to check if a particle has a particular attribute, do one thing if it does and another if it does not. This macro implements that pattern. It requires that the method get_particle() return the particle being used.

Parameters:
[in] AttributeKey The key for the attribute
[in] Type The type for the attribute ("Int", "Float", "String")
[in] has_action The action to take if the Particle has the attribute. The attribute value is stored in the variable VALUE.
[in] not_has_action The action to take if the Particle does not have the attribute.
See also:
IMP_DECORATOR_GET()

IMP_DECORATOR_GET_SET()

#define IMP_DECORATOR_GET_SET ( name,
AttributeKey,
Type,
ReturnType   ) 

Define methods for getting and setting a particular simple field.

This macro defines methods to get and set a particular attribute.

Parameters:
[in] name The lower case name of the attribute
[in] AttributeKey The AttributeKey object controlling the attribute.
[in] Type The type of the attribute (upper case).
[in] ReturnType The type to return from the get.
See also:
IMP_DECORATOR_GET()

IMP_DECORATOR_SET()

#define IMP_DECORATOR_GET_SET_OPT ( name,
AttributeKey,
Type,
ReturnType,
default_value   ) 

Define methods for getting and setting an optional simple field.

See IMP_DECORATOR_GET_SET(). The difference is that here you can provide a default value to use if the decorator does not have the attribute.

Parameters:
[in] name The lower case name of the attribute
[in] AttributeKey The expression to get the required attribute key.
[in] Type The type of the attribute (upper case).
[in] ReturnType The type to return from the get.
[in] default_value The value returned if the attribute is missing.

#define IMP_DECORATOR_SET ( AttributeKey,
value   ) 

Set an attribute, creating it if it does not already exist.

Another common pattern is to have an assumed value if the attribute is not there. Then, you sometimes need to set the value whether it is there or not.

See also:
IMP_DECORATOR_GET()

IMP_DECORATOR_GET_SET()

#define IMP_DECORATOR_TRAITS ( Name,
Parent,
TraitsType,
traits_name,
default_traits   ) 

Define the basic things needed by a Decorator which has a traits object.

This macro is the same as IMP_DECORATOR() except that an extra object of type TraitsType is passed after the particle to

As in the IMP::core::XYZR or IMP::core::Hierarchy, this object can be used to parameterize the Decorator. The traits object is stored in the decorator and made accessible through the get_traits() method.

#define IMP_DECORATORS ( Name,
Parent   ) 

Value:

class Name##s: public Parent {};              \
  class Name##sTemp: public Parent##Temp {}
Define the types for storing sets of decorators.

The macro defines the types Names and NamesTemp.

#define IMP_NEW ( Typename,
varname,
args   )     IMP::Pointer<Typename> varname(new Typename args)

Declare a ref counted pointer to a new object.

Parameters:
[in] Typename The namespace qualified type being declared
[in] varname The name for the ref counted pointer
[in] args The arguments to the constructor, or () if there are none.
See also:
IMP::Pointer
    IMP_NEW(m, IMP::Model, ());

#define IMP_NO_DOXYGEN (  ) 

Hide something from doxygen.

#define IMP_NO_SWIG (  )     x

Hide the line when SWIG is compiled or parses it.

#define IMP_OBJECTS ( Name   ) 

Value:

class Name##sTemp {};                         \
  class Name##s:public Name##sTemp{};
Define the types for storing sets of objects.

The macro defines the types Names and NamesTemp.

#define IMP_ONLY_DOXYGEN (  )     x

Only show something to doxygen.

#define IMP_OUTPUT_OPERATOR ( name   ) 

Implement operator<< on class name.

The class named should define the method void show(std::ostream&).

#define IMP_OUTPUT_OPERATOR_1 ( name   ) 

Implement operator<< on class name, assuming it has one template argument.

The class named should define the method void show(std::ostream&).

#define IMP_OUTPUT_OPERATOR_2 ( name   ) 

Implement operator<< on class name, assuming it has two template arguments.

The class named should define the method void show(std::ostream&).

#define IMP_OUTPUT_OPERATOR_D ( name   ) 

Implement operator<< on class name templated by the dimension.

The class named should define the method void show(std::ostream&).

#define IMP_REF_COUNTED_DESTRUCTOR ( Name   ) 

Value:

protected:                                                    \
  template <class T> friend void IMP::internal::unref(T*);      \
  virtual ~Name(){}
Ref counted objects should have private destructors.

This macro defines a private destructor and adds the appropriate friend methods so that the class can be used with ref counting. By defining a private destructor, you make it so that the object cannot be declared on the stack and so must be ref counted.

See also:
IMP_REF_COUNTED_NONTRIVIAL_DESTRUCTOR()

IMP::RefCounted

#define IMP_REF_COUNTED_NONTRIVIAL_DESTRUCTOR ( Name   ) 

Value:

protected:                                                    \
  template <class T> friend void IMP::internal::unref(T*);      \
  virtual ~Name()
Like IMP_REF_COUNTED_DESTRUCTOR(), but the destructor is only declared, not defined.

#define IMP_SHOWABLE

Declare the methods needed by an object that can be printed.

This macro declares the method

  • void show(std::ostream &out) const It also makes it so that the object can be printed in Python.

The ostream and sstream headers must be included.

See also IMP_SHOWABLE_INLINE().

Do not use with IMP::Object objects as they have their own show mechanism.

#define IMP_SHOWABLE_INLINE ( how_to_show   ) 

Declare the methods needed by an object that can be printed.

This macro declares the method

  • void show(std::ostream &out) const It also makes it so that the object can be printed in Python.

The ostream and sstream headers must be included.

See also IMP_SHOWABLE_INLINE()

#define IMP_SUMMARY_DECORATOR_DECL ( Name,
Parent,
Members   ) 

Create a decorator that computes some sort of summary info on a set.

Examples include a centroid or a cover for a set of particles.

Parameters:
[in] Name The name for the decorator
[in] Parent the parent decorator type
[in] Members the way to pass a set of particles in

#define IMP_SUMMARY_DECORATOR_DEF ( Name,
Parent,
Members,
create_modifier   ) 

See IMP_SUMMARY_DECORATOR_DECL()

Parameters:
[in] Name The name for the decorator
[in] Parent the parent decorator type
[in] Members the way to pass a set of particles in
[in] create_modifier the statements to create the modifier which computes the summary info. It should be called mod.

#define IMP_SWAP_1 ( Name   ) 

Value:

template <class A>                                            \
  inline void swap(Name<A> &a, Name<A> &b) {a.swap_with(b);}

#define IMP_SWAP_MEMBER ( var_name   )     std::swap(var_name, o.var_name);

Swap two member variables assuming the other object is called o.

Swap the member var_name of the two objects (this and o).

#define IMP_VALUES ( Name   )     class Name##s;

Define the type for storing sets of values.

The macro defines the type Names.


Generated on Mon Mar 8 23:06:01 2010 for IMP by doxygen 1.5.8