blob: 89a1aa26f639e1ae7929e6c5bbe380d339533306 (
plain)
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
98
99
100
|
/***************************************************************************
dgdata.hh - description
-------------------
begin : Wed Jul 19 2000
copyright : (C) 2000 by Erik Schnetter
email : schnetter@astro.psu.edu
$Header: /home/eschnett/C/carpet/Carpet/Carpet/CarpetLib/src/Attic/dgdata.hh,v 1.2 2002/05/05 22:17:00 schnetter Exp $
***************************************************************************/
/***************************************************************************
* *
* This program 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. *
* *
***************************************************************************/
#ifndef DGDATA_HH
#define DGDATA_HH
#include <assert.h>
#include <iostream>
#include "defs.hh"
using namespace std;
// Forward declaration
class dimgeneric_data;
// Output
ostream& operator<< (ostream& os, const dimgeneric_data& d);
// A generic data storage without type information
class dimgeneric_data {
protected: // should be readonly
// Fields
bool _has_storage; // has storage associated (on some processor)
bool _owns_storage; // owns the storage
int _size; // size
int _proc; // stored on processor
public:
// Constructors
dimgeneric_data ();
// Destructors
virtual ~dimgeneric_data ();
// Processor management
virtual void change_processor (const int newproc, void* const mem=0) = 0;
// Accessors
bool has_storage () const {
return _has_storage;
}
bool owns_storage () const {
assert (_has_storage);
return _owns_storage;
}
virtual const void* storage () const = 0;
virtual void* storage () = 0;
int size () const {
assert (_has_storage);
return _size;
}
int proc () const {
assert (_has_storage);
return _proc;
}
// Output
virtual ostream& output (ostream& os) const = 0;
};
inline ostream& operator<< (ostream& os, const dimgeneric_data& d) {
return d.output(os);
}
#endif // DGDATA_HH
|