111 lines
1.8 KiB
C++
Executable File
111 lines
1.8 KiB
C++
Executable File
|
|
|
|
|
|
#pragma once
|
|
|
|
#include <map>
|
|
#include <functional>
|
|
#include <memory>
|
|
|
|
namespace LtsSession
|
|
{
|
|
class LtsSessionDataDds;
|
|
}
|
|
|
|
namespace OperatorManagement
|
|
{
|
|
namespace Interface
|
|
{
|
|
class Dtc;
|
|
}
|
|
}
|
|
|
|
namespace ExerciseManagement
|
|
{
|
|
namespace Interface
|
|
{
|
|
class Dtc;
|
|
}
|
|
}
|
|
|
|
namespace InfrastructureManagement
|
|
{
|
|
namespace Interface
|
|
{
|
|
class Dtc;
|
|
}
|
|
}
|
|
|
|
namespace AudioVideoManagement
|
|
{
|
|
|
|
namespace Interface
|
|
{
|
|
class Dtc;
|
|
class Ftc;
|
|
}
|
|
|
|
class StreamNameMapping;
|
|
|
|
|
|
|
|
class AvmExerciseContextManager
|
|
{
|
|
public:
|
|
struct ExerciseContext;
|
|
|
|
~AvmExerciseContextManager();
|
|
|
|
|
|
|
|
|
|
ExerciseContext *acquire(int exerciseId, LtsSession::LtsSessionDataDds *session);
|
|
void release(int exerciseId, ExerciseContext *composite);
|
|
|
|
|
|
private:
|
|
|
|
|
|
struct RefCountedContext
|
|
{
|
|
explicit RefCountedContext(std::unique_ptr<ExerciseContext> &&context);
|
|
RefCountedContext(RefCountedContext &&) noexcept;
|
|
~RefCountedContext();
|
|
|
|
int refCount{1};
|
|
std::unique_ptr<ExerciseContext> context;
|
|
};
|
|
|
|
using ExerciseId = int;
|
|
std::map<ExerciseId, RefCountedContext> m_activeContexts;
|
|
};
|
|
|
|
|
|
|
|
|
|
class AvmExerciseContextHandle
|
|
{
|
|
public:
|
|
AvmExerciseContextHandle();
|
|
AvmExerciseContextHandle(AvmExerciseContextManager *context, int exerciseId, LtsSession::LtsSessionDataDds *session);
|
|
|
|
operator bool() const { return m_context.get(); }
|
|
|
|
|
|
StreamNameMapping *streamNameMapping() const;
|
|
|
|
const std::shared_ptr<Interface::Dtc> &dtc() const;
|
|
const std::shared_ptr<Interface::Ftc> &ftc() const;
|
|
|
|
OperatorManagement::Interface::Dtc *opmDtc() const;
|
|
ExerciseManagement::Interface::Dtc *exmDtc() const;
|
|
InfrastructureManagement::Interface::Dtc *ismDtc() const;
|
|
|
|
|
|
private:
|
|
using Releaser = std::function<void (AvmExerciseContextManager::ExerciseContext *)>;
|
|
std::unique_ptr<AvmExerciseContextManager::ExerciseContext, Releaser> m_context;
|
|
};
|
|
|
|
}
|