//
// Generated file, do not edit! Created by opp_msgc 4.1 from applications/mydht/MyDHTMessage.msg.
//

// Disable warnings about unused variables, empty switch stmts, etc:
#ifdef _MSC_VER
#  pragma warning(disable:4101)
#  pragma warning(disable:4065)
#endif

#include <iostream>
#include <sstream>
#include "MyDHTMessage_m.h"

// Template rule which fires if a struct or class doesn't have operator<<
template<typename T>
std::ostream& operator<<(std::ostream& out,const T&) {return out;}

// Another default rule (prevents compiler from choosing base class' doPacking())
template<typename T>
void doPacking(cCommBuffer *, T& t) {
    throw cRuntimeError("Parsim error: no doPacking() function for type %s or its base class (check .msg and _m.cc/h files!)",opp_typename(typeid(t)));
}

template<typename T>
void doUnpacking(cCommBuffer *, T& t) {
    throw cRuntimeError("Parsim error: no doUnpacking() function for type %s or its base class (check .msg and _m.cc/h files!)",opp_typename(typeid(t)));
}




Register_Class(MyDHTPutCall);

MyDHTPutCall::MyDHTPutCall(const char *name, int kind) : BaseCallMessage(name,kind)
{
    this->kind_var = 0;
    this->id_var = 0;
    this->ttl_var = 0;
    this->isModifiable_var = 0;
    this->maintenance_var = 0;
}

MyDHTPutCall::MyDHTPutCall(const MyDHTPutCall& other) : BaseCallMessage()
{
    setName(other.getName());
    operator=(other);
}

MyDHTPutCall::~MyDHTPutCall()
{
}

MyDHTPutCall& MyDHTPutCall::operator=(const MyDHTPutCall& other)
{
    if (this==&other) return *this;
    BaseCallMessage::operator=(other);
    this->key_var = other.key_var;
    this->value_var = other.value_var;
    this->kind_var = other.kind_var;
    this->id_var = other.id_var;
    this->ttl_var = other.ttl_var;
    this->isModifiable_var = other.isModifiable_var;
    this->maintenance_var = other.maintenance_var;
    this->ownerNode_var = other.ownerNode_var;
    return *this;
}

void MyDHTPutCall::parsimPack(cCommBuffer *b)
{
    BaseCallMessage::parsimPack(b);
    doPacking(b,this->key_var);
    doPacking(b,this->value_var);
    doPacking(b,this->kind_var);
    doPacking(b,this->id_var);
    doPacking(b,this->ttl_var);
    doPacking(b,this->isModifiable_var);
    doPacking(b,this->maintenance_var);
    doPacking(b,this->ownerNode_var);
}

void MyDHTPutCall::parsimUnpack(cCommBuffer *b)
{
    BaseCallMessage::parsimUnpack(b);
    doUnpacking(b,this->key_var);
    doUnpacking(b,this->value_var);
    doUnpacking(b,this->kind_var);
    doUnpacking(b,this->id_var);
    doUnpacking(b,this->ttl_var);
    doUnpacking(b,this->isModifiable_var);
    doUnpacking(b,this->maintenance_var);
    doUnpacking(b,this->ownerNode_var);
}

OverlayKey& MyDHTPutCall::getKey()
{
    return key_var;
}

void MyDHTPutCall::setKey(const OverlayKey& key_var)
{
    this->key_var = key_var;
}

BinaryValue& MyDHTPutCall::getValue()
{
    return value_var;
}

void MyDHTPutCall::setValue(const BinaryValue& value_var)
{
    this->value_var = value_var;
}

uint32_t MyDHTPutCall::getKind() const
{
    return kind_var;
}

void MyDHTPutCall::setKind(uint32_t kind_var)
{
    this->kind_var = kind_var;
}

uint32_t MyDHTPutCall::getId() const
{
    return id_var;
}

void MyDHTPutCall::setId(uint32_t id_var)
{
    this->id_var = id_var;
}

int MyDHTPutCall::getTtl() const
{
    return ttl_var;
}

void MyDHTPutCall::setTtl(int ttl_var)
{
    this->ttl_var = ttl_var;
}

bool MyDHTPutCall::getIsModifiable() const
{
    return isModifiable_var;
}

void MyDHTPutCall::setIsModifiable(bool isModifiable_var)
{
    this->isModifiable_var = isModifiable_var;
}

bool MyDHTPutCall::getMaintenance() const
{
    return maintenance_var;
}

void MyDHTPutCall::setMaintenance(bool maintenance_var)
{
    this->maintenance_var = maintenance_var;
}

NodeHandle& MyDHTPutCall::getOwnerNode()
{
    return ownerNode_var;
}

void MyDHTPutCall::setOwnerNode(const NodeHandle& ownerNode_var)
{
    this->ownerNode_var = ownerNode_var;
}

class MyDHTPutCallDescriptor : public cClassDescriptor
{
  public:
    MyDHTPutCallDescriptor();
    virtual ~MyDHTPutCallDescriptor();

    virtual bool doesSupport(cObject *obj) const;
    virtual const char *getProperty(const char *propertyname) const;
    virtual int getFieldCount(void *object) const;
    virtual const char *getFieldName(void *object, int field) const;
    virtual int findField(void *object, const char *fieldName) const;
    virtual unsigned int getFieldTypeFlags(void *object, int field) const;
    virtual const char *getFieldTypeString(void *object, int field) const;
    virtual const char *getFieldProperty(void *object, int field, const char *propertyname) const;
    virtual int getArraySize(void *object, int field) const;

    virtual std::string getFieldAsString(void *object, int field, int i) const;
    virtual bool setFieldAsString(void *object, int field, int i, const char *value) const;

    virtual const char *getFieldStructName(void *object, int field) const;
    virtual void *getFieldStructPointer(void *object, int field, int i) const;
};

Register_ClassDescriptor(MyDHTPutCallDescriptor);

MyDHTPutCallDescriptor::MyDHTPutCallDescriptor() : cClassDescriptor("MyDHTPutCall", "BaseCallMessage")
{
}

MyDHTPutCallDescriptor::~MyDHTPutCallDescriptor()
{
}

bool MyDHTPutCallDescriptor::doesSupport(cObject *obj) const
{
    return dynamic_cast<MyDHTPutCall *>(obj)!=NULL;
}

const char *MyDHTPutCallDescriptor::getProperty(const char *propertyname) const
{
    cClassDescriptor *basedesc = getBaseClassDescriptor();
    return basedesc ? basedesc->getProperty(propertyname) : NULL;
}

int MyDHTPutCallDescriptor::getFieldCount(void *object) const
{
    cClassDescriptor *basedesc = getBaseClassDescriptor();
    return basedesc ? 8+basedesc->getFieldCount(object) : 8;
}

unsigned int MyDHTPutCallDescriptor::getFieldTypeFlags(void *object, int field) const
{
    cClassDescriptor *basedesc = getBaseClassDescriptor();
    if (basedesc) {
        if (field < basedesc->getFieldCount(object))
            return basedesc->getFieldTypeFlags(object, field);
        field -= basedesc->getFieldCount(object);
    }
    static unsigned int fieldTypeFlags[] = {
        FD_ISCOMPOUND,
        FD_ISCOMPOUND,
        FD_ISEDITABLE,
        FD_ISEDITABLE,
        FD_ISEDITABLE,
        FD_ISEDITABLE,
        FD_ISEDITABLE,
        FD_ISCOMPOUND,
    };
    return (field>=0 && field<8) ? fieldTypeFlags[field] : 0;
}

const char *MyDHTPutCallDescriptor::getFieldName(void *object, int field) const
{
    cClassDescriptor *basedesc = getBaseClassDescriptor();
    if (basedesc) {
        if (field < basedesc->getFieldCount(object))
            return basedesc->getFieldName(object, field);
        field -= basedesc->getFieldCount(object);
    }
    static const char *fieldNames[] = {
        "key",
        "value",
        "kind",
        "id",
        "ttl",
        "isModifiable",
        "maintenance",
        "ownerNode",
    };
    return (field>=0 && field<8) ? fieldNames[field] : NULL;
}

int MyDHTPutCallDescriptor::findField(void *object, const char *fieldName) const
{
    cClassDescriptor *basedesc = getBaseClassDescriptor();
    int base = basedesc ? basedesc->getFieldCount(object) : 0;
    if (fieldName[0]=='k' && strcmp(fieldName, "key")==0) return base+0;
    if (fieldName[0]=='v' && strcmp(fieldName, "value")==0) return base+1;
    if (fieldName[0]=='k' && strcmp(fieldName, "kind")==0) return base+2;
    if (fieldName[0]=='i' && strcmp(fieldName, "id")==0) return base+3;
    if (fieldName[0]=='t' && strcmp(fieldName, "ttl")==0) return base+4;
    if (fieldName[0]=='i' && strcmp(fieldName, "isModifiable")==0) return base+5;
    if (fieldName[0]=='m' && strcmp(fieldName, "maintenance")==0) return base+6;
    if (fieldName[0]=='o' && strcmp(fieldName, "ownerNode")==0) return base+7;
    return basedesc ? basedesc->findField(object, fieldName) : -1;
}

const char *MyDHTPutCallDescriptor::getFieldTypeString(void *object, int field) const
{
    cClassDescriptor *basedesc = getBaseClassDescriptor();
    if (basedesc) {
        if (field < basedesc->getFieldCount(object))
            return basedesc->getFieldTypeString(object, field);
        field -= basedesc->getFieldCount(object);
    }
    static const char *fieldTypeStrings[] = {
        "OverlayKey",
        "BinaryValue",
        "uint32_t",
        "uint32_t",
        "int",
        "bool",
        "bool",
        "NodeHandle",
    };
    return (field>=0 && field<8) ? fieldTypeStrings[field] : NULL;
}

const char *MyDHTPutCallDescriptor::getFieldProperty(void *object, int field, const char *propertyname) const
{
    cClassDescriptor *basedesc = getBaseClassDescriptor();
    if (basedesc) {
        if (field < basedesc->getFieldCount(object))
            return basedesc->getFieldProperty(object, field, propertyname);
        field -= basedesc->getFieldCount(object);
    }
    switch (field) {
        default: return NULL;
    }
}

int MyDHTPutCallDescriptor::getArraySize(void *object, int field) const
{
    cClassDescriptor *basedesc = getBaseClassDescriptor();
    if (basedesc) {
        if (field < basedesc->getFieldCount(object))
            return basedesc->getArraySize(object, field);
        field -= basedesc->getFieldCount(object);
    }
    MyDHTPutCall *pp = (MyDHTPutCall *)object; (void)pp;
    switch (field) {
        default: return 0;
    }
}

std::string MyDHTPutCallDescriptor::getFieldAsString(void *object, int field, int i) const
{
    cClassDescriptor *basedesc = getBaseClassDescriptor();
    if (basedesc) {
        if (field < basedesc->getFieldCount(object))
            return basedesc->getFieldAsString(object,field,i);
        field -= basedesc->getFieldCount(object);
    }
    MyDHTPutCall *pp = (MyDHTPutCall *)object; (void)pp;
    switch (field) {
        case 0: {std::stringstream out; out << pp->getKey(); return out.str();}
        case 1: {std::stringstream out; out << pp->getValue(); return out.str();}
        case 2: return ulong2string(pp->getKind());
        case 3: return ulong2string(pp->getId());
        case 4: return long2string(pp->getTtl());
        case 5: return bool2string(pp->getIsModifiable());
        case 6: return bool2string(pp->getMaintenance());
        case 7: {std::stringstream out; out << pp->getOwnerNode(); return out.str();}
        default: return "";
    }
}

bool MyDHTPutCallDescriptor::setFieldAsString(void *object, int field, int i, const char *value) const
{
    cClassDescriptor *basedesc = getBaseClassDescriptor();
    if (basedesc) {
        if (field < basedesc->getFieldCount(object))
            return basedesc->setFieldAsString(object,field,i,value);
        field -= basedesc->getFieldCount(object);
    }
    MyDHTPutCall *pp = (MyDHTPutCall *)object; (void)pp;
    switch (field) {
        case 2: pp->setKind(string2ulong(value)); return true;
        case 3: pp->setId(string2ulong(value)); return true;
        case 4: pp->setTtl(string2long(value)); return true;
        case 5: pp->setIsModifiable(string2bool(value)); return true;
        case 6: pp->setMaintenance(string2bool(value)); return true;
        default: return false;
    }
}

const char *MyDHTPutCallDescriptor::getFieldStructName(void *object, int field) const
{
    cClassDescriptor *basedesc = getBaseClassDescriptor();
    if (basedesc) {
        if (field < basedesc->getFieldCount(object))
            return basedesc->getFieldStructName(object, field);
        field -= basedesc->getFieldCount(object);
    }
    static const char *fieldStructNames[] = {
        "OverlayKey",
        "BinaryValue",
        NULL,
        NULL,
        NULL,
        NULL,
        NULL,
        "NodeHandle",
    };
    return (field>=0 && field<8) ? fieldStructNames[field] : NULL;
}

void *MyDHTPutCallDescriptor::getFieldStructPointer(void *object, int field, int i) const
{
    cClassDescriptor *basedesc = getBaseClassDescriptor();
    if (basedesc) {
        if (field < basedesc->getFieldCount(object))
            return basedesc->getFieldStructPointer(object, field, i);
        field -= basedesc->getFieldCount(object);
    }
    MyDHTPutCall *pp = (MyDHTPutCall *)object; (void)pp;
    switch (field) {
        case 0: return (void *)(&pp->getKey()); break;
        case 1: return (void *)(&pp->getValue()); break;
        case 7: return (void *)(&pp->getOwnerNode()); break;
        default: return NULL;
    }
}

Register_Class(MyDHTPutResponse);

MyDHTPutResponse::MyDHTPutResponse(const char *name, int kind) : BaseResponseMessage(name,kind)
{
    this->success_var = 0;
}

MyDHTPutResponse::MyDHTPutResponse(const MyDHTPutResponse& other) : BaseResponseMessage()
{
    setName(other.getName());
    operator=(other);
}

MyDHTPutResponse::~MyDHTPutResponse()
{
}

MyDHTPutResponse& MyDHTPutResponse::operator=(const MyDHTPutResponse& other)
{
    if (this==&other) return *this;
    BaseResponseMessage::operator=(other);
    this->success_var = other.success_var;
    return *this;
}

void MyDHTPutResponse::parsimPack(cCommBuffer *b)
{
    BaseResponseMessage::parsimPack(b);
    doPacking(b,this->success_var);
}

void MyDHTPutResponse::parsimUnpack(cCommBuffer *b)
{
    BaseResponseMessage::parsimUnpack(b);
    doUnpacking(b,this->success_var);
}

bool MyDHTPutResponse::getSuccess() const
{
    return success_var;
}

void MyDHTPutResponse::setSuccess(bool success_var)
{
    this->success_var = success_var;
}

