9 #ifndef IMPKERNEL_ARRAY_H 
   10 #define IMPKERNEL_ARRAY_H 
   12 #include <IMP/kernel_config.h> 
   19 #include <type_traits> 
   20 #include <cereal/access.hpp> 
   21 #include <cereal/types/array.hpp> 
   23 IMPKERNEL_BEGIN_NAMESPACE
 
   39 template <
unsigned int D, 
class Data, 
class SwigData = Data>
 
   41   typedef std::array<Data, D> Storage;
 
   44   friend class cereal::access;
 
   45   template<
class Archive> 
void serialize(Archive &ar) {
 
   50     for (
unsigned int i = 0; i < D; ++i) {
 
   53       else if (d_[i] > o.get(i))
 
   61   typedef SwigData value_type;
 
   63   unsigned int get_dimension() {
 
   68   template<int DT=D, typename std::enable_if<DT == 2>::type* = 
nullptr>
 
   69   Array(SwigData x, SwigData y) {
 
   74   template<int DT=D, typename std::enable_if<DT == 3>::type* = 
nullptr>
 
   75   Array(SwigData x, SwigData y, SwigData z) {
 
   81   template<int DT=D, typename std::enable_if<DT == 4>::type* = 
nullptr>
 
   82   Array(SwigData x0, SwigData x1, SwigData x2, SwigData x3) {
 
   89   SwigData 
get(
unsigned int i) 
const { 
return d_[i]; }
 
   92                       for (
unsigned int i = 0; i < D; ++i) {
 
   93                              boost::hash_combine(seed, d_[i]);
 
   97   const Data operator[](
unsigned int i)
 const {
 
  101   Data& operator[](
unsigned int i) {
 
  106   void set_item(
unsigned int i, SwigData v)
 const {
 
  113   SwigData __getitem__(
unsigned int i)
 const {
 
  115     return operator[](i);
 
  117   unsigned int __len__()
 const { 
return D; }
 
  120   unsigned int size()
 const { 
return D; }
 
  122   std::string get_name()
 const {
 
  123     std::ostringstream oss;
 
  125     for (
unsigned int i = 0; i < D; ++i) {
 
  135   typedef typename Storage::iterator iterator;
 
  136   iterator begin() { 
return d_.begin(); }
 
  137   iterator end() { 
return d_.end(); }
 
  138   typedef typename Storage::const_iterator const_iterator;
 
  139   const_iterator begin()
 const { 
return d_.begin(); }
 
  140   const_iterator end()
 const { 
return d_.end(); }
 
  150   const Data* data()
 const {
 
  159 #if !defined(IMP_DOXYGEN) && !defined(SWIG) 
  160 template <
unsigned int D, 
class Data, 
class SwigData>
 
  166 IMPKERNEL_END_NAMESPACE
 
  170   template <
unsigned int I, 
unsigned int D, 
class Data, 
class SwigData>
 
  172     static_assert(I < D, 
"array index is within bounds");
 
  173     return *(arr.begin() + I);
 
  176   template <
unsigned int I, 
unsigned int D, 
class Data, 
class SwigData>
 
  178     static_assert(I < D, 
"array index is within bounds");
 
  179     return *(arr.begin() + I);
 
#define IMP_SHOWABLE_INLINE(Name, how_to_show)
Declare the methods needed by an object that can be printed. 
 
Helper macros for implementing comparisons of IMP objects. 
 
A class to store a fixed array of same-typed values. 
 
#define IMP_HASHABLE_INLINE(name, hashret)
 
#define IMP_COMPARISONS(Name)
Implement comparison in a class using a compare function. 
 
Base class for a simple primitive-like type. 
 
int compare(const VectorD< D > &a, const VectorD< D > &b)
lexicographic comparison of two vectors 
 
Helper macros for implementing hashable classes. 
 
An exception for a request for an invalid member of a container. 
 
#define IMP_THROW(message, exception_name)
Throw an exception with a message. 
 
Helper macros for throwing and handling exceptions. 
 
Base class for a simple primitive-like type. 
 
#define IMP_USAGE_CHECK(expr, message)
A runtime test for incorrect usage of a class or method. 
 
Macros to help with objects that can be printed to a stream.