casacore
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: aips2-request@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//# $Id: CountedPtr.h 21469 2014-08-12 11:25:55Z gervandiepen $
27
28#ifndef CASA_ALIGNMEMORY_H
29#define CASA_ALIGNMEMORY_H
30
31#include <casacore/casa/aips.h>
32#include <stddef.h>
33
34
35namespace casacore { //#Begin casa namespace
36
37// <summary>Referenced counted pointer for constant data</summary>
38// <use visibility=export>
39// <reviewed reviewer="Friso Olnon" date="1995/03/15" tests="tCountedPtr" demos="">
40
41// <etymology>
42// This class is <em>Counted</em> because it is reference counted.
43// </etymology>
44
45// <synopsis>
46// This class implements a reference counting mechanism. It
47// allows <src>CountedPtr</src>s to be passed around freely,
48// incrementing or decrementing the reference count as needed when one
49// <src>CountedPtr</src> is assigned to another. When the
50// reference count reaches zero the internal storage is deleted by
51// default, but this behavior can be overridden.
52//
53// Internally the class uses std::shared_ptr to be thread-safe. Note that
54// tr1 is used if the compiler does not support C++11 yet.
55// </synopsis>
56
57// <motivation>
58// Reference counting
59// </motivation>
60
62 {
63
64 public:
65 // Default alignment is none.
68 {}
69
70 // Get the alignment.
72 { return itsAlign; }
73
74 // Allocate the given amount of memory with the correct alignment.
75 // If alignment < sizeof(void*), malloc will be used, otherwise posix_memalign.
76 // The alignment must be a power of 2 for posix_memalign to succeed.
77 // It can be freed with the normal free.
78 void* alloc (size_t size) const;
79
80 private:
82 };
83
84} //#End casa namespace
85
86#endif
AlignMemory(uInt alignment=0)
Default alignment is none.
Definition: AlignMemory.h:66
uInt alignment() const
Get the alignment.
Definition: AlignMemory.h:71
void * alloc(size_t size) const
Allocate the given amount of memory with the correct alignment.
this file contains all the compiler specific defines
Definition: mainpage.dox:28
unsigned int uInt
Definition: aipstype.h:51