Alien  1.3.0
Developer documentation
Loading...
Searching...
No Matches
TimestampMng.cc
1/*
2 * Copyright 2020 IFPEN-CEA
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 *
16 * SPDX-License-Identifier: Apache-2.0
17 */
18
19#include "TimestampMng.h"
20
21#include <alien/utils/Trace.h>
22
23#include "ITimestampObserver.h"
24#include "Timestamp.h"
25
26/*---------------------------------------------------------------------------*/
27/*---------------------------------------------------------------------------*/
28
29namespace Alien
30{
31
32using namespace Arccore;
33
34/*---------------------------------------------------------------------------*/
35/*---------------------------------------------------------------------------*/
36
37TimestampMng::TimestampMng()
38: m_timestamp(0)
39{}
40
41/*---------------------------------------------------------------------------*/
42
43TimestampMng::TimestampMng(const TimestampMng& tm)
44: m_timestamp(tm.m_timestamp)
45{}
46
47/*---------------------------------------------------------------------------*/
48
50{
51 return m_timestamp;
52}
53
54/*---------------------------------------------------------------------------*/
55
57{
58 alien_debug([&] {
59 cout() << "Udpate Timestamp " << ts << " (" << m_observers.size()
60 << " Observers) by TimestampMng " << this;
61 });
62
63 ts->setTimestamp(this, ++m_timestamp);
64
65 for (auto& o : m_observers)
66 o->updateTimestamp();
67}
68
69/*---------------------------------------------------------------------------*/
70
71void TimestampMng::addObserver(std::shared_ptr<ITimestampObserver> observer)
72{
73 alien_debug([&] {
74 cout() << "Add Timestamp Observer " << observer.get() << " to TimestampMng " << this;
75 });
76
77 m_observers.add(observer);
78}
79
80/*---------------------------------------------------------------------------*/
81
82void TimestampMng::clearObservers()
83{
84 m_observers.clear();
85}
86
87/*---------------------------------------------------------------------------*/
88/*---------------------------------------------------------------------------*/
89
90} // namespace Alien
91
92/*---------------------------------------------------------------------------*/
93/*---------------------------------------------------------------------------*/
Int64 timestamp() const
Valeur du timestamp de référence.
void updateTimestamp(Timestamp *ts) const
Requête de mise à jour d'un Timestamp.
-- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature --
Definition BackEnd.h:17