class MyDHTPutResponseDescriptor : public cClassDescriptor
{
  public:
    MyDHTPutResponseDescriptor();
    virtual ~MyDHTPutResponseDescriptor();

    virtual bool doesSupport(cObject *obj) const;
    virtual const char *getProperty(const char *propertyname) const;
    virtual int getFieldCount(void *object) const;
    virtual const char *getFieldName(void *object, int field) const;
    virtual int findField(void *object, const char *fieldName) const;
    virtual unsigned int getFieldTypeFlags(void *object, int field) const;
    virtual const char *getFieldTypeString(void *object, int field) const;
    virtual const char *getFieldProperty(void *object, int field, const char *propertyname) const;
    virtual int getArraySize(void *object, int field) const;

    virtual std::string getFieldAsString(void *object, int field, int i) const;
    virtual bool setFieldAsString(void *object, int field, int i, const char *value) const;

    virtual const char *getFieldStructName(void *object, int field) const;
    virtual void *getFieldStructPointer(void *object, int field, int i) const;
};

Register_ClassDescriptor(MyDHTPutResponseDescriptor);

MyDHTPutResponseDescriptor::MyDHTPutResponseDescriptor() : cClassDescriptor("MyDHTPutResponse", "BaseResponseMessage")
{
}

MyDHTPutResponseDescriptor::~MyDHTPutResponseDescriptor()
{
}

bool MyDHTPutResponseDescriptor::doesSupport(cObject *obj) const
{
    return dynamic_cast<MyDHTPutResponse *>(obj)!=NULL;
}

const char *MyDHTPutResponseDescriptor::getProperty(const char *propertyname) const
{
    cClassDescriptor *basedesc = getBaseClassDescriptor();
    return basedesc ? basedesc->getProperty(propertyname) : NULL;
}

int MyDHTPutResponseDescriptor::getFieldCount(void *object) const
{
    cClassDescriptor *basedesc = getBaseClassDescriptor();
    return basedesc ? 1+basedesc->getFieldCount(object) : 1;
}

unsigned int MyDHTPutResponseDescriptor::getFieldTypeFlags(void *object, int field) const
{
    cClassDescriptor *basedesc = getBaseClassDescriptor();
    if (basedesc) {
        if (field < basedesc->getFieldCount(object))
            return basedesc->getFieldTypeFlags(object, field);
        field -= basedesc->getFieldCount(object);
    }
    static unsigned int fieldTypeFlags[] = {
        FD_ISEDITABLE,
    };
    return (field>=0 && field<1) ? fieldTypeFlags[field] : 0;
}

const char *MyDHTPutResponseDescriptor::getFieldName(void *object, int field) const
{
    cClassDescriptor *basedesc = getBaseClassDescriptor();
    if (basedesc) {
        if (field < basedesc->getFieldCount(object))
            return basedesc->getFieldName(object, field);
        field -= basedesc->getFieldCount(object);
    }
    static const char *fieldNames[] = {
        "success",
    };
    return (field>=0 && field<1) ? fieldNames[field] : NULL;
}

int MyDHTPutResponseDescriptor::findField(void *object, const char *fieldName) const
{
    cClassDescriptor *basedesc = getBaseClassDescriptor();
    int base = basedesc ? basedesc->getFieldCount(object) : 0;
    if (fieldName[0]=='s' && strcmp(fieldName, "success")==0) return base+0;
    return basedesc ? basedesc->findField(object, fieldName) : -1;
}

const char *MyDHTPutResponseDescriptor::getFieldTypeString(void *object, int field) const
{
    cClassDescriptor *basedesc = getBaseClassDescriptor();
    if (basedesc) {
        if (field < basedesc->getFieldCount(object))
            return basedesc->getFieldTypeString(object, field);
        field -= basedesc->getFieldCount(object);
    }
    static const char *fieldTypeStrings[] = {
        "bool",
    };
    return (field>=0 && field<1) ? fieldTypeStrings[field] : NULL;
}

const char *MyDHTPutResponseDescriptor::getFieldProperty(void *object, int field, const char *propertyname) const
{
    cClassDescriptor *basedesc = getBaseClassDescriptor();
    if (basedesc) {
        if (field < basedesc->getFieldCount(object))
            return basedesc->getFieldProperty(object, field, propertyname);
        field -= basedesc->getFieldCount(object);
    }
    switch (field) {
        default: return NULL;
    }
}

int MyDHTPutResponseDescriptor::getArraySize(void *object, int field) const
{
    cClassDescriptor *basedesc = getBaseClassDescriptor();
    if (basedesc) {
        if (field < basedesc->getFieldCount(object))
            return basedesc->getArraySize(object, field);
        field -= basedesc->getFieldCount(object);
    }
    MyDHTPutResponse *pp = (MyDHTPutResponse *)object; (void)pp;
    switch (field) {
        default: return 0;
    }
}

std::string MyDHTPutResponseDescriptor::getFieldAsString(void *object, int field, int i) const
{
    cClassDescriptor *basedesc = getBaseClassDescriptor();
    if (basedesc) {
        if (field < basedesc->getFieldCount(object))
            return basedesc->getFieldAsString(object,field,i);
        field -= basedesc->getFieldCount(object);
    }
    MyDHTPutResponse *pp = (MyDHTPutResponse *)object; (void)pp;
    switch (field) {
        case 0: return bool2string(pp->getSuccess());
        default: return "";
    }
}

bool MyDHTPutResponseDescriptor::setFieldAsString(void *object, int field, int i, const char *value) const
{
    cClassDescriptor *basedesc = getBaseClassDescriptor();
    if (basedesc) {
        if (field < basedesc->getFieldCount(object))
            return basedesc->setFieldAsString(object,field,i,value);
        field -= basedesc->getFieldCount(object);
    }
    MyDHTPutResponse *pp = (MyDHTPutResponse *)object; (void)pp;
    switch (field) {
        case 0: pp->setSuccess(string2bool(value)); return true;
        default: return false;
    }
}

const char *MyDHTPutResponseDescriptor::getFieldStructName(void *object, int field) const
{
    cClassDescriptor *basedesc = getBaseClassDescriptor();
    if (basedesc) {
        if (field < basedesc->getFieldCount(object))
            return basedesc->getFieldStructName(object, field);
        field -= basedesc->getFieldCount(object);
    }
    static const char *fieldStructNames[] = {
        NULL,
    };
    return (field>=0 && field<1) ? fieldStructNames[field] : NULL;
}

void *MyDHTPutResponseDescriptor::getFieldStructPointer(void *object, int field, int i) const
{
    cClassDescriptor *basedesc = getBaseClassDescriptor();
    if (basedesc) {
        if (field < basedesc->getFieldCount(object))
            return basedesc->getFieldStructPointer(object, field, i);
        field -= basedesc->getFieldCount(object);
    }
    MyDHTPutResponse *pp = (MyDHTPutResponse *)object; (void)pp;
    switch (field) {
        default: return NULL;
    }
}

Register_Class(MyDHTGetMessage);

MyDHTGetMessage::MyDHTGetMessage(const char *name, int kind) : cPacket(name,kind)
{
    this->kind_var = 0;
    this->id_var = 0;
    this->groupId_var = 0;
    this->isHash_var = 0;
    this->nonce_var = 0;
    this->cache_var = 0;
    cRequesters_arraysize = 0;
    this->cRequesters_var = 0;
}

MyDHTGetMessage::MyDHTGetMessage(const MyDHTGetMessage& other) : cPacket()
{
    setName(other.getName());
    cRequesters_arraysize = 0;
    this->cRequesters_var = 0;
    operator=(other);
}

MyDHTGetMessage::~MyDHTGetMessage()
{
    delete [] cRequesters_var;
}

MyDHTGetMessage& MyDHTGetMessage::operator=(const MyDHTGetMessage& other)
{
    if (this==&other) return *this;
    cPacket::operator=(other);
    this->key_var = other.key_var;
    this->kind_var = other.kind_var;
    this->id_var = other.id_var;
    this->groupId_var = other.groupId_var;
    this->isHash_var = other.isHash_var;
    this->nonce_var = other.nonce_var;
    this->cache_var = other.cache_var;
    delete [] this->cRequesters_var;
    this->cRequesters_var = (other.cRequesters_arraysize==0) ? NULL : new ::NodeHandle[other.cRequesters_arraysize];
    cRequesters_arraysize = other.cRequesters_arraysize;
    for (unsigned int i=0; i<cRequesters_arraysize; i++)
        this->cRequesters_var[i] = other.cRequesters_var[i];
    return *this;
}

void MyDHTGetMessage::parsimPack(cCommBuffer *b)
{
    cPacket::parsimPack(b);
    doPacking(b,this->key_var);
    doPacking(b,this->kind_var);
    doPacking(b,this->id_var);
    doPacking(b,this->groupId_var);
    doPacking(b,this->isHash_var);
    doPacking(b,this->nonce_var);
    doPacking(b,this->cache_var);
    b->pack(cRequesters_arraysize);
    doPacking(b,this->cRequesters_var,cRequesters_arraysize);
}

void MyDHTGetMessage::parsimUnpack(cCommBuffer *b)
{
    cPacket::parsimUnpack(b);
    doUnpacking(b,this->key_var);
    doUnpacking(b,this->kind_var);
    doUnpacking(b,this->id_var);
    doUnpacking(b,this->groupId_var);
    doUnpacking(b,this->isHash_var);
    doUnpacking(b,this->nonce_var);
    doUnpacking(b,this->cache_var);
    delete [] this->cRequesters_var;
    b->unpack(cRequesters_arraysize);
    if (cRequesters_arraysize==0) {
        this->cRequesters_var = 0;
    } else {
        this->cRequesters_var = new ::NodeHandle[cRequesters_arraysize];
        doUnpacking(b,this->cRequesters_var,cRequesters_arraysize);
    }
}

OverlayKey& MyDHTGetMessage::getKey()
{
    return key_var;
}

void MyDHTGetMessage::setKey(const OverlayKey& key_var)
{
    this->key_var = key_var;
}

uint32_t MyDHTGetMessage::getKind() const
{
    return kind_var;
}

void MyDHTGetMessage::setKind(uint32_t kind_var)
{
    this->kind_var = kind_var;
}

uint32_t MyDHTGetMessage::getId() const
{
    return id_var;
}

void MyDHTGetMessage::setId(uint32_t id_var)
{
    this->id_var = id_var;
}

int MyDHTGetMessage::getGroupId() const
{
    return groupId_var;
}

void MyDHTGetMessage::setGroupId(int groupId_var)
{
    this->groupId_var = groupId_var;
}

bool MyDHTGetMessage::getIsHash() const
{
    return isHash_var;
}

void MyDHTGetMessage::setIsHash(bool isHash_var)
{
    this->isHash_var = isHash_var;
}

unsigned int MyDHTGetMessage::getNonce() const
{
    return nonce_var;
}

void MyDHTGetMessage::setNonce(unsigned int nonce_var)
{
    this->nonce_var = nonce_var;
}

bool MyDHTGetMessage::getCache() const
{
    return cache_var;
}

void MyDHTGetMessage::setCache(bool cache_var)
{
    this->cache_var = cache_var;
}

void MyDHTGetMessage::setCRequestersArraySize(unsigned int size)
{
    ::NodeHandle *cRequesters_var2 = (size==0) ? NULL : new ::NodeHandle[size];
    unsigned int sz = cRequesters_arraysize < size ? cRequesters_arraysize : size;
    for (unsigned int i=0; i<sz; i++)
        cRequesters_var2[i] = this->cRequesters_var[i];
    cRequesters_arraysize = size;
    delete [] this->cRequesters_var;
    this->cRequesters_var = cRequesters_var2;
}

unsigned int MyDHTGetMessage::getCRequestersArraySize() const
{
    return cRequesters_arraysize;
}

NodeHandle& MyDHTGetMessage::getCRequesters(unsigned int k)
{
    if (k>=cRequesters_arraysize) throw cRuntimeError("Array of size %d indexed by %d", cRequesters_arraysize, k);
    return cRequesters_var[k];
}

void MyDHTGetMessage::setCRequesters(unsigned int k, const NodeHandle& cRequesters_var)
{
    if (k>=cRequesters_arraysize) throw cRuntimeError("Array of size %d indexed by %d", cRequesters_arraysize, k);
    this->cRequesters_var[k]=cRequesters_var;
}

class MyDHTGetMessageDescriptor : public cClassDescriptor
{
  public:
    MyDHTGetMessageDescriptor();
    virtual ~MyDHTGetMessageDescriptor();

    virtual bool doesSupport(cObject *obj) const;
    virtual const char *getProperty(const char *propertyname) const;
    virtual int getFieldCount(void *object) const;
    virtual const char *getFieldName(void *object, int field) const;
    virtual int findField(void *object, const char *fieldName) const;
    virtual unsigned int getFieldTypeFlags(void *object, int field) const;
    virtual const char *getFieldTypeString(void *object, int field) const;
    virtual const char *getFieldProperty(void *object, int field, const char *propertyname) const;
    virtual int getArraySize(void *object, int field) const;

    virtual std::string getFieldAsString(void *object, int field, int i) const;
    virtual bool setFieldAsString(void *object, int field, int i, const char *value) const;

    virtual const char *getFieldStructName(void *object, int field) const;
    virtual void *getFieldStructPointer(void *object, int field, int i) const;
};

Register_ClassDescriptor(MyDHTGetMessageDescriptor);

MyDHTGetMessageDescriptor::MyDHTGetMessageDescriptor() : cClassDescriptor("MyDHTGetMessage", "cPacket")
{
}

MyDHTGetMessageDescriptor::~MyDHTGetMessageDescriptor()
{
}

bool MyDHTGetMessageDescriptor::doesSupport(cObject *obj) const
{
    return dynamic_cast<MyDHTGetMessage *>(obj)!=NULL;
}

const char *MyDHTGetMessageDescriptor::getProperty(const char *propertyname) const
{
    cClassDescriptor *basedesc = getBaseClassDescriptor();
    return basedesc ? basedesc->getProperty(propertyname) : NULL;
}

int MyDHTGetMessageDescriptor::getFieldCount(void *object) const
{
    cClassDescriptor *basedesc = getBaseClassDescriptor();
    return basedesc ? 8+basedesc->getFieldCount(object) : 8;
}

unsigned int MyDHTGetMessageDescriptor::getFieldTypeFlags(void *object, int field) const
{
    cClassDescriptor *basedesc = getBaseClassDescriptor();
    if (basedesc) {
        if (field < basedesc->getFieldCount(object))
            return basedesc->getFieldTypeFlags(object, field);
        field -= basedesc->getFieldCount(object);
    }
    static unsigned int fieldTypeFlags[] = {
        FD_ISCOMPOUND,
        FD_ISEDITABLE,
        FD_ISEDITABLE,
        FD_ISEDITABLE,
        FD_ISEDITABLE,
        FD_ISEDITABLE,
        FD_ISEDITABLE,
        FD_ISARRAY | FD_ISCOMPOUND,
    };
    return (field>=0 && field<8) ? fieldTypeFlags[field] : 0;
}

