include/utilities/types.h
author Aravindakshan Babu <akshan@stanford.edu>
Thu, 08 Jul 2010 23:50:39 -0700
branchdev
changeset 217 64a272a34cb2
parent 125 0a2c2283e4a8
permissions -rw-r--r--
Added extra functionality to Point class( an iterator ) and PersistenceDiagram( dimension property and __len__ func ). persistence-diagram.h: Added a new read-only dimension member and member function to access it. With a new constructor that that takes in an int type to initialize dimension. persistence-diagram.cpp: Added new bp::init constructor. Takes in an integer type to initialize the dimension. Exposed the dimension property. Exposed the size property via a __len__ method. __init__.py: Added an iterator for Point objects. This iterates over the coords and then the data( if present ).

#ifndef __TYPES_H__
#define __TYPES_H__

#include <limits>
#include <iostream>

/* Types */
typedef 	bool					Sign;
typedef		short int		        Dimension;
const 		Sign	 				POS = true;
const 		Sign					NEG = false;
typedef		double					RealType;
typedef		unsigned int			SizeType;

static RealType Infinity = std::numeric_limits<RealType>::infinity();

typedef 	const unsigned int&		version_type;

// Empty is made a template so that we don't have to compile and deal with a library
// solely for its operator<<(out, e) function
template<typename T = void>
struct      Empty                   {};


struct      use_default             {};

template<class T, class Default>
struct      if_default
{ typedef   T           type; };

template<class Default>
struct      if_default<use_default, Default>
{ typedef   Default     type; };


template<typename T>
std::ostream& operator<<(std::ostream& out, Empty<T> e) { return out; }

enum        SwitchType
{
            DiffDim     = 0,
            Case1       = 0x4,
            Case12      = 0x5,
            Case112     = 0x6,
            Case2       = 0x8,
            Case212     = 0x9,
            Case3       = 0x10,
            Case31      = 0x11,
            Case4       = 0x20,
};

// Nothing to do for serializing Empty, but still need to provide this function
namespace boost {
namespace serialization {

template<class Archive, class T>
void serialize(Archive & ar, Empty<T>&, const unsigned int )
{}

} // namespace serialization
} // namespace boost

#endif // __TYPES_H__