serializer_base.h Source File

CPP API: serializer_base.h Source File
serializer_base.h
Go to the documentation of this file.
1 /*
2 * Copyright (C) 2020-2026 MEmilio
3 *
4 * Authors: Daniel Abele
5 *
6 * Contact: Martin J. Kuehn <Martin.Kuehn@DLR.de>
7 *
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
11 *
12 * http://www.apache.org/licenses/LICENSE-2.0
13 *
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
19 */
20 #ifndef MIO_IO_SERIALIZER_BASE_H
21 #define MIO_IO_SERIALIZER_BASE_H
22 
23 #include "memilio/io/io.h"
24 #include <memory>
25 
26 namespace mio
27 {
28 
35 {
36 public:
40  SerializerBase(std::shared_ptr<IOStatus> status, int flags)
41  : m_status(status)
42  , m_flags(flags)
43  {
44  assert(status && "Status must not be null.");
45  }
46 
51  int flags() const
52  {
53  return m_flags;
54  }
55 
60  void set_flags(int f)
61  {
62  m_flags = f;
63  }
64 
69  const IOStatus& status() const
70  {
71  return *m_status;
72  }
73 
77  void set_error(const IOStatus& status)
78  {
79  if (*m_status) {
80  *m_status = status;
81  }
82  }
83 
84 protected:
85  std::shared_ptr<IOStatus> m_status;
86  int m_flags;
87 };
88 
89 } // namespace mio
90 
91 #endif
IOStatus represents the result of an operation.
Definition: io.h:197
Base class for implementations of serialization framework concepts.
Definition: serializer_base.h:35
const IOStatus & status() const
The current status of serialization.
Definition: serializer_base.h:69
SerializerBase(std::shared_ptr< IOStatus > status, int flags)
Constructor that sets status and flags.
Definition: serializer_base.h:40
int m_flags
Definition: serializer_base.h:86
void set_error(const IOStatus &status)
Set the current status of serialization.
Definition: serializer_base.h:77
int flags() const
Flags that determine the behavior of serialization.
Definition: serializer_base.h:51
void set_flags(int f)
Set flags that determine the behavior of serialization.
Definition: serializer_base.h:60
std::shared_ptr< IOStatus > m_status
Definition: serializer_base.h:85
A collection of classes to simplify handling of matrix shapes in meta programming.
Definition: models/abm/analyze_result.h:30