IMP logo
IMP Reference Guide  develop.7482b7c7af, 2026/12/05
The Integrative Modeling Platform
IMP::example::ExampleTemplateClassD< D > Class Template Reference

A line segment templated on the dimension. More...

#include <IMP/example/ExampleTemplateClass.h>

Inheritance diagram for IMP::example::ExampleTemplateClassD< D >:

Detailed Description

template<unsigned int D>
class IMP::example::ExampleTemplateClassD< D >

A line segment templated on the dimension.

Like the underlying algebra::VectorD data, is not initialized when the default constructor is used. Since it is a small class, it is designed to be allocated on the stack and to be passed by value (or const &).

The class should be named SegmentD, but it is a demonstration.

The source code is as follows:

/**
* \file IMP/example/ExampleTemplateClass.h
* \brief Show how to manage a template class with Python.
*
* Copyright 2007-2026 IMP Inventors. All rights reserved.
*
*/
#ifndef IMPEXAMPLE_EXAMPLE_TEMPLATE_CLASS_H
#define IMPEXAMPLE_EXAMPLE_TEMPLATE_CLASS_H
#include <IMP/example/example_config.h>
#include <IMP/utility.h>
IMPEXAMPLE_BEGIN_NAMESPACE
//! A line segment templated on the dimension.
/** Like the underlying
algebra::VectorD data, is not initialized when the default
constructor is used. Since it is a small class, it is designed to
be allocated on the stack and to be passed by value (or
const &).
The class should be named SegmentD, but it is a demonstration.
The source code is as follows:
\include ExampleTemplateClass.h
*/
template <unsigned int D>
class ExampleTemplateClassD {
public:
ExampleTemplateClassD() {}
/** Since it is a simple object, there is no reason to provide
methods to change the data.
*/
eps_[0] = a;
eps_[1] = b;
}
//! Get one of the endpoints
const IMP::algebra::VectorD<D> &get_point(unsigned int i) const {
IMP_USAGE_CHECK(i < 2, "The endpoint index can only be 0 or 1");
return eps_[i];
}
IMP_SHOWABLE_INLINE(ExampleTemplateClassD, out << eps_[0] << " " << eps_[1];);
};
typedef ExampleTemplateClassD<3> ExampleTemplateClass3D;
typedef Vector<ExampleTemplateClassD<3>> ExampleTemplateClass3Ds;
IMPEXAMPLE_END_NAMESPACE
#endif /* IMPEXAMPLE_EXAMPLE_TEMPLATE_CLASS_H */
Simple D vector class.
#define IMP_USAGE_CHECK(expr, message)
A runtime test for incorrect usage of a class or method.
A Cartesian vector in D-dimensions.
Definition VectorD.h:38
A line segment templated on the dimension.
#define IMP_SHOWABLE_INLINE(Name, how_to_show)
Declare the methods needed by an object that can be printed.
Various general useful functions for IMP.

Definition at line 32 of file ExampleTemplateClass.h.

Public Member Functions

 ExampleTemplateClassD (const IMP::algebra::VectorD< D > &a, const IMP::algebra::VectorD< D > &b)
const IMP::algebra::VectorD< D > & get_point (unsigned int i) const
 Get one of the endpoints.
void show (std::ostream &out=std::cout) const

Constructor & Destructor Documentation

◆ ExampleTemplateClassD() [1/2]

template<unsigned int D>
IMP::example::ExampleTemplateClassD< D >::ExampleTemplateClassD ( )

Definition at line 36 of file ExampleTemplateClass.h.

◆ ExampleTemplateClassD() [2/2]

template<unsigned int D>
IMP::example::ExampleTemplateClassD< D >::ExampleTemplateClassD ( const IMP::algebra::VectorD< D > & a,
const IMP::algebra::VectorD< D > & b )

Since it is a simple object, there is no reason to provide methods to change the data.

Definition at line 40 of file ExampleTemplateClass.h.

Member Function Documentation

◆ get_point()

template<unsigned int D>
const IMP::algebra::VectorD< D > & IMP::example::ExampleTemplateClassD< D >::get_point ( unsigned int i) const

Get one of the endpoints.

Definition at line 46 of file ExampleTemplateClass.h.


The documentation for this class was generated from the following file: