45namespace Gecode {
namespace CPProfiler {
48 static const int32_t PROFILER_PROTOCOL_VERSION = 3;
95 present =
true; value_ =
t;
105 assert(present);
return value_;
110 assert(present);
return value_;
226 static void serializeType(std::vector<char>& data,
MsgType f) {
227 data.push_back(
static_cast<char>(f));
230 static void serializeField(std::vector<char>& data, Field f) {
231 data.push_back(
static_cast<char>(f));
234 static void serialize(std::vector<char>& data, int32_t i) {
235 data.push_back(
static_cast<char>((i & 0xFF000000) >> 24));
236 data.push_back(
static_cast<char>((i & 0xFF0000) >> 16));
237 data.push_back(
static_cast<char>((i & 0xFF00) >> 8));
238 data.push_back(
static_cast<char>((i & 0xFF)));
242 data.push_back(
static_cast<char>(s));
245 static void serialize(std::vector<char>& data,
const std::string& s) {
246 serialize(data,
static_cast<int32_t
>(s.size()));
252 static MsgType deserializeMsgType(iter& it) {
253 auto m =
static_cast<MsgType>(*it);
258 static Field deserializeField(iter& it) {
259 auto f =
static_cast<Field
>(*it);
264 static int32_t deserializeInt(iter& it) {
265 auto b1 =
static_cast<uint32_t
>(
reinterpret_cast<uint8_t&
>(*it++));
266 auto b2 =
static_cast<uint32_t
>(
reinterpret_cast<uint8_t&
>(*it++));
267 auto b3 =
static_cast<uint32_t
>(
reinterpret_cast<uint8_t&
>(*it++));
268 auto b4 =
static_cast<uint32_t
>(
reinterpret_cast<uint8_t&
>(*it++));
270 return static_cast<int32_t
>(b1 << 24 | b2 << 16 | b3 << 8 | b4);
273 static NodeStatus deserializeStatus(iter& it) {
279 static std::string deserializeString(iter& it) {
281 int32_t size = deserializeInt(it);
282 result.reserve(
static_cast<size_t>(size));
283 for (int32_t i = 0; i < size; i++) {
292 int32_t alt, int32_t kids,
NodeStatus status) {
327 std::vector<char> data;
328 size_t dataSize = 1 + (msg.
isNode() ? 4 * 8 + 1 : 0) +
332 data.reserve(dataSize);
334 serializeType(data, msg.
type());
353 serializeField(data, VERSION);
357 serializeField(data, LABEL);
361 serializeField(data, NOGOOD);
365 serializeField(data, INFO);
372 char *end = data + size;
373 msg.
set_type(deserializeMsgType(data));
375 int32_t nid = deserializeInt(data);
376 int32_t rid = deserializeInt(data);
377 int32_t tid = deserializeInt(data);
381 nid = deserializeInt(data);
382 rid = deserializeInt(data);
383 tid = deserializeInt(data);
387 msg.
set_alt(deserializeInt(data));
394 while (data != end) {
395 MessageMarshalling::Field f = deserializeField(data);
400 msg.
set_label(deserializeString(data));
break;
402 msg.
set_nogood(deserializeString(data));
break;
404 msg.
set_info(deserializeString(data));
break;
int p
Number of positive literals for node type.
int n
Number of negative literals for node type.
std::vector< char > serialize(void) const
void deserialize(char *data, size_t size)
const Message & get_msg(void)
Message & makeNode(NodeUID node, NodeUID parent, int32_t alt, int32_t kids, NodeStatus status)
void makeStart(const std::string &info)
void makeRestart(const std::string &info)
Message for the CP Profiler.
void set_alt(int32_t alt)
bool has_info(void) const
NodeUID nodeUID(void) const
void set_label(const std::string &label)
void set_status(NodeStatus status)
NodeUID parentUID(void) const
void set_nogood(const std::string &nogood)
void set_nodeUID(const NodeUID &n)
const std::string & label() const
const std::string & nogood(void) const
void set_info(const std::string &info)
int32_t version(void) const
NodeStatus status(void) const
void set_version(int32_t v)
bool isRestart(void) const
bool has_nogood(void) const
void set_type(MsgType type)
void set_kids(int32_t kids)
const std::string & info(void) const
bool has_label(void) const
bool has_version(void) const
void set_parentUID(const NodeUID &p)
bool valid(void) const
Check whether value is present.
void set(const T &t)
Set value to t.
bool present
Whether value is present.
T value_
A value, potentially not initialized.
void unset(void)
Disregard value.
const T & value(void) const
Access value.
T & value(void)
Access value.
NodeStatus
Types of nodes for CP Profiler.
@ SOLVED
Node representing a solution.
@ BRANCH
Node representing a branch.
@ SKIPPED
Node skipped by backjumping.
@ FAILED
Node representing failure.
MsgType
Types of messages for CP Profiler.
Gecode toplevel namespace
Unique identifier for a node.