Skip to main content

doubly-list-links.cpp File

C++ source file with the implementations for the µOS++ doubly linked list link node classes. More...

Included Headers

Namespaces Index

namespacemicro_os_plus

The primary namespace for the µOS++ framework. More...

namespaceutils

The µOS++ utilities definitions. More...

Description

C++ source file with the implementations for the µOS++ doubly linked list link node classes.

The doubly-list-links.cpp source file contains the C++ implementations of the non-inline methods for the doubly_list_links_base and static_doubly_list_links classes, providing an efficient and lightweight linked list management system tailored for embedded applications.

The class definitions are in the doubly-list-links.h file.

File Listing

The file content with the documentation metadata removed is:

1/*
2 * This file is part of the µOS++ project (https://micro-os-plus.github.io/).
3 * Copyright (c) 2016-2026 Liviu Ionescu. All rights reserved.
4 *
5 * Permission to use, copy, modify, and/or distribute this software for any
6 * purpose is hereby granted, under the terms of the MIT license.
7 *
8 * If a copy of the license was not distributed with this file, it can be
9 * obtained from https://opensource.org/licenses/mit.
10 */
11
25
26// ----------------------------------------------------------------------------
27
29
30// ----------------------------------------------------------------------------
31
32#if defined(MICRO_OS_PLUS_UTILS_LISTS_ENABLED)
33
34// ----------------------------------------------------------------------------
35
36#if defined(__GNUC__)
37#pragma GCC diagnostic ignored "-Waggregate-return"
38#if defined(__clang__)
39#pragma clang diagnostic ignored "-Wc++98-compat"
40#endif // defined(__clang__)
41#endif // defined(__GNUC__)
42
44{
45 // ==========================================================================
46
55 bool
57 {
58 if (previous_ == nullptr || next_ == nullptr)
59 {
60 assert (previous_ == nullptr);
61 assert (next_ == nullptr);
62 return false;
63 }
64 return true;
65 }
66
80 bool
82 {
83 if (!initialised ())
84 {
85 initialise ();
86 return true;
87 }
88 return false;
89 }
90
100 void
102 {
103#if defined(MICRO_OS_PLUS_UTILS_LISTS_TRACE_ENABLED)
104 trace::printf ("%s() link %p after %p\n", __func__,
105 static_cast<const void*> (node),
106 static_cast<const void*> (this));
107#endif // defined(MICRO_OS_PLUS_UTILS_LISTS_TRACE_ENABLED)
108 assert (next_ != nullptr);
109 assert (next_->previous_ != nullptr);
110
111 // Make the new node point to its new neighbours.
112 node->previous_ = this;
113 node->next_ = next_;
114
115 next_->previous_ = node;
116 next_ = node;
117 }
118
128 void
130 {
131#if defined(MICRO_OS_PLUS_UTILS_LISTS_TRACE_ENABLED)
132 trace::printf ("%s() link %p before %p\n", __func__,
133 static_cast<const void*> (node),
134 static_cast<const void*> (this));
135#endif // defined(MICRO_OS_PLUS_UTILS_LISTS_TRACE_ENABLED)
136 assert (previous_ != nullptr);
137 assert (previous_->next_ != nullptr);
138
139 // Make the new node point to its new neighbours.
140 node->next_ = this;
141 node->previous_ = previous_;
142
143 previous_->next_ = node;
144 previous_ = node;
145 }
146
154 void
156 {
157#if defined(MICRO_OS_PLUS_UTILS_LISTS_TRACE_ENABLED)
158 trace::printf ("%s() %p \n", __func__, static_cast<const void*> (this));
159#endif // defined(MICRO_OS_PLUS_UTILS_LISTS_TRACE_ENABLED)
160 assert (previous_ != nullptr);
161 assert (next_ != nullptr);
162
163 // Make neighbours point to each other.
164 // This works even if the node is already unlinked,
165 // so no need for an extra test.
166 previous_->next_ = next_;
167 next_->previous_ = previous_;
168
169 // Reset the unlinked node to the initial state,
170 // with both pointers pointing to itself.
171 initialise ();
172 }
173
174 // ==========================================================================
175} // namespace micro_os_plus::utils
176
177// ----------------------------------------------------------------------------
178
179#endif // defined(MICRO_OS_PLUS_UTILS_LISTS_ENABLED)
180
181// ----------------------------------------------------------------------------

Generated via doxygen2docusaurus 2.2.2 by Doxygen 1.17.0.