Files
integration/luprex/cpp/core/invocation.hpp

78 lines
1.9 KiB
C++
Raw Normal View History

//////////////////////////////////////////////////////////////////////////
//
// DATAPACK
//
// Invocations contain a field 'datapack' which contains additional
// data for the invocation, packed up in a serialized format. Executing
// the invocation involves unpacking the datapack.
//
// The actual contents of the datapack depends on the type of invocation:
//
2024-09-02 21:48:24 -04:00
// InvocationKind::INVALID:
//
// Nothing.
//
2024-09-02 21:48:24 -04:00
// InvocationKind::LUA_CALL:
2024-08-29 17:45:05 -04:00
//
// A lua function call. The class name, the function name, and then
// the function arguments.
2024-02-07 15:59:17 -05:00
//
2024-09-02 21:48:24 -04:00
// InvocationKind::LUA_EXPR:
//
// A block of lua source code, in plaintext.
//
2024-09-02 21:48:24 -04:00
// InvocationKind::FLUSH_PRINTS:
//
// Line number in ascii.
//
2024-09-02 21:48:24 -04:00
// InvocationKind::TICK:
//
// Nothing.
//
2024-09-02 21:48:24 -04:00
// InvocationKind::LUA_SOURCE:
//
// Packaged lua sourcecode. See drvutil::package_lua_source.
//
//////////////////////////////////////////////////////////////////////////
#ifndef INVOCATION_HPP
#define INVOCATION_HPP
#include "wrap-string.hpp"
#include "wrap-map.hpp"
#include "wrap-deque.hpp"
#include "streambuffer.hpp"
2024-09-02 21:48:24 -04:00
#include "enginewrapper.hpp"
class Invocation : public eng::opnew {
public:
private:
2024-09-02 21:48:24 -04:00
InvocationKind kind_;
int64_t actor_;
int64_t place_;
eng::string datapack_;
public:
Invocation();
2024-09-02 21:48:24 -04:00
Invocation(InvocationKind kind, int64_t actor, int64_t place, std::string_view datapack);
2021-11-16 12:20:11 -05:00
2024-09-02 21:48:24 -04:00
bool valid() const { return kind_ != InvocationKind::INVALID; }
InvocationKind kind() const { return kind_; }
int64_t actor() const { return actor_; }
int64_t place() const { return place_; }
const eng::string &datapack() const { return datapack_; }
void serialize(StreamBuffer *sb) const;
void deserialize(StreamBuffer *sb);
2021-11-11 16:23:11 -05:00
eng::string debug_string() const;
};
using UniqueInvocation = std::unique_ptr<Invocation>;
class InvocationQueue : public eng::deque<Invocation> {
};
#endif // INVOCATION_HPP