-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathSession.h
85 lines (69 loc) · 2.4 KB
/
Session.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
// All rights not expressly granted are reserved.
//
// This software is distributed under the terms of the GNU General Public
// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
//
// In applying this license CERN does not waive the privileges and immunities
// granted to it by virtue of its status as an Intergovernmental Organization
// or submit itself to any jurisdiction.
/// \file Session.h
/// \brief Definition of the Session class.
///
/// \author Kostas Alexopoulos ([email protected])
#ifndef O2_LLA_INC_SESSION_H
#define O2_LLA_INC_SESSION_H
#include "Lla/SessionParameters.h"
#include "Lla/InterprocessLockInterface.h"
#include "Lla/LockParameters.h"
#include <memory>
#include <mutex>
namespace o2
{
namespace lla
{
class Session
{
public:
#ifdef O2_LLA_BENCH_ENABLED
#pragma message("O2_LLA_BENCH_ENABLED defined")
/// Session constructor only for debugging
/// \param params The Session parameters
/// \param lockType The type of the underlying lock implementation
Session(SessionParameters& params, LockType::Type lockType);
#endif
/// Session constructor
/// \param params The Session parameters
Session(SessionParameters& params);
Session(const Session& other);
Session(Session&& other);
Session& operator=(const Session& other);
Session& operator=(Session&& other);
~Session();
/// Start a Session, within which atomic access to the card's SC interface is guaranteed
/// \return boolean; true if successful, otherwise False
bool start();
/// Start a Session, trying until the timeOut has expired
/// \param timeOut Timeout in ms after which to stop trying to start the session
/// \return boolean; true if successful, otherwise false
bool timedStart(int timeOut);
/// Stops a Session, releasing atomic access to the card's SC interface
void stop();
/// Reports on the state of the Session
/// \return boolean; true if started, false otherwise
bool isStarted();
private:
void checkAndSetParameters();
void makeLockName();
std::string mSessionName;
int mCardId;
SessionParameters mParams;
LockParameters mLockParams;
std::unique_ptr<InterprocessLockInterface> mLock;
bool mIsStarted = false;
std::mutex mMutex;
};
} // namespace lla
} // namespace o2
#endif // O2_LLA_INC_SESSION_H