-
Notifications
You must be signed in to change notification settings - Fork 0
/
UserClasses.h
97 lines (83 loc) · 2.58 KB
/
UserClasses.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
/*
* UserClasses.h
* This file is part of Generic Runtime Support for Parallel Divide and Conquer
*
* Copyright (C) 2010 - Lorenzo Anardu, Emanuele Vespa
*
* Generic Runtime Support for Parallel Divide and Conquer is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* Generic Runtime Support for Parallel Divide and Conquer is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Generic Runtime Support for Parallel Divide and Conquer; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301 USA
*/
#include <cstdlib>
#include <vector>
#ifndef DAC_USER_CLASSES
#define DAC_USER_CLASSES
namespace dac {
template <class T>
struct Chunk
{
unsigned size; //expressed in number of elements of the buffer
T* buf;
Chunk() {
size = 0;
buf = NULL;
}
virtual ~Chunk() {
size = 0;
}
};
/*******************************************
* abstract class for divider
*******************************************/
template <class D>
class Divide
{
public:
virtual std::vector<Chunk<D> > divide(Chunk<D> &chunk) = 0;
};
/*******************************************
* abstract class for combiner
*******************************************/
template <class C>
class Combine
{
public:
virtual Chunk<C> combine(std::vector<Chunk<C> > chunks) = 0;
};
/*******************************************
* abstract class for base case handler
*******************************************/
template <class D, class C=D>
class BaseCase
{
public:
virtual bool isBaseCase(Chunk<D>) = 0;
virtual Chunk<C> baseSolve(Chunk<D>) = 0;
};
//template <class T>
class SerializableData {
public:
SerializableData() {}
virtual ~SerializableData() {}
/* returns the size of the serialized class, expressed in bytes */
virtual int getSize() = 0;
/* buffer is already allocated into serialize method
* bufSize returns the size of buffer expressed in bytes*/
virtual bool serialize(void* buffer, int bufSize) = 0;
/* buffer is already allocated into deSerialize method
* bufSize represents the size of buffer expressed in bytes*/
virtual bool deSerialize(void* buffer, int bufSize) = 0;
};
}
#endif