Basic objects
The definition of a vector, grid, or graph, define how your data is organized, but does not define what is storing. For example a vector can store float, double, long int, or even more complex objects, same for grid, each point in the grid can store generic objects, same for Graph each vertex and edge can store generic objects. Generic object has two formats, here an example
/////////////////////////////////////
// C++ FORMAT
/////////////////////////////////////
template<typename T> class Point_orig
{
public:
T x;
T y;
T z;
T s;
T v[3];
T t[3][3];
// setter method
inline void setx(T x_) {x = x_;};
inline void sety(T y_) {y = y_;};
inline void setz(T z_) {z = z_;};
inline void sets(T s_) {s = s_;};
};
////////////////////////////////////
// OPENFPM DATA STRUCTURE FORMAT
////////////////////////////////////
template<typename T> class Point_test
{
public:
typedef boost::fusion::vector<T,T,T,T,T[3],T[3][3]> type;
typedef typename memory_traits_inte<type>::type memory_int;
typedef typename memory_traits_lin<type>::type memory_lin;
type data;
static const unsigned int x = 0;
static const unsigned int y = 1;
static const unsigned int z = 2;
static const unsigned int s = 3;
static const unsigned int v = 4;
static const unsigned int t = 5;
static const unsigned int max_prop = 6;
// Setter method
inline void setx(T x_) {boost::fusion::at_c<0>(data) = x_;};
inline void sety(T y_) {boost::fusion::at_c<1>(data) = y_;};
inline void setz(T z_) {boost::fusion::at_c<2>(data) = z_;};
inline void sets(T s_) {boost::fusion::at_c<3>(data) = s_;};
};
The two definitions are equivalent, but the second one give the possibility to analyse the members of the basic data. This can be useful when the memory representation (see below) can depend from the basic object. Other useful information for example for IO can be appended to the basic object, see OpenFPM_IO. In any case all the structures implemented in OpenFPM_data must work with both format. In case of implementing a new structure inside OpenFPM_data, consider to use already implemented structure like vector or grid that already implements the capabilities that we are going to present in the following sections. It is allowed to treat the two form in the same way but strongly discouraged, because iy will be an extremely limiting factor.