annotate OrthancFramework/Sources/MallocMemoryBuffer.h @ 4870:43e613a7756b

upgrade to year 2022
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 11 Jan 2022 11:15:42 +0100
parents 7053502fbf97
children c1b19f95e166 89f7d29a38c4
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
4484
64f06e7d5fc7 new abstraction IMemoryBuffer to avoid unnecessary copies of std::string buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1 /**
64f06e7d5fc7 new abstraction IMemoryBuffer to avoid unnecessary copies of std::string buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2 * Orthanc - A Lightweight, RESTful DICOM Store
64f06e7d5fc7 new abstraction IMemoryBuffer to avoid unnecessary copies of std::string buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
64f06e7d5fc7 new abstraction IMemoryBuffer to avoid unnecessary copies of std::string buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
4 * Department, University Hospital of Liege, Belgium
4870
43e613a7756b upgrade to year 2022
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4831
diff changeset
5 * Copyright (C) 2017-2022 Osimis S.A., Belgium
43e613a7756b upgrade to year 2022
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4831
diff changeset
6 * Copyright (C) 2021-2022 Sebastien Jodogne, ICTEAM UCLouvain, Belgium
4484
64f06e7d5fc7 new abstraction IMemoryBuffer to avoid unnecessary copies of std::string buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
7 *
64f06e7d5fc7 new abstraction IMemoryBuffer to avoid unnecessary copies of std::string buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
8 * This program is free software: you can redistribute it and/or
64f06e7d5fc7 new abstraction IMemoryBuffer to avoid unnecessary copies of std::string buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
9 * modify it under the terms of the GNU Lesser General Public License
64f06e7d5fc7 new abstraction IMemoryBuffer to avoid unnecessary copies of std::string buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
10 * as published by the Free Software Foundation, either version 3 of
64f06e7d5fc7 new abstraction IMemoryBuffer to avoid unnecessary copies of std::string buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
11 * the License, or (at your option) any later version.
64f06e7d5fc7 new abstraction IMemoryBuffer to avoid unnecessary copies of std::string buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
12 *
64f06e7d5fc7 new abstraction IMemoryBuffer to avoid unnecessary copies of std::string buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
13 * This program is distributed in the hope that it will be useful, but
64f06e7d5fc7 new abstraction IMemoryBuffer to avoid unnecessary copies of std::string buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
64f06e7d5fc7 new abstraction IMemoryBuffer to avoid unnecessary copies of std::string buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
64f06e7d5fc7 new abstraction IMemoryBuffer to avoid unnecessary copies of std::string buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
16 * Lesser General Public License for more details.
64f06e7d5fc7 new abstraction IMemoryBuffer to avoid unnecessary copies of std::string buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
17 *
64f06e7d5fc7 new abstraction IMemoryBuffer to avoid unnecessary copies of std::string buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
18 * You should have received a copy of the GNU Lesser General Public
64f06e7d5fc7 new abstraction IMemoryBuffer to avoid unnecessary copies of std::string buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
19 * License along with this program. If not, see
64f06e7d5fc7 new abstraction IMemoryBuffer to avoid unnecessary copies of std::string buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
20 * <http://www.gnu.org/licenses/>.
64f06e7d5fc7 new abstraction IMemoryBuffer to avoid unnecessary copies of std::string buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
21 **/
64f06e7d5fc7 new abstraction IMemoryBuffer to avoid unnecessary copies of std::string buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
22
64f06e7d5fc7 new abstraction IMemoryBuffer to avoid unnecessary copies of std::string buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
23
64f06e7d5fc7 new abstraction IMemoryBuffer to avoid unnecessary copies of std::string buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
24 #pragma once
64f06e7d5fc7 new abstraction IMemoryBuffer to avoid unnecessary copies of std::string buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
25
64f06e7d5fc7 new abstraction IMemoryBuffer to avoid unnecessary copies of std::string buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
26 #include "IMemoryBuffer.h"
64f06e7d5fc7 new abstraction IMemoryBuffer to avoid unnecessary copies of std::string buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
27 #include "Compatibility.h"
64f06e7d5fc7 new abstraction IMemoryBuffer to avoid unnecessary copies of std::string buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
28
64f06e7d5fc7 new abstraction IMemoryBuffer to avoid unnecessary copies of std::string buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
29
64f06e7d5fc7 new abstraction IMemoryBuffer to avoid unnecessary copies of std::string buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
30 namespace Orthanc
64f06e7d5fc7 new abstraction IMemoryBuffer to avoid unnecessary copies of std::string buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
31 {
64f06e7d5fc7 new abstraction IMemoryBuffer to avoid unnecessary copies of std::string buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
32 class MallocMemoryBuffer : public IMemoryBuffer
64f06e7d5fc7 new abstraction IMemoryBuffer to avoid unnecessary copies of std::string buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
33 {
64f06e7d5fc7 new abstraction IMemoryBuffer to avoid unnecessary copies of std::string buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
34 public:
64f06e7d5fc7 new abstraction IMemoryBuffer to avoid unnecessary copies of std::string buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
35 typedef void (*FreeFunction) (void* buffer);
64f06e7d5fc7 new abstraction IMemoryBuffer to avoid unnecessary copies of std::string buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
36
64f06e7d5fc7 new abstraction IMemoryBuffer to avoid unnecessary copies of std::string buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
37 private:
64f06e7d5fc7 new abstraction IMemoryBuffer to avoid unnecessary copies of std::string buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
38 void* buffer_;
64f06e7d5fc7 new abstraction IMemoryBuffer to avoid unnecessary copies of std::string buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
39 size_t size_;
64f06e7d5fc7 new abstraction IMemoryBuffer to avoid unnecessary copies of std::string buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
40 FreeFunction free_;
64f06e7d5fc7 new abstraction IMemoryBuffer to avoid unnecessary copies of std::string buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
41
64f06e7d5fc7 new abstraction IMemoryBuffer to avoid unnecessary copies of std::string buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
42 public:
64f06e7d5fc7 new abstraction IMemoryBuffer to avoid unnecessary copies of std::string buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
43 MallocMemoryBuffer();
64f06e7d5fc7 new abstraction IMemoryBuffer to avoid unnecessary copies of std::string buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
44
64f06e7d5fc7 new abstraction IMemoryBuffer to avoid unnecessary copies of std::string buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
45 virtual ~MallocMemoryBuffer()
64f06e7d5fc7 new abstraction IMemoryBuffer to avoid unnecessary copies of std::string buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
46 {
64f06e7d5fc7 new abstraction IMemoryBuffer to avoid unnecessary copies of std::string buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
47 Clear();
64f06e7d5fc7 new abstraction IMemoryBuffer to avoid unnecessary copies of std::string buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
48 }
64f06e7d5fc7 new abstraction IMemoryBuffer to avoid unnecessary copies of std::string buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
49
64f06e7d5fc7 new abstraction IMemoryBuffer to avoid unnecessary copies of std::string buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
50 void Clear();
64f06e7d5fc7 new abstraction IMemoryBuffer to avoid unnecessary copies of std::string buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
51
64f06e7d5fc7 new abstraction IMemoryBuffer to avoid unnecessary copies of std::string buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
52 void Assign(void* buffer,
64f06e7d5fc7 new abstraction IMemoryBuffer to avoid unnecessary copies of std::string buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
53 size_t size,
64f06e7d5fc7 new abstraction IMemoryBuffer to avoid unnecessary copies of std::string buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
54 FreeFunction freeFunction);
64f06e7d5fc7 new abstraction IMemoryBuffer to avoid unnecessary copies of std::string buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
55
64f06e7d5fc7 new abstraction IMemoryBuffer to avoid unnecessary copies of std::string buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
56 virtual void MoveToString(std::string& target) ORTHANC_OVERRIDE;
64f06e7d5fc7 new abstraction IMemoryBuffer to avoid unnecessary copies of std::string buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
57
64f06e7d5fc7 new abstraction IMemoryBuffer to avoid unnecessary copies of std::string buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
58 virtual const void* GetData() const ORTHANC_OVERRIDE
64f06e7d5fc7 new abstraction IMemoryBuffer to avoid unnecessary copies of std::string buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
59 {
64f06e7d5fc7 new abstraction IMemoryBuffer to avoid unnecessary copies of std::string buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
60 return buffer_;
64f06e7d5fc7 new abstraction IMemoryBuffer to avoid unnecessary copies of std::string buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
61 }
64f06e7d5fc7 new abstraction IMemoryBuffer to avoid unnecessary copies of std::string buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
62
64f06e7d5fc7 new abstraction IMemoryBuffer to avoid unnecessary copies of std::string buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
63 virtual size_t GetSize() const ORTHANC_OVERRIDE
64f06e7d5fc7 new abstraction IMemoryBuffer to avoid unnecessary copies of std::string buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
64 {
64f06e7d5fc7 new abstraction IMemoryBuffer to avoid unnecessary copies of std::string buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
65 return size_;
64f06e7d5fc7 new abstraction IMemoryBuffer to avoid unnecessary copies of std::string buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
66 }
64f06e7d5fc7 new abstraction IMemoryBuffer to avoid unnecessary copies of std::string buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
67 };
64f06e7d5fc7 new abstraction IMemoryBuffer to avoid unnecessary copies of std::string buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
68 }