const char *MyDHTGetMessageDescriptor::getFieldName(void *object, int field) const
{
    cClassDescriptor *basedesc = getBaseClassDescriptor();
    if (basedesc) {
        if (field < basedesc->getFieldCount(object))
            return basedesc->getFieldName(object, field);
        field -= basedesc->getFieldCount(object);
    }
    static const char *fieldNames[] = {
        "key",
        "kind",
        "id",
        "groupId",
        "isHash",
        "nonce",
        "cache",
        "cRequesters",
    };
    return (field>=0 && field<8) ? fieldNames[field] : NULL;
}

int MyDHTGetMessageDescriptor::findField(void *object, const char *fieldName) const
{
    cClassDescriptor *basedesc = getBaseClassDescriptor();
    int base = basedesc ? basedesc->getFieldCount(object) : 0;
    if (fieldName[0]=='k' && strcmp(fieldName, "key")==0) return base+0;
    if (fieldName[0]=='k' && strcmp(fieldName, "kind")==0) return base+1;
    if (fieldName[0]=='i' && strcmp(fieldName, "id")==0) return base+2;
    if (fieldName[0]=='g' && strcmp(fieldName, "groupId")==0) return base+3;
    if (fieldName[0]=='i' && strcmp(fieldName, "isHash")==0) return base+4;
    if (fieldName[0]=='n' && strcmp(fieldName, "nonce")==0) return base+5;
    if (fieldName[0]=='c' && strcmp(fieldName, "cache")==0) return base+6;
    if (fieldName[0]=='c' && strcmp(fieldName, "cRequesters")==0) return base+7;
    return basedesc ? basedesc->findField(object, fieldName) : -1;
}

const char *MyDHTGetMessageDescriptor::getFieldTypeString(void *object, int field) const
{
    cClassDescriptor *basedesc = getBaseClassDescriptor();
    if (basedesc) {
        if (field < basedesc->getFieldCount(object))
            return basedesc->getFieldTypeString(object, field);
        field -= basedesc->getFieldCount(object);
    }
    static const char *fieldTypeStrings[] = {
        "OverlayKey",
        "uint32_t",
        "uint32_t",
        "int",
        "bool",
        "unsigned int",
        "bool",
        "NodeHandle",
    };
    return (field>=0 && field<8) ? fieldTypeStrings[field] : NULL;
}

const char *MyDHTGetMessageDescriptor::getFieldProperty(void *object, int field, const char *propertyname) const
{
    cClassDescriptor *basedesc = getBaseClassDescriptor();
    if (basedesc) {
        if (field < basedesc->getFieldCount(object))
            return basedesc->getFieldProperty(object, field, propertyname);
        field -= basedesc->getFieldCount(object);
    }
    switch (field) {
        default: return NULL;
    }
}

int MyDHTGetMessageDescriptor::getArraySize(void *object, int field) const
{
    cClassDescriptor *basedesc = getBaseClassDescriptor();
    if (basedesc) {
        if (field < basedesc->getFieldCount(object))
            return basedesc->getArraySize(object, field);
        field -= basedesc->getFieldCount(object);
    }
    MyDHTGetMessage *pp = (MyDHTGetMessage *)object; (void)pp;
    switch (field) {
        case 7: return pp->getCRequestersArraySize();
        default: return 0;
    }
}

std::string MyDHTGetMessageDescriptor::getFieldAsString(void *object, int field, int i) const
{
    cClassDescriptor *basedesc = getBaseClassDescriptor();
    if (basedesc) {
        if (field < basedesc->getFieldCount(object))
            return basedesc->getFieldAsString(object,field,i);
        field -= basedesc->getFieldCount(object);
    }
    MyDHTGetMessage *pp = (MyDHTGetMessage *)object; (void)pp;
    switch (field) {
        case 0: {std::stringstream out; out << pp->getKey(); return out.str();}
        case 1: return ulong2string(pp->getKind());
        case 2: return ulong2string(pp->getId());
        case 3: return long2string(pp->getGroupId());
        case 4: return bool2string(pp->getIsHash());
        case 5: return ulong2string(pp->getNonce());
        case 6: return bool2string(pp->getCache());
        case 7: {std::stringstream out; out << pp->getCRequesters(i); return out.str();}
        default: return "";
    }
}

bool MyDHTGetMessageDescriptor::setFieldAsString(void *object, int field, int i, const char *value) const
{
    cClassDescriptor *basedesc = getBaseClassDescriptor();
    if (basedesc) {
        if (field < basedesc->getFieldCount(object))
            return basedesc->setFieldAsString(object,field,i,value);
        field -= basedesc->getFieldCount(object);
    }
    MyDHTGetMessage *pp = (MyDHTGetMessage *)object; (void)pp;
    switch (field) {
        case 1: pp->setKind(string2ulong(value)); return true;
        case 2: pp->setId(string2ulong(value)); return true;
        case 3: pp->setGroupId(string2long(value)); return true;
        case 4: pp->setIsHash(string2bool(value)); return true;
        case 5: pp->setNonce(string2ulong(value)); return true;
        case 6: pp->setCache(string2bool(value)); return true;
        default: return false;
    }
}

const char *MyDHTGetMessageDescriptor::getFieldStructName(void *object, int field) const
{
    cClassDescriptor *basedesc = getBaseClassDescriptor();
    if (basedesc) {
        if (field < basedesc->getFieldCount(object))
            return basedesc->getFieldStructName(object, field);
        field -= basedesc->getFieldCount(object);
    }
    static const char *fieldStructNames[] = {
        "OverlayKey",
        NULL,
        NULL,
        NULL,
        NULL,
        NULL,
        NULL,
        "NodeHandle",
    };
    return (field>=0 && field<8) ? fieldStructNames[field] : NULL;
}

void *MyDHTGetMessageDescriptor::getFieldStructPointer(void *object, int field, int i) const
{
    cClassDescriptor *basedesc = getBaseClassDescriptor();
    if (basedesc) {
        if (field < basedesc->getFieldCount(object))
            return basedesc->getFieldStructPointer(object, field, i);
        field -= basedesc->getFieldCount(object);
    }
    MyDHTGetMessage *pp = (MyDHTGetMessage *)object; (void)pp;
    switch (field) {
        case 0: return (void *)(&pp->getKey()); break;
        case 7: return (void *)(&pp->getCRequesters(i)); break;
        default: return NULL;
    }
}

Register_Class(MyDHTGetResMessage);

MyDHTGetResMessage::MyDHTGetResMessage(const char *name, int kind) : cPacket(name,kind)
{
    this->isHash_var = 0;
    result_arraysize = 0;
    this->result_var = 0;
    this->nonce_var = 0;
    this->hopCount_var = 0;
    this->rtt_var = 0;
}

MyDHTGetResMessage::MyDHTGetResMessage(const MyDHTGetResMessage& other) : cPacket()
{
    setName(other.getName());
    result_arraysize = 0;
    this->result_var = 0;
    operator=(other);
}

MyDHTGetResMessage::~MyDHTGetResMessage()
{
    delete [] result_var;
}

MyDHTGetResMessage& MyDHTGetResMessage::operator=(const MyDHTGetResMessage& other)
{
    if (this==&other) return *this;
    cPacket::operator=(other);
    this->key_var = other.key_var;
    this->hashValue_var = other.hashValue_var;
    this->isHash_var = other.isHash_var;
    delete [] this->result_var;
    this->result_var = (other.result_arraysize==0) ? NULL : new ::DhtDumpEntry[other.result_arraysize];
    result_arraysize = other.result_arraysize;
    for (unsigned int i=0; i<result_arraysize; i++)
        this->result_var[i] = other.result_var[i];
    this->nonce_var = other.nonce_var;
    this->hopCount_var = other.hopCount_var;
    this->rtt_var = other.rtt_var;
    return *this;
}

void MyDHTGetResMessage::parsimPack(cCommBuffer *b)
{
    cPacket::parsimPack(b);
    doPacking(b,this->key_var);
    doPacking(b,this->hashValue_var);
    doPacking(b,this->isHash_var);
    b->pack(result_arraysize);
    doPacking(b,this->result_var,result_arraysize);
    doPacking(b,this->nonce_var);
    doPacking(b,this->hopCount_var);
    doPacking(b,this->rtt_var);
}

void MyDHTGetResMessage::parsimUnpack(cCommBuffer *b)
{
    cPacket::parsimUnpack(b);
    doUnpacking(b,this->key_var);
    doUnpacking(b,this->hashValue_var);
    doUnpacking(b,this->isHash_var);
    delete [] this->result_var;
    b->unpack(result_arraysize);
    if (result_arraysize==0) {
        this->result_var = 0;
    } else {
        this->result_var = new ::DhtDumpEntry[result_arraysize];
        doUnpacking(b,this->result_var,result_arraysize);
    }
    doUnpacking(b,this->nonce_var);
    doUnpacking(b,this->hopCount_var);
    doUnpacking(b,this->rtt_var);
}

OverlayKey& MyDHTGetResMessage::getKey()
{
    return key_var;
}

void MyDHTGetResMessage::setKey(const OverlayKey& key_var)
{
    this->key_var = key_var;
}

BinaryValue& MyDHTGetResMessage::getHashValue()
{
    return hashValue_var;
}

void MyDHTGetResMessage::setHashValue(const BinaryValue& hashValue_var)
{
    this->hashValue_var = hashValue_var;
}

bool MyDHTGetResMessage::getIsHash() const
{
    return isHash_var;
}

void MyDHTGetResMessage::setIsHash(bool isHash_var)
{
    this->isHash_var = isHash_var;
}

void MyDHTGetResMessage::setResultArraySize(unsigned int size)
{
    ::DhtDumpEntry *result_var2 = (size==0) ? NULL : new ::DhtDumpEntry[size];
    unsigned int sz = result_arraysize < size ? result_arraysize : size;
    for (unsigned int i=0; i<sz; i++)
        result_var2[i] = this->result_var[i];
    result_arraysize = size;
    delete [] this->result_var;
    this->result_var = result_var2;
}

unsigned int MyDHTGetResMessage::getResultArraySize() const
{
    return result_arraysize;
}

DhtDumpEntry& MyDHTGetResMessage::getResult(unsigned int k)
{
    if (k>=result_arraysize) throw cRuntimeError("Array of size %d indexed by %d", result_arraysize, k);
    return result_var[k];
}

void MyDHTGetResMessage::setResult(unsigned int k, const DhtDumpEntry& result_var)
{
    if (k>=result_arraysize) throw cRuntimeError("Array of size %d indexed by %d", result_arraysize, k);
    this->result_var[k]=result_var;
}

unsigned int MyDHTGetResMessage::getNonce() const
{
    return nonce_var;
}

void MyDHTGetResMessage::setNonce(unsigned int nonce_var)
{
    this->nonce_var = nonce_var;
}

uint32_t MyDHTGetResMessage::getHopCount() const
{
    return hopCount_var;
}

void MyDHTGetResMessage::setHopCount(uint32_t hopCount_var)
{
    this->hopCount_var = hopCount_var;
}

simtime_t MyDHTGetResMessage::getRtt() const
{
    return rtt_var;
}

void MyDHTGetResMessage::setRtt(simtime_t rtt_var)
{
    this->rtt_var = rtt_var;
}

class MyDHTGetResMessageDescriptor : public cClassDescriptor
{
  public:
    MyDHTGetResMessageDescriptor();
    virtual ~MyDHTGetResMessageDescriptor();

    virtual bool doesSupport(cObject *obj) const;
    virtual const char *getProperty(const char *propertyname) const;
    virtual int getFieldCount(void *object) const;
    virtual const char *getFieldName(void *object, int field) const;
    virtual int findField(void *object, const char *fieldName) const;
    virtual unsigned int getFieldTypeFlags(void *object, int field) const;
    virtual const char *getFieldTypeString(void *object, int field) const;
    virtual const char *getFieldProperty(void *object, int field, const char *propertyname) const;
    virtual int getArraySize(void *object, int field) const;

    virtual std::string getFieldAsString(void *object, int field, int i) const;
    virtual bool setFieldAsString(void *object, int field, int i, const char *value) const;

    virtual const char *getFieldStructName(void *object, int field) const;
    virtual void *getFieldStructPointer(void *object, int field, int i) const;
};

Register_ClassDescriptor(MyDHTGetResMessageDescriptor);

MyDHTGetResMessageDescriptor::MyDHTGetResMessageDescriptor() : cClassDescriptor("MyDHTGetResMessage", "cPacket")
{
}

MyDHTGetResMessageDescriptor::~MyDHTGetResMessageDescriptor()
{
}

bool MyDHTGetResMessageDescriptor::doesSupport(cObject *obj) const
{
    return dynamic_cast<MyDHTGetResMessage *>(obj)!=NULL;
}

const char *MyDHTGetResMessageDescriptor::getProperty(const char *propertyname) const
{
    cClassDescriptor *basedesc = getBaseClassDescriptor();
    return basedesc ? basedesc->getProperty(propertyname) : NULL;
}

int MyDHTGetResMessageDescriptor::getFieldCount(void *object) const
{
    cClassDescriptor *basedesc = getBaseClassDescriptor();
    return basedesc ? 7+basedesc->getFieldCount(object) : 7;
}

unsigned int MyDHTGetResMessageDescriptor::getFieldTypeFlags(void *object, int field) const
{
    cClassDescriptor *basedesc = getBaseClassDescriptor();
    if (basedesc) {
        if (field < basedesc->getFieldCount(object))
            return basedesc->getFieldTypeFlags(object, field);
        field -= basedesc->getFieldCount(object);
    }
    static unsigned int fieldTypeFlags[] = {
        FD_ISCOMPOUND,
        FD_ISCOMPOUND,
        FD_ISEDITABLE,
        FD_ISARRAY | FD_ISCOMPOUND,
        FD_ISEDITABLE,
        FD_ISEDITABLE,
        FD_ISEDITABLE,
    };
    return (field>=0 && field<7) ? fieldTypeFlags[field] : 0;
}

const char *MyDHTGetResMessageDescriptor::getFieldName(void *object, int field) const
{
    cClassDescriptor *basedesc = getBaseClassDescriptor();
    if (basedesc) {
        if (field < basedesc->getFieldCount(object))
            return basedesc->getFieldName(object, field);
        field -= basedesc->getFieldCount(object);
    }
    static const char *fieldNames[] = {
        "key",
        "hashValue",
        "isHash",
        "result",
        "nonce",
        "hopCount",
        "rtt",
    };
    return (field>=0 && field<7) ? fieldNames[field] : NULL;
}

