⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 thing.h

📁 chord 源码 http://pdos.csail.mit.edu/chord/
💻 H
字号:
#ifndef _THING_H_#define _THING_H_#include "mud_obj.h"//#include "room.h"class thing: public mud_obj {    //ptr<room> location;  char *buf; public:  tag_t ctag; //current version, for rmw updates  thing (str n, chordID writer, uint64 ver=0) : //, ptr<room> l=NULL) :     mud_obj (n), buf (NULL) {    ctag.ver = ver;    ctag.writer = writer;  };  thing (char *bytes, uint size) : buf (NULL) {    uint offst = 0;    uint slen;    bcopy (bytes, &ctag.ver, USZ);    offst += USZ;    mud_ID_get (&ctag.writer, bytes + offst);    offst += ID_SIZE;    bcopy (bytes + offst, &slen, USZ);    offst += USZ;    set_name (bytes + offst, slen);    offst += slen;    bcopy (bytes + offst, &slen, USZ);    offst += USZ;    set_desc (bytes + offst, slen);  };  uint size () {    return (3*USZ + ID_SIZE + get_name ().len () + describe ().len ());  };   char *bytes () {    if (buf) free (buf);    uint offst = 0;    uint slen;    buf = (char *) malloc (size ());    bcopy (&ctag.ver, buf + offst, USZ);    offst += USZ;    mud_ID_put (buf + offst, chordID(ctag.writer));    offst += ID_SIZE;        slen = get_name ().len ();    bcopy (&slen, buf + offst, USZ);    offst += USZ;    bcopy (get_name ().cstr (), buf + offst, slen);    offst += slen;    slen = describe ().len ();    bcopy (&slen, buf + offst, USZ);    offst += USZ;    bcopy (describe ().cstr (), buf + offst, slen);      return buf;  };   ~thing () {};    str to_str () {    strbuf ret;    ret << "\n"	<< "Object Name: " << get_name () << "\n"	<< "         ID: " << ID () << "\n"	<< "        tag: <" << ctag.ver << ", " << ctag.writer << ">\n"	<< "Description: " << describe () << "\n";    return str (ret);  };};#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -