Commit ff29a689 authored by Pascal Palenda's avatar Pascal Palenda
Browse files

Introduce ITASimulationScheduler namespace - WIP

parent 2bfe3f9a
......@@ -36,10 +36,11 @@
// STL includes
#include <vector>
// Forward declarations
class R_MasterController;
namespace ITASimulationScheduler
{
// Forward declarations
class R_MasterController;
//! Raven-Instanz fr eine einfache Simulation einer Szene (blocking) (nicht thread-safe)
/**
......
......@@ -2,39 +2,44 @@
#include <assert.h>
CRavenSimulationResult::ComplexSimulationSoundPath::ComplexSimulationSoundPath()
: psfResult( NULL )
namespace ITASimulationScheduler
{
}
CRavenSimulationResult::ComplexSimulationSoundPath::ComplexSimulationSoundPath()
: psfResult(NULL)
{
CRavenSimulationResult::ComplexSimulationSoundPath::~ComplexSimulationSoundPath()
{
if( bEmpty == false )
}
CRavenSimulationResult::ComplexSimulationSoundPath::~ComplexSimulationSoundPath()
{
assert( psfResult->length() > 0 );
if (bEmpty == false)
{
assert(psfResult->length() > 0);
}
delete psfResult;
psfResult = NULL;
}
delete psfResult;
psfResult = NULL;
}
// --= Simulation Result =--
// --= Simulation Result =--
CRavenSimulationResult::CRavenSimulationResult()
{
vcspResult.clear();
}
CRavenSimulationResult::CRavenSimulationResult()
{
vcspResult.clear();
}
CRavenSimulationResult::~CRavenSimulationResult()
{
for (int i = 0; i < (int)vcspResult.size(); i++)
delete vcspResult[i];
}
CRavenSimulationResult::~CRavenSimulationResult()
{
for( int i=0; i<(int)vcspResult.size(); i++ )
delete vcspResult[i];
}
void CRavenSimulationResult::Clear()
{
for (int i = 0; i < (int)vcspResult.size(); i++)
delete vcspResult[i];
vcspResult.clear();
}
void CRavenSimulationResult::Clear()
{
for( int i=0; i<(int) vcspResult.size();i++ )
delete vcspResult[i];
vcspResult.clear();
}
\ No newline at end of file
......@@ -19,6 +19,9 @@
#define RAVENSIMULATOR_REQUIRE_SCENE { if( m_iStatus < SCENE_LOADED ) ITA_EXCEPT1( MODAL_EXCEPTION, "Loaded scene required for this method, use LoadScene() prior to this call" ); };
#define RAVENSIMULATOR_REQUIRE_FILTER_ENGINE { if( m_iStatus < FILTER_ENGINE_LOADED ) ITA_EXCEPT1( MODAL_EXCEPTION, "Loaded filter engine required for this method, probably an error in LoadScene() occured" ); };
namespace ITASimulationScheduler
{
const int g_iMaxNumSources = 1;
const int g_iMaxNumReceivers = 1;
......@@ -1579,3 +1582,5 @@ void CRavenSimulator::ResetStatistics( const bool bResetLoadSceneCount, const bo
if( bResetLoadSceneCount ) m_oProfiler.uiNumLoadScenes = 0;
if( bResetResetCount ) m_oProfiler.uiNumResets = 0;
}
}
#include <ITASimulationScheduler/Raven/RavenNetClient.h>
#include "RavenNetClientImpl.h"
IRavenNetClient* IRavenNetClient::Create()
namespace ITASimulationScheduler
{
return new CRavenNetClientImpl();
}
IRavenNetClient::IRavenNetClient() {}
IRavenNetClient::~IRavenNetClient() {}
IRavenNetClient* IRavenNetClient::Create()
{
return new CRavenNetClientImpl();
}
IRavenNetClient::IRavenNetClient() {}
IRavenNetClient::~IRavenNetClient() {}
}
\ No newline at end of file
......@@ -7,83 +7,89 @@
#include <vector>
class VistaConnectionIP;
class CRavenNetNetworkProtocol;
class VistaMutex;
class IRavenSimulationInterface;
class IRavenSimulationSchedulerInterface;
class CNetworkedRaven;
/**
* Thread-Safe implementation
*/
namespace ITASimulationScheduler
{
class CRavenNetClientImpl : public IRavenNetClient {
public:
CRavenNetClientImpl();
~CRavenNetClientImpl();
class CRavenNetNetworkProtocol;
class IRavenSimulationInterface;
class IRavenSimulationSchedulerInterface;
class CNetworkedRaven;
// Raven
/**
* Thread-Safe implementation
*/
IRavenSimulationInterface* GetRavenSimulator() const;
IRavenSimulationSchedulerInterface* GetRavenSimulationScheduler() const;
class CRavenNetClientImpl : public IRavenNetClient {
public:
CRavenNetClientImpl();
~CRavenNetClientImpl();
bool HasRavenSimulator() const;
bool HasRavenSimulationScheduler() const;
// Raven
void AttachRavenSchedulerSimulationResultHandler(IRavenSimulationSchedulerResultHandler*);
void DetachRavenSchedulerSimulationResultHandler(IRavenSimulationSchedulerResultHandler*);
IRavenSimulationInterface* GetRavenSimulator() const;
IRavenSimulationSchedulerInterface* GetRavenSimulationScheduler() const;
// Connection
bool HasRavenSimulator() const;
bool HasRavenSimulationScheduler() const;
bool IsConnected() const;
std::string GetServerAddress() const;
int Initialize(const std::string& sServerAddress, int iServerPort,
int iHeadChannelMode = RAVEN_HC_USE_EXISTING,
int IExceptionHandlingMode = EXC_CLIENT_THROW );
int Disconnect();
void AttachRavenSchedulerSimulationResultHandler(IRavenSimulationSchedulerResultHandler*);
void DetachRavenSchedulerSimulationResultHandler(IRavenSimulationSchedulerResultHandler*);
void SetExceptionHandlingMode( int nMode );
int GetExceptionhandlingMode() const;
// Connection
// Events
bool IsConnected() const;
std::string GetServerAddress() const;
int Initialize(const std::string& sServerAddress, int iServerPort,
int iHeadChannelMode = RAVEN_HC_USE_EXISTING,
int IExceptionHandlingMode = EXC_CLIENT_THROW);
int Disconnect();
void SendConnectionEvent( int nId );
void SetExceptionHandlingMode(int nMode);
int GetExceptionhandlingMode() const;
bool AttachEventHandler(IRavenNetClient::IEventHandler* pHandler);
bool DetachEventHandler(IRavenNetClient::IEventHandler* pHandler);
// Events
void ProcessNetEvent( int iEventID );
void ProcessConnectionError();
void SendConnectionEvent(int nId);
private:
void Cleanup();
bool AttachEventHandler(IRavenNetClient::IEventHandler* pHandler);
bool DetachEventHandler(IRavenNetClient::IEventHandler* pHandler);
void EmitEvent( const CEvent& oEvent );
void EmitEvent( int iID );
void ProcessNetEvent(int iEventID);
void ProcessConnectionError();
protected:
class CNetworkedRavenSimulator;
CNetworkedRavenSimulator* m_pNetworkedRavenSimulator;
private:
void Cleanup();
class CNetworkedRavenSimulationScheduler;
CNetworkedRavenSimulationScheduler* m_pNetworkedRavenSimulationScheduler;
void EmitEvent(const CEvent& oEvent);
void EmitEvent(int iID);
class CEventReceiver;
CEventReceiver* m_pEventReceiver;
protected:
class CNetworkedRavenSimulator;
CNetworkedRavenSimulator* m_pNetworkedRavenSimulator;
CRavenNetNetworkProtocol* m_pProtocol;
class CNetworkedRavenSimulationScheduler;
CNetworkedRavenSimulationScheduler* m_pNetworkedRavenSimulationScheduler;
bool m_bConnected;
bool m_bShutdownFlag;
class CEventReceiver;
CEventReceiver* m_pEventReceiver;
VistaConnectionIP* m_pCommandChannel;
VistaConnectionIP* m_pEventChannel;
VistaConnectionIP* m_pHeadChannel;
CRavenNetNetworkProtocol* m_pProtocol;
std::string m_sServerIP;
bool m_bConnected;
bool m_bShutdownFlag;
std::list<IEventHandler*> m_liEventHandlers;
VistaMutex* m_pEventChannelLock;
};
VistaConnectionIP* m_pCommandChannel;
VistaConnectionIP* m_pEventChannel;
VistaConnectionIP* m_pHeadChannel;
std::string m_sServerIP;
std::list<IEventHandler*> m_liEventHandlers;
VistaMutex* m_pEventChannelLock;
};
}
#endif // IW_RAVENNET_CLIENTIMPL
......@@ -23,84 +23,88 @@
// Forward declarations
class VistaConnectionIP;
// Messages consist of a message part and an answer part, each read or written
// separately. Messages have a three-int-header (SIZE, MSGTYPE; EXCEPTIONMODE), while
// answers have a two-int header (SIZE; ANSWERTYPE)
class CRavenNetMessage
namespace ITASimulationScheduler
{
public:
CRavenNetMessage( VistaSerializingToolset::ByteOrderSwapBehavior bSwapBuffers );
void ResetMessage();
void SetConnection( VistaConnectionIP* pConn );
void WriteMessage();
void ReadMessage();
void WriteAnswer();
void ReadAnswer();
int GetExceptionMode() const;
int GetMessageType() const;
int GetAnswerType() const;
void SetExceptionMode( int nMode );
void SetMessageType( int nType );
void SetAnswerType( int nType );
int GetIncomingMessageSize() const;
int GetOutgoingMessageSize() const;
bool GetOutgoingMessageHasData() const;
// --= Serializing functions =--
// Basics
void WriteInt( const int );
void WriteBool( const bool );
void WriteDouble( const double );
void WriteException( const ITAException& );
void WriteFloat( const float );
void WriteString( const std::string& );
void WriteIntVector(const std::vector<int> );
void WriteUInt64( const RavenNetCompat::uint64 uliValue );
void WriteRavenSimulationTask( const CRavenSimulationTask* pTask );
void WriteRavenSimulationResult( const CRavenSimulationResult* pResult );
void WriteRavenSimulationProfilerState( IRavenSimulationInterface::CProfiler* );
void WriteRavenSimulationProfilerState( IRavenSimulationSchedulerInterface::CProfiler* );
// --= Reader =--
std::string ReadString();
int ReadInt();
bool ReadBool();
ITAException ReadException();
float ReadFloat();
double ReadDouble();
std::vector<int> ReadIntVector();
RavenNetCompat::uint64 ReadUInt64();
void ReadRavenSimulationTask( CRavenSimulationTask* pTask );
void ReadRavenSimulationResult( CRavenSimulationResult* pResult );
void ReadRavenSimulationProfilerState( IRavenSimulationInterface::CProfiler* );
void ReadRavenSimulationProfilerState( IRavenSimulationSchedulerInterface::CProfiler* );
VistaConnectionIP* GetConnection() const;
void ClearConnection();
private:
int m_nMessageType;
int m_nMessageId;
int m_nAnswerType;
int m_nExceptionMode;
CRavenSerializer m_oOutgoing;
CRavenDeserializer m_oIncoming;
std::vector<RavenNetCompat::byte> m_vecIncomingBuffer;
VistaConnectionIP* m_pConnection;
};
// Messages consist of a message part and an answer part, each read or written
// separately. Messages have a three-int-header (SIZE, MSGTYPE; EXCEPTIONMODE), while
// answers have a two-int header (SIZE; ANSWERTYPE)
class CRavenNetMessage
{
public:
CRavenNetMessage(VistaSerializingToolset::ByteOrderSwapBehavior bSwapBuffers);
void ResetMessage();
void SetConnection(VistaConnectionIP* pConn);
void WriteMessage();
void ReadMessage();
void WriteAnswer();
void ReadAnswer();
int GetExceptionMode() const;
int GetMessageType() const;
int GetAnswerType() const;
void SetExceptionMode(int nMode);
void SetMessageType(int nType);
void SetAnswerType(int nType);
int GetIncomingMessageSize() const;
int GetOutgoingMessageSize() const;
bool GetOutgoingMessageHasData() const;
// --= Serializing functions =--
// Basics
void WriteInt(const int);
void WriteBool(const bool);
void WriteDouble(const double);
void WriteException(const ITAException&);
void WriteFloat(const float);
void WriteString(const std::string&);
void WriteIntVector(const std::vector<int>);
void WriteUInt64(const RavenNetCompat::uint64 uliValue);
void WriteRavenSimulationTask(const CRavenSimulationTask* pTask);
void WriteRavenSimulationResult(const CRavenSimulationResult* pResult);
void WriteRavenSimulationProfilerState(IRavenSimulationInterface::CProfiler*);
void WriteRavenSimulationProfilerState(IRavenSimulationSchedulerInterface::CProfiler*);
// --= Reader =--
std::string ReadString();
int ReadInt();
bool ReadBool();
ITAException ReadException();
float ReadFloat();
double ReadDouble();
std::vector<int> ReadIntVector();
RavenNetCompat::uint64 ReadUInt64();
void ReadRavenSimulationTask(CRavenSimulationTask* pTask);
void ReadRavenSimulationResult(CRavenSimulationResult* pResult);
void ReadRavenSimulationProfilerState(IRavenSimulationInterface::CProfiler*);
void ReadRavenSimulationProfilerState(IRavenSimulationSchedulerInterface::CProfiler*);
VistaConnectionIP* GetConnection() const;
void ClearConnection();
private:
int m_nMessageType;
int m_nMessageId;
int m_nAnswerType;
int m_nExceptionMode;
CRavenSerializer m_oOutgoing;
CRavenDeserializer m_oIncoming;
std::vector<RavenNetCompat::byte> m_vecIncomingBuffer;
VistaConnectionIP* m_pConnection;
};
}
#endif // IW_RAVENNET_MESSAGE
#include <ITASimulationScheduler/Raven/RavenNetServer.h>
#include "RavenNetServerImpl.h"
IRavenNetServer* IRavenNetServer::Create()
namespace ITASimulationScheduler
{
return new CRavenNetServerImpl();
}
IRavenNetServer::IRavenNetServer() {}
IRavenNetServer::~IRavenNetServer() {}
IRavenNetServer* IRavenNetServer::Create()
{
return new CRavenNetServerImpl();
}
IRavenNetServer::IRavenNetServer() {}
IRavenNetServer::~IRavenNetServer() {}
}
......@@ -20,6 +20,8 @@
#include <cassert>
#include <algorithm>
namespace ITASimulationScheduler
{
// --= Raven Simulation Scheduler Task Handler =--
class CRavenNetServerSimulationSchedulerTaskHandler : public IRavenSimulationSchedulerResultHandler
......@@ -1026,3 +1028,5 @@ bool CRavenNetServerImpl::IsRavenSimulationScheduler() const
{
return (m_pRealRavenSimulationScheduler != NULL);
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment