mirror of
https://github.com/openmoh/openmohaa.git
synced 2025-05-06 19:01:04 +03:00
Renamed file.c to files.cpp
Renamed huffman.c to huffman.cp Renamed msg.c to msg.cpp Added Pipe class Made loaddef a local variable instead of a global variable for future potential multi-threading support
This commit is contained in:
parent
6bdfb4c093
commit
62ff9b7f4c
22 changed files with 2486 additions and 900 deletions
62
code/globalcpp/pipe.h
Normal file
62
code/globalcpp/pipe.h
Normal file
|
@ -0,0 +1,62 @@
|
|||
#pragma once
|
||||
|
||||
#include "listener.h"
|
||||
|
||||
class MessageEvent {
|
||||
private:
|
||||
byte* Buffer;
|
||||
size_t AllocatedSize;
|
||||
size_t BufferSize;
|
||||
byte* Position;
|
||||
bool bReadMode;
|
||||
|
||||
public:
|
||||
MessageEvent();
|
||||
MessageEvent(byte* Buffer, size_t Size);
|
||||
~MessageEvent();
|
||||
|
||||
void Reset();
|
||||
byte* SetReadMode(size_t Size);
|
||||
|
||||
bool ReadBool();
|
||||
int ReadInteger();
|
||||
str ReadString();
|
||||
byte ReadByte();
|
||||
|
||||
void WriteBool(bool Value);
|
||||
void WriteInteger(int Value);
|
||||
void WriteString(const char* Value);
|
||||
|
||||
byte* GetData() const;
|
||||
size_t GetDataSize() const;
|
||||
|
||||
private:
|
||||
bool FinishedReading();
|
||||
void EnsureAllocated();
|
||||
};
|
||||
|
||||
class PipeClass {
|
||||
private:
|
||||
void *m_phSourceReadHandle;
|
||||
void *m_phSourceWriteHandle;
|
||||
void *m_phTargetReadHandle;
|
||||
void *m_phTargetWriteHandle;
|
||||
|
||||
public:
|
||||
PipeClass();
|
||||
PipeClass(void* SourceHandle, void* TargetHandle);
|
||||
~PipeClass();
|
||||
|
||||
bool IsValid() const;
|
||||
bool IsValidForWriting() const;
|
||||
void Read(MessageEvent* Msg, bool bWait = false);
|
||||
void Send(const MessageEvent* Msg);
|
||||
bool HasData();
|
||||
|
||||
void* GetSourceNativeHandle();
|
||||
void* GetTargetNativeHandle();
|
||||
|
||||
private:
|
||||
void ReadPipeData(MessageEvent* Msg, bool bWait = false );
|
||||
void WritePipeData(const MessageEvent* Msg);
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue