mapgd  0.4
A program for the Maximum-likelihood analysis of population genomic data.
 All Data Structures Functions Variables Friends Groups Pages
constants.h
1 #ifndef CONSTANTS_H_
2 #define CONSTANTS_H_
3 
4 #include "typedef.h"
5 
6 template <class R, class T>
7 class Constants{
8 private:
9  size_t _size;
10  void (**cfn) (Constants <R, T> &, const T &);
11 public:
12  R* c;
13  Constants(const size_t &size, void (**fn) (Constants <R, T> &, const T &) )
14  {
15  _size=size;
16  c=(R *) calloc( size, sizeof(R) );
17  cfn=(void (**) (Constants <R, T> &,const T &)) calloc( size, sizeof( cfn ));
18  memcpy(cfn, fn, sizeof( cfn )*_size);
19  }
20  ~Constants(void)
21  {
22  free(c);
23  free(cfn);
24  }
25  void recalculate(const T &t)
26  {
27  for (int x=0; x<_size; x++) (*cfn[x])(*this, t);
28  }
29 };
30 #endif
Definition: constants.h:7