//
// Generated file, do not edit! Created by opp_msgc 4.1 from src/node/sensor/WiseSensorMessage.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 "WiseSensorMessage_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)));
}




EXECUTE_ON_STARTUP(
    cEnum *e = cEnum::find("WiseSensorMessageType");
    if (!e) enums.getInstance()->add(e = new cEnum("WiseSensorMessageType"));
    e->insert(SAMPLE, "SAMPLE");
    e->insert(UPDATE_COVERSETS, "UPDATE_COVERSETS");
    e->insert(ALERT, "ALERT");
    e->insert(SENSOR_READING, "SENSOR_READING");
    e->insert(MULTIMEDIA, "MULTIMEDIA");
);

Register_Class(WiseSensorMessage);

WiseSensorMessage::WiseSensorMessage(const char *name, int kind) : cMessage(name,kind)
{
    this->payload_var = 0;
    this->sensedValue_var = 0;
    this->sensorType_var = 0;
    this->sensorIndex_var = 0;
    this->typeFrame_var = 0;
    this->idFrame_var = 0;
    this->byteLength_var = 0;
    this->x_var = 0;
    this->y_var = 0;
}

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

WiseSensorMessage::~WiseSensorMessage()
{
}

WiseSensorMessage& WiseSensorMessage::operator=(const WiseSensorMessage& other)
{
    if (this==&other) return *this;
    cMessage::operator=(other);
    this->payload_var = other.payload_var;
    this->sensedValue_var = other.sensedValue_var;
    this->sensorType_var = other.sensorType_var;
    this->sensorIndex_var = other.sensorIndex_var;
    this->info_var = other.info_var;
    this->typeFrame_var = other.typeFrame_var;
    this->idFrame_var = other.idFrame_var;
    this->byteLength_var = other.byteLength_var;
    this->x_var = other.x_var;
    this->y_var = other.y_var;
    return *this;
}

void WiseSensorMessage::parsimPack(cCommBuffer *b)
{
    cMessage::parsimPack(b);
    doPacking(b,this->payload_var);
    doPacking(b,this->sensedValue_var);
    doPacking(b,this->sensorType_var);
    doPacking(b,this->sensorIndex_var);
    doPacking(b,this->info_var);
    doPacking(b,this->typeFrame_var);
    doPacking(b,this->idFrame_var);
    doPacking(b,this->byteLength_var);
    doPacking(b,this->x_var);
    doPacking(b,this->y_var);
}

void WiseSensorMessage::parsimUnpack(cCommBuffer *b)
{
    cMessage::parsimUnpack(b);
    doUnpacking(b,this->payload_var);
    doUnpacking(b,this->sensedValue_var);
    doUnpacking(b,this->sensorType_var);
    doUnpacking(b,this->sensorIndex_var);
    doUnpacking(b,this->info_var);
    doUnpacking(b,this->typeFrame_var);
    doUnpacking(b,this->idFrame_var);
    doUnpacking(b,this->byteLength_var);
    doUnpacking(b,this->x_var);
    doUnpacking(b,this->y_var);
}

double WiseSensorMessage::getPayload() const
{
    return payload_var;
}

void WiseSensorMessage::setPayload(double payload_var)
{
    this->payload_var = payload_var;
}

double WiseSensorMessage::getSensedValue() const
{
    return sensedValue_var;
}

void WiseSensorMessage::setSensedValue(double sensedValue_var)
{
    this->sensedValue_var = sensedValue_var;
}

const char * WiseSensorMessage::getSensorType() const
{
    return sensorType_var.c_str();
}

void WiseSensorMessage::setSensorType(const char * sensorType_var)
{
    this->sensorType_var = sensorType_var;
}

int WiseSensorMessage::getSensorIndex() const
{
    return sensorIndex_var;
}

void WiseSensorMessage::setSensorIndex(int sensorIndex_var)
{
    this->sensorIndex_var = sensorIndex_var;
}

TraceInfo& WiseSensorMessage::getInfo()
{
    return info_var;
}

void WiseSensorMessage::setInfo(const TraceInfo& info_var)
{
    this->info_var = info_var;
}

char WiseSensorMessage::getTypeFrame() const
{
    return typeFrame_var;
}

void WiseSensorMessage::setTypeFrame(char typeFrame_var)
{
    this->typeFrame_var = typeFrame_var;
}

int WiseSensorMessage::getIdFrame() const
{
    return idFrame_var;
}

void WiseSensorMessage::setIdFrame(int idFrame_var)
{
    this->idFrame_var = idFrame_var;
}

int WiseSensorMessage::getByteLength() const
{
    return byteLength_var;
}

void WiseSensorMessage::setByteLength(int byteLength_var)
{
    this->byteLength_var = byteLength_var;
}

double WiseSensorMessage::getX() const
{
    return x_var;
}

