//
// Generated file, do not edit! Created by opp_msgc 4.1 from src/world/physicalProcess/WisePhysicalProcessMessage.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 "WisePhysicalProcessMessage_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(WisePhysicalProcessMessage);

WisePhysicalProcessMessage::WisePhysicalProcessMessage(const char *name, int kind) : PhysicalProcessMessage(name,kind)
{
    this->zCoor_var = 0;
    vec_value_arraysize = 0;
    this->vec_value_var = 0;
}

WisePhysicalProcessMessage::WisePhysicalProcessMessage(const WisePhysicalProcessMessage& other) : PhysicalProcessMessage()
{
    setName(other.getName());
    vec_value_arraysize = 0;
    this->vec_value_var = 0;
    operator=(other);
}

WisePhysicalProcessMessage::~WisePhysicalProcessMessage()
{
    delete [] vec_value_var;
}

WisePhysicalProcessMessage& WisePhysicalProcessMessage::operator=(const WisePhysicalProcessMessage& other)
{
    if (this==&other) return *this;
    PhysicalProcessMessage::operator=(other);
    this->zCoor_var = other.zCoor_var;
    delete [] this->vec_value_var;
    this->vec_value_var = (other.vec_value_arraysize==0) ? NULL : new unsigned char[other.vec_value_arraysize];
    vec_value_arraysize = other.vec_value_arraysize;
    for (unsigned int i=0; i<vec_value_arraysize; i++)
        this->vec_value_var[i] = other.vec_value_var[i];
    return *this;
}

void WisePhysicalProcessMessage::parsimPack(cCommBuffer *b)
{
    PhysicalProcessMessage::parsimPack(b);
    doPacking(b,this->zCoor_var);
    b->pack(vec_value_arraysize);
    doPacking(b,this->vec_value_var,vec_value_arraysize);
}

void WisePhysicalProcessMessage::parsimUnpack(cCommBuffer *b)
{
    PhysicalProcessMessage::parsimUnpack(b);
    doUnpacking(b,this->zCoor_var);
    delete [] this->vec_value_var;
    b->unpack(vec_value_arraysize);
    if (vec_value_arraysize==0) {
        this->vec_value_var = 0;
    } else {
        this->vec_value_var = new unsigned char[vec_value_arraysize];
        doUnpacking(b,this->vec_value_var,vec_value_arraysize);
    }
}

double WisePhysicalProcessMessage::getZCoor() const
{
    return zCoor_var;
}

void WisePhysicalProcessMessage::setZCoor(double zCoor_var)
{
    this->zCoor_var = zCoor_var;
}

void WisePhysicalProcessMessage::setVec_valueArraySize(unsigned int size)
{
    unsigned char *vec_value_var2 = (size==0) ? NULL : new unsigned char[size];
    unsigned int sz = vec_value_arraysize < size ? vec_value_arraysize : size;
    for (unsigned int i=0; i<sz; i++)
        vec_value_var2[i] = this->vec_value_var[i];
    for (unsigned int i=sz; i<size; i++)
        vec_value_var2[i] = 0;
    vec_value_arraysize = size;
    delete [] this->vec_value_var;
    this->vec_value_var = vec_value_var2;
}

unsigned int WisePhysicalProcessMessage::getVec_valueArraySize() const
{
    return vec_value_arraysize;
}

unsigned char WisePhysicalProcessMessage::getVec_value(unsigned int k) const
{
    if (k>=vec_value_arraysize) throw cRuntimeError("Array of size %d indexed by %d", vec_value_arraysize, k);
    return vec_value_var[k];
}

void WisePhysicalProcessMessage::setVec_value(unsigned int k, unsigned char vec_value_var)
{
    if (k>=vec_value_arraysize) throw cRuntimeError("Array of size %d indexed by %d", vec_value_arraysize, k);
    this->vec_value_var[k]=vec_value_var;
}

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

    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(WisePhysicalProcessMessageDescriptor);

WisePhysicalProcessMessageDescriptor::WisePhysicalProcessMessageDescriptor() : cClassDescriptor("WisePhysicalProcessMessage", "PhysicalProcessMessage")
{
}

WisePhysicalProcessMessageDescriptor::~WisePhysicalProcessMessageDescriptor()
{
}

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

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

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

unsigned int WisePhysicalProcessMessageDescriptor::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,
        FD_ISARRAY | FD_ISEDITABLE,
    };
    return (field>=0 && field<2) ? fieldTypeFlags[field] : 0;
}

const char *WisePhysicalProcessMessageDescriptor::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[] = {
        "zCoor",
        "vec_value",
    };
    return (field>=0 && field<2) ? fieldNames[field] : NULL;
}

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

const char *WisePhysicalProcessMessageDescriptor::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[] = {
        "double",
        "unsigned char",
    };
    return (field>=0 && field<2) ? fieldTypeStrings[field] : NULL;
}

const char *WisePhysicalProcessMessageDescriptor::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 WisePhysicalProcessMessageDescriptor::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);
    }
    WisePhysicalProcessMessage *pp = (WisePhysicalProcessMessage *)object; (void)pp;
    switch (field) {
        case 1: return pp->getVec_valueArraySize();
        default: return 0;
    }
}

std::string WisePhysicalProcessMessageDescriptor::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);
    }
    WisePhysicalProcessMessage *pp = (WisePhysicalProcessMessage *)object; (void)pp;
    switch (field) {
        case 0: return double2string(pp->getZCoor());
        case 1: return ulong2string(pp->getVec_value(i));
        default: return "";
    }
}

bool WisePhysicalProcessMessageDescriptor::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);
    }
    WisePhysicalProcessMessage *pp = (WisePhysicalProcessMessage *)object; (void)pp;
    switch (field) {
        case 0: pp->setZCoor(string2double(value)); return true;
        case 1: pp->setVec_value(i,string2ulong(value)); return true;
        default: return false;
    }
}

const char *WisePhysicalProcessMessageDescriptor::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,
        NULL,
    };
    return (field>=0 && field<2) ? fieldStructNames[field] : NULL;
}

void *WisePhysicalProcessMessageDescriptor::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);
    }
    WisePhysicalProcessMessage *pp = (WisePhysicalProcessMessage *)object; (void)pp;
    switch (field) {
        default: return NULL;
    }
}