int MyDHTGetResMessageDescriptor::findField(void *object, const char *fieldName) const
{
    cClassDescriptor *basedesc = getBaseClassDescriptor();
    int base = basedesc ? basedesc->getFieldCount(object) : 0;
    if (fieldName[0]=='k' && strcmp(fieldName, "key")==0) return base+0;
    if (fieldName[0]=='h' && strcmp(fieldName, "hashValue")==0) return base+1;
    if (fieldName[0]=='i' && strcmp(fieldName, "isHash")==0) return base+2;
    if (fieldName[0]=='r' && strcmp(fieldName, "result")==0) return base+3;
    if (fieldName[0]=='n' && strcmp(fieldName, "nonce")==0) return base+4;
    if (fieldName[0]=='h' && strcmp(fieldName, "hopCount")==0) return base+5;
    if (fieldName[0]=='r' && strcmp(fieldName, "rtt")==0) return base+6;
    return basedesc ? basedesc->findField(object, fieldName) : -1;
}

const char *MyDHTGetResMessageDescriptor::getFieldTypeString(void *object, int field) const
{
    cClassDescriptor *basedesc = getBaseClassDescriptor();
    if (basedesc) {
        if (field < basedesc->getFieldCount(object))
            return basedesc->getFieldTypeString(object, field);
        field -= basedesc->getFieldCount(object);
    }
    static const char *fieldTypeStrings[] = {
        "OverlayKey",
        "BinaryValue",
        "bool",
        "DhtDumpEntry",
        "unsigned int",
        "uint32_t",
        "simtime_t",
    };
    return (field>=0 && field<7) ? fieldTypeStrings[field] : NULL;
}

const char *MyDHTGetResMessageDescriptor::getFieldProperty(void *object, int field, const char *propertyname) const
{
    cClassDescriptor *basedesc = getBaseClassDescriptor();
    if (basedesc) {
        if (field < basedesc->getFieldCount(object))
            return basedesc->getFieldProperty(object, field, propertyname);
        field -= basedesc->getFieldCount(object);
    }
    switch (field) {
        default: return NULL;
    }
}

int MyDHTGetResMessageDescriptor::getArraySize(void *object, int field) const
{
    cClassDescriptor *basedesc = getBaseClassDescriptor();
    if (basedesc) {
        if (field < basedesc->getFieldCount(object))
            return basedesc->getArraySize(object, field);
        field -= basedesc->getFieldCount(object);
    }
    MyDHTGetResMessage *pp = (MyDHTGetResMessage *)object; (void)pp;
    switch (field) {
        case 3: return pp->getResultArraySize();
        default: return 0;
    }
}

std::string MyDHTGetResMessageDescriptor::getFieldAsString(void *object, int field, int i) const
{
    cClassDescriptor *basedesc = getBaseClassDescriptor();
    if (basedesc) {
        if (field < basedesc->getFieldCount(object))
            return basedesc->getFieldAsString(object,field,i);
        field -= basedesc->getFieldCount(object);
    }
    MyDHTGetResMessage *pp = (MyDHTGetResMessage *)object; (void)pp;
    switch (field) {
        case 0: {std::stringstream out; out << pp->getKey(); return out.str();}
        case 1: {std::stringstream out; out << pp->getHashValue(); return out.str();}
        case 2: return bool2string(pp->getIsHash());
        case 3: {std::stringstream out; out << pp->getResult(i); return out.str();}
        case 4: return ulong2string(pp->getNonce());
        case 5: return ulong2string(pp->getHopCount());
        case 6: return double2string(pp->getRtt());
        default: return "";
    }
}

bool MyDHTGetResMessageDescriptor::setFieldAsString(void *object, int field, int i, const char *value) const
{
    cClassDescriptor *basedesc = getBaseClassDescriptor();
    if (basedesc) {
        if (field < basedesc->getFieldCount(object))
            return basedesc->setFieldAsString(object,field,i,value);
        field -= basedesc->getFieldCount(object);
    }
    MyDHTGetResMessage *pp = (MyDHTGetResMessage *)object; (void)pp;
    switch (field) {
        case 2: pp->setIsHash(string2bool(value)); return true;
        case 4: pp->setNonce(string2ulong(value)); return true;
        case 5: pp->setHopCount(string2ulong(value)); return true;
        case 6: pp->setRtt(string2double(value)); return true;
        default: return false;
    }
}

const char *MyDHTGetResMessageDescriptor::getFieldStructName(void *object, int field) const
{
    cClassDescriptor *basedesc = getBaseClassDescriptor();
    if (basedesc) {
        if (field < basedesc->getFieldCount(object))
            return basedesc->getFieldStructName(object, field);
        field -= basedesc->getFieldCount(object);
    }
    static const char *fieldStructNames[] = {
        "OverlayKey",
        "BinaryValue",
        NULL,
        "DhtDumpEntry",
        NULL,
        NULL,
        NULL,
    };
    return (field>=0 && field<7) ? fieldStructNames[field] : NULL;
}

void *MyDHTGetResMessageDescriptor::getFieldStructPointer(void *object, int field, int i) const
{
    cClassDescriptor *basedesc = getBaseClassDescriptor();
    if (basedesc) {
        if (field < basedesc->getFieldCount(object))
            return basedesc->getFieldStructPointer(object, field, i);
        field -= basedesc->getFieldCount(object);
    }
    MyDHTGetResMessage *pp = (MyDHTGetResMessage *)object; (void)pp;
    switch (field) {
        case 0: return (void *)(&pp->getKey()); break;
        case 1: return (void *)(&pp->getHashValue()); break;
        case 3: return (void *)(&pp->getResult(i)); break;
        default: return NULL;
    }
}

Register_Class(MyDHTTtlTimer);

MyDHTTtlTimer::MyDHTTtlTimer(const char *name, int kind) : cMessage(name,kind)
{
    this->kind_var = 0;
    this->id_var = 0;
}

MyDHTTtlTimer::MyDHTTtlTimer(const MyDHTTtlTimer& other) : cMessage()
{
    setName(other.getName());
    operator=(other);
}

MyDHTTtlTimer::~MyDHTTtlTimer()
{
}

MyDHTTtlTimer& MyDHTTtlTimer::operator=(const MyDHTTtlTimer& other)
{
    if (this==&other) return *this;
    cMessage::operator=(other);
    this->key_var = other.key_var;
    this->kind_var = other.kind_var;
    this->id_var = other.id_var;
    return *this;
}

void MyDHTTtlTimer::parsimPack(cCommBuffer *b)
{
    cMessage::parsimPack(b);
    doPacking(b,this->key_var);
    doPacking(b,this->kind_var);
    doPacking(b,this->id_var);
}

void MyDHTTtlTimer::parsimUnpack(cCommBuffer *b)
{
    cMessage::parsimUnpack(b);
    doUnpacking(b,this->key_var);
    doUnpacking(b,this->kind_var);
    doUnpacking(b,this->id_var);
}

OverlayKey& MyDHTTtlTimer::getKey()
{
    return key_var;
}

void MyDHTTtlTimer::setKey(const OverlayKey& key_var)
{
    this->key_var = key_var;
}

uint32_t MyDHTTtlTimer::getKind() const
{
    return kind_var;
}

void MyDHTTtlTimer::setKind(uint32_t kind_var)
{
    this->kind_var = kind_var;
}

uint32_t MyDHTTtlTimer::getId() const
{
    return id_var;
}

void MyDHTTtlTimer::setId(uint32_t id_var)
{
    this->id_var = id_var;
}

class MyDHTTtlTimerDescriptor : public cClassDescriptor
{
  public:
    MyDHTTtlTimerDescriptor();
    virtual ~MyDHTTtlTimerDescriptor();

