casacore
Loading...
Searching...
No Matches
casa
Utilities
AlignMemory.h
Go to the documentation of this file.
1
//# AlignMemory.h: Class to specify and calculate memory alignment
2
//# Copyright (C) 2014
3
//# Associated Universities, Inc. Washington DC, USA.
4
//#
5
//# This library is free software; you can redistribute it and/or modify it
6
//# under the terms of the GNU Library General Public License as published by
7
//# the Free Software Foundation; either version 2 of the License, or (at your
8
//# option) any later version.
9
//#
10
//# This library is distributed in the hope that it will be useful, but WITHOUT
11
//# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12
//# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
13
//# License for more details.
14
//#
15
//# You should have received a copy of the GNU Library General Public License
16
//# along with this library; if not, write to the Free Software Foundation,
17
//# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
18
//#
19
//# Correspondence concerning AIPS++ should be addressed as follows:
20
//# Internet email: casa-feedback@nrao.edu.
21
//# Postal address: AIPS++ Project Office
22
//# National Radio Astronomy Observatory
23
//# 520 Edgemont Road
24
//# Charlottesville, VA 22903-2475 USA
25
26
#ifndef CASA_ALIGNMEMORY_H
27
#define CASA_ALIGNMEMORY_H
28
29
#include <casacore/casa/aips.h>
30
#include <stddef.h>
31
32
33
namespace
casacore
{
//#Begin casa namespace
34
35
// <summary>Referenced counted pointer for constant data</summary>
36
// <use visibility=export>
37
// <reviewed reviewer="Friso Olnon" date="1995/03/15" tests="tCountedPtr" demos="">
38
39
// <etymology>
40
// This class is <em>Counted</em> because it is reference counted.
41
// </etymology>
42
43
// <synopsis>
44
// This class implements a reference counting mechanism. It
45
// allows <src>CountedPtr</src>s to be passed around freely,
46
// incrementing or decrementing the reference count as needed when one
47
// <src>CountedPtr</src> is assigned to another. When the
48
// reference count reaches zero the internal storage is deleted by
49
// default, but this behavior can be overridden.
50
//
51
// Internally the class uses std::shared_ptr to be thread-safe. Note that
52
// tr1 is used if the compiler does not support C++11 yet.
53
// </synopsis>
54
55
// <motivation>
56
// Reference counting
57
// </motivation>
58
59
class
AlignMemory
60
{
61
62
public
:
63
// Default alignment is none.
64
explicit
AlignMemory
(
uInt
alignment
=0)
65
:
itsAlign
(
alignment
)
66
{}
67
68
// Get the alignment.
69
uInt
alignment
()
const
70
{
return
itsAlign
; }
71
72
// Allocate the given amount of memory with the correct alignment.
73
// If alignment < sizeof(void*), malloc will be used, otherwise posix_memalign.
74
// The alignment must be a power of 2 for posix_memalign to succeed.
75
// It can be freed with the normal free.
76
void
*
alloc
(
size_t
size)
const
;
77
78
private
:
79
uInt
itsAlign
;
80
};
81
82
}
//#End casa namespace
83
84
#endif
casacore::AlignMemory
Definition
AlignMemory.h:60
casacore::AlignMemory::AlignMemory
AlignMemory(uInt alignment=0)
Default alignment is none.
Definition
AlignMemory.h:64
casacore::AlignMemory::alignment
uInt alignment() const
Get the alignment.
Definition
AlignMemory.h:69
casacore::AlignMemory::alloc
void * alloc(size_t size) const
Allocate the given amount of memory with the correct alignment.
casacore::AlignMemory::itsAlign
uInt itsAlign
Definition
AlignMemory.h:79
casacore
this file contains all the compiler specific defines
Definition
mainpage.dox:28
casacore::uInt
unsigned int uInt
Definition
aipstype.h:49
Generated by
1.9.8