FastArduino  v1.9 alpha
C++ library to build fast but small Arduino/AVR projects
lifecycle.cpp
1 // Copyright 2016-2022 Jean-Francois Poilpret
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 #include "lifecycle.h"
16 
17 namespace lifecycle
18 {
20  AbstractLifeCycle::AbstractLifeCycle(AbstractLifeCycle&& that)
21  {
22  if (that.id_)
23  that.manager()->move_(that.id_, *this);
24  }
25  AbstractLifeCycle::~AbstractLifeCycle()
26  {
27  if (id_)
28  manager()->unregister_(id_);
29  }
30  AbstractLifeCycle& AbstractLifeCycle::operator=(AbstractLifeCycle&& that)
31  {
32  if (id_)
33  manager()->unregister_(id_);
34  if (that.id_)
35  that.manager()->move_(that.id_, *this);
36  return *this;
37  }
39 }
The abstract base class of all LifeCycle<T>.
Definition: lifecycle.h:68
AbstractLifeCycleManager * manager() const
A pointer to the AbstractLifeCycleManager handling this instance.
Definition: lifecycle.h:112
bool unregister_(uint8_t id)
Unregisters a LifeCycle<T> instance, identified by id, already registered with this LifeCycleManager.
Definition: lifecycle.h:178
Utility API to handle lifecycle of objects so that:
Contains the API around LifeCycle management implementation.
Definition: lifecycle.cpp:18