    virtual bool doesSupport(cObject *obj) const;
    virtual const char *getProperty(const char *propertyname) const;
    virtual int getFieldCount(void *object) const;
    virtual const char *getFieldName(void *object, int field) const;
    virtual int findField(void *object, const char *fieldName) const;
    virtual unsigned int getFieldTypeFlags(void *object, int field) const;
    virtual const char *getFieldTypeString(void *object, int field) const;
    virtual const char *getFieldProperty(void *object, int field, const char *propertyname) const;
    virtual int getArraySize(void *object, int field) const;

    virtual std::string getFieldAsString(void *object, int field, int i) const;
    virtual bool setFieldAsString(void *object, int field, int i, const char *value) const;

    virtual const char *getFieldStructName(void *object, int field) const;
    virtual void *getFieldStructPointer(void *object, int field, int i) const;
};

Register_ClassDescriptor(MyDHTTtlTimerDescriptor);

MyDHTTtlTimerDescriptor::MyDHTTtlTimerDescriptor() : cClassDescriptor("MyDHTTtlTimer", "cMessage")
{
}

MyDHTTtlTimerDescriptor::~MyDHTTtlTimerDescriptor()
{
}

bool MyDHTTtlTimerDescriptor::doesSupport(cObject *obj) const
{
    return dynamic_cast<MyDHTTtlTimer *>(obj)!=NULL;
}

const char *MyDHTTtlTimerDescriptor::getProperty(const char *propertyname) const
{
    cClassDescriptor *basedesc = getBaseClassDescriptor();
    return basedesc ? basedesc->getProperty(propertyname) : NULL;
}

int MyDHTTtlTimerDescriptor::getFieldCount(void *object) const
{
    cClassDescriptor *basedesc = getBaseClassDescriptor();
    return basedesc ? 3+basedesc->getFieldCount(object) : 3;
}

unsigned int MyDHTTtlTimerDescriptor::getFieldTypeFlags(void *object, int field) const
{
    cClassDescriptor *basedesc = getBaseClassDescriptor();
    if (basedesc) {
        if (field < basedesc->getFieldCount(object))
            return basedesc->getFieldTypeFlags(object, field);
        field -= basedesc->getFieldCount(object);
    }
    static unsigned int fieldTypeFlags[] = {
        FD_ISCOMPOUND,
        FD_ISEDITABLE,
        FD_ISEDITABLE,
    };
    return (field>=0 && field<3) ? fieldTypeFlags[field] : 0;
}

const char *MyDHTTtlTimerDescriptor::getFieldName(void *object, int field) const
{
    cClassDescriptor *basedesc = getBaseClassDescriptor();
    if (basedesc) {
        if (field < basedesc->getFieldCount(object))
            return basedesc->getFieldName(object, field);
        field -= basedesc->getFieldCount(object);
    }
    static const char *fieldNames[] = {
        "key",
        "kind",
        "id",
    };
    return (field>=0 && field<3) ? fieldNames[field] : NULL;
}

int MyDHTTtlTimerDescriptor::findField(void *object, const char *fieldName) const
{
    cClassDescriptor *basedesc = getBaseClassDescriptor();
    int base = basedesc ? basedesc->getFieldCount(object) : 0;
    if (fieldName[0]=='k' && strcmp(fieldName, "key")==0) return base+0;
    if (fieldName[0]=='k' && strcmp(fieldName, "kind")==0) return base+1;
    if (fieldName[0]=='i' && strcmp(fieldName, "id")==0) return base+2;
    return basedesc ? basedesc->findField(object, fieldName) : -1;
}

const char *MyDHTTtlTimerDescriptor::getFieldTypeString(void *object, int field) const
{
    cClassDescriptor *basedesc = getBaseClassDescriptor();
    if (basedesc) {
        if (field < basedesc->getFieldCount(object))
            return basedesc->getFieldTypeString(object, field);
        field -= basedesc->getFieldCount(object);
    }
    static const char *fieldTypeStrings[] = {
        "OverlayKey",
        "uint32_t",
        "uint32_t",
    };
    return (field>=0 && field<3) ? fieldTypeStrings[field] : NULL;
}

const char *MyDHTTtlTimerDescriptor::getFieldProperty(void *object, int field, const char *propertyname) const
{
    cClassDescriptor *basedesc = getBaseClassDescriptor();
    if (basedesc) {
        if (field < basedesc->getFieldCount(object))
            return basedesc->getFieldProperty(object, field, propertyname);
        field -= basedesc->getFieldCount(object);
    }
    switch (field) {
        default: return NULL;
    }
}

int MyDHTTtlTimerDescriptor::getArraySize(void *object, int field) const
{
    cClassDescriptor *basedesc = getBaseClassDescriptor();
    if (basedesc) {
        if (field < basedesc->getFieldCount(object))
            return basedesc->getArraySize(object, field);
        field -= basedesc->getFieldCount(object);
    }
    MyDHTTtlTimer *pp = (MyDHTTtlTimer *)object; (void)pp;
    switch (field) {
        default: return 0;
    }
}

std::string MyDHTTtlTimerDescriptor::getFieldAsString(void *object, int field, int i) const
{
    cClassDescriptor *basedesc = getBaseClassDescriptor();
    if (basedesc) {
        if (field < basedesc->getFieldCount(object))
            return basedesc->getFieldAsString(object,field,i);
        field -= basedesc->getFieldCount(object);
    }
    MyDHTTtlTimer *pp = (MyDHTTtlTimer *)object; (void)pp;
    switch (field) {
        case 0: {std::stringstream out; out << pp->getKey(); return out.str();}
        case 1: return ulong2string(pp->getKind());
        case 2: return ulong2string(pp->getId());
        default: return "";
    }
}

bool MyDHTTtlTimerDescriptor::setFieldAsString(void *object, int field, int i, const char *value) const
{
    cClassDescriptor *basedesc = getBaseClassDescriptor();
    if (basedesc) {
        if (field < basedesc->getFieldCount(object))
            return basedesc->setFieldAsString(object,field,i,value);
        field -= basedesc->getFieldCount(object);
    }
    MyDHTTtlTimer *pp = (MyDHTTtlTimer *)object; (void)pp;
    switch (field) {
        case 1: pp->setKind(string2ulong(value)); return true;
        case 2: pp->setId(string2ulong(value)); return true;
        default: return false;
    }
}

const char *MyDHTTtlTimerDescriptor::getFieldStructName(void *object, int field) const
{
    cClassDescriptor *basedesc = getBaseClassDescriptor();
    if (basedesc) {
        if (field < basedesc->getFieldCount(object))
            return basedesc->getFieldStructName(object, field);
        field -= basedesc->getFieldCount(object);
    }
    static const char *fieldStructNames[] = {
        "OverlayKey",
        NULL,
        NULL,
    };
    return (field>=0 && field<3) ? fieldStructNames[field] : NULL;
}

void *MyDHTTtlTimerDescriptor::getFieldStructPointer(void *object, int field, int i) const
{
    cClassDescriptor *basedesc = getBaseClassDescriptor();
    if (basedesc) {
        if (field < basedesc->getFieldCount(object))
            return basedesc->getFieldStructPointer(object, field, i);
        field -= basedesc->getFieldCount(object);
    }
    MyDHTTtlTimer *pp = (MyDHTTtlTimer *)object; (void)pp;
    switch (field) {
        case 0: return (void *)(&pp->getKey()); break;
        default: return NULL;
    }
}