void WiseSensorMessage::setX(double x_var)
{
    this->x_var = x_var;
}

double WiseSensorMessage::getY() const
{
    return y_var;
}

void WiseSensorMessage::setY(double y_var)
{
    this->y_var = y_var;
}

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

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

WiseSensorMessageDescriptor::WiseSensorMessageDescriptor() : cClassDescriptor("WiseSensorMessage", "cMessage")
{
}

WiseSensorMessageDescriptor::~WiseSensorMessageDescriptor()
{
}

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

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

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

unsigned int WiseSensorMessageDescriptor::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_ISEDITABLE,
        FD_ISEDITABLE,
        FD_ISEDITABLE,
        FD_ISCOMPOUND,
        FD_ISEDITABLE,
        FD_ISEDITABLE,
        FD_ISEDITABLE,
        FD_ISEDITABLE,
        FD_ISEDITABLE,
    };
    return (field>=0 && field<10) ? fieldTypeFlags[field] : 0;
}

const char *WiseSensorMessageDescriptor::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[] = {
        "payload",
        "sensedValue",
        "sensorType",
        "sensorIndex",
        "info",
        "typeFrame",
        "idFrame",
        "byteLength",
        "x",
        "y",
    };
    return (field>=0 && field<10) ? fieldNames[field] : NULL;
}

int WiseSensorMessageDescriptor::findField(void *object, const char *fieldName) const
{
    cClassDescriptor *basedesc = getBaseClassDescriptor();
    int base = basedesc ? basedesc->getFieldCount(object) : 0;
    if (fieldName[0]=='p' && strcmp(fieldName, "payload")==0) return base+0;
    if (fieldName[0]=='s' && strcmp(fieldName, "sensedValue")==0) return base+1;
    if (fieldName[0]=='s' && strcmp(fieldName, "sensorType")==0) return base+2;
    if (fieldName[0]=='s' && strcmp(fieldName, "sensorIndex")==0) return base+3;
    if (fieldName[0]=='i' && strcmp(fieldName, "info")==0) return base+4;
    if (fieldName[0]=='t' && strcmp(fieldName, "typeFrame")==0) return base+5;
    if (fieldName[0]=='i' && strcmp(fieldName, "idFrame")==0) return base+6;
    if (fieldName[0]=='b' && strcmp(fieldName, "byteLength")==0) return base+7;
    if (fieldName[0]=='x' && strcmp(fieldName, "x")==0) return base+8;
    if (fieldName[0]=='y' && strcmp(fieldName, "y")==0) return base+9;
    return basedesc ? basedesc->findField(object, fieldName) : -1;
}

const char *WiseSensorMessageDescriptor::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",
        "double",
        "string",
        "int",
        "TraceInfo",
        "char",
        "int",
        "int",
        "double",
        "double",
    };
    return (field>=0 && field<10) ? fieldTypeStrings[field] : NULL;
}

const char *WiseSensorMessageDescriptor::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 WiseSensorMessageDescriptor::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);
    }
    WiseSensorMessage *pp = (WiseSensorMessage *)object; (void)pp;
    switch (field) {
        default: return 0;
    }
}

std::string WiseSensorMessageDescriptor::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);
    }
    WiseSensorMessage *pp = (WiseSensorMessage *)object; (void)pp;
    switch (field) {
        case 0: return double2string(pp->getPayload());
        case 1: return double2string(pp->getSensedValue());
        case 2: return oppstring2string(pp->getSensorType());
        case 3: return long2string(pp->getSensorIndex());
        case 4: {std::stringstream out; out << pp->getInfo(); return out.str();}
        case 5: return long2string(pp->getTypeFrame());
        case 6: return long2string(pp->getIdFrame());
        case 7: return long2string(pp->getByteLength());
        case 8: return double2string(pp->getX());
        case 9: return double2string(pp->getY());
        default: return "";
    }
}

bool WiseSensorMessageDescriptor::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);
    }
    WiseSensorMessage *pp = (WiseSensorMessage *)object; (void)pp;
    switch (field) {
        case 0: pp->setPayload(string2double(value)); return true;
        case 1: pp->setSensedValue(string2double(value)); return true;
        case 2: pp->setSensorType((value)); return true;
        case 3: pp->setSensorIndex(string2long(value)); return true;
        case 5: pp->setTypeFrame(string2long(value)); return true;
        case 6: pp->setIdFrame(string2long(value)); return true;
        case 7: pp->setByteLength(string2long(value)); return true;
        case 8: pp->setX(string2double(value)); return true;
        case 9: pp->setY(string2double(value)); return true;
        default: return false;
    }
}

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

void *WiseSensorMessageDescriptor::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);
    }
    WiseSensorMessage *pp = (WiseSensorMessage *)object; (void)pp;
    switch (field) {
        case 4: return (void *)(&pp->getInfo()); break;
        default: return NULL;
    }
}


