tahoma2d/toonz/sources/include/tipcmsg.h

100 lines
1.8 KiB
C
Raw Normal View History

2016-05-17 03:04:11 +12:00
#pragma once
2016-03-19 06:57:51 +13:00
#ifndef TIPC_MESSAGE_H
#define TIPC_MESSAGE_H
2016-06-15 18:43:10 +12:00
// Toonz includes
2016-03-19 06:57:51 +13:00
#include "tcommon.h"
2016-06-15 18:43:10 +12:00
// Qt includes
2016-03-19 06:57:51 +13:00
#include <QDataStream>
#include <QLocalSocket>
#include "tipc.h"
#undef DVAPI
#undef DVVAR
#ifdef TNZCORE_EXPORTS
#define DVAPI DV_EXPORT_API
#define DVVAR DV_EXPORT_VAR
#else
#define DVAPI DV_IMPORT_API
#define DVVAR DV_IMPORT_VAR
#endif
2016-06-15 18:43:10 +12:00
namespace tipc {
2016-03-19 06:57:51 +13:00
//********************************************************
// TIPC Message Parser declaration
//********************************************************
2016-06-15 18:43:10 +12:00
class MessageParser {
friend class Server;
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
QLocalSocket *m_socket;
tipc::Stream *m_stream;
2016-03-19 06:57:51 +13:00
public:
2016-06-15 18:43:10 +12:00
virtual QString header() const = 0;
virtual void operator()(Message &msg) = 0;
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
QLocalSocket *socket() { return m_socket; }
tipc::Stream *stream() { return m_stream; }
2016-03-19 06:57:51 +13:00
};
//********************************************************
// Default Message Types declaration
//********************************************************
2016-06-15 18:43:10 +12:00
enum DefMsgEnum {
SHMEM_REQUEST,
SHMEM_RELEASE,
TMPFILE_REQUEST,
TMPFILE_RELEASE,
QUIT_ON_ERROR
};
2016-03-19 06:57:51 +13:00
template <DefMsgEnum msgType>
class DVAPI DefaultMessageParser final : public MessageParser {
2016-03-19 06:57:51 +13:00
public:
2016-06-19 20:06:29 +12:00
QString header() const override;
void operator()(Message &msg) override;
2016-03-19 06:57:51 +13:00
};
//------------------------------------------------------------------------------
/* Default commands syntaxes:
SHMEM_REQUEST
Syntax: $shmem_request <shmem id> <nbytes>
Reply: ok | err
SHMEM_RELEASE
Syntax: $shmem_release <shmem id>
Reply: ok | err
TMPFILE_REQUEST
Syntax: $tmpfile_request <file id>
Reply: ok <file path>\n | err
TMPFILE_RELEASE
Syntax: $tmpfile_release <file id>
Reply: ok | err
QUIT_ON_ERROR
Syntax: $quit_on_error
Reply: ok
*/
//------------------------------------------------------------------------------
2016-06-15 18:43:10 +12:00
} // namespace tipc
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
#endif // TIPC_MESSAGE_H