Changeset 203 for cpp


Ignore:
Timestamp:
04/02/14 16:17:01 (11 years ago)
Author:
Maciej Komosinski
Message:

The Geno object can be de/serialized

Location:
cpp/frams/vm/classes
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • cpp/frams/vm/classes/genoobj.cpp

    r197 r203  
    66#include <frams/util/extvalue.h>
    77#include <frams/model/autoname.h>
     8#include "collectionobj.h"
    89
    910#define FIELDSTRUCT GenoObj
    1011ParamEntry geno_paramtab[]=
    1112{
    12 {"Geno",1,12,"Geno","All information about a single genotype.\nThis is a genetics-only object which does not contain any performance data. See also: Genotype class"},
     13{"Geno",1,14,"Geno","All information about a single genotype.\nThis is a genetics-only object which does not contain any performance data. See also: Genotype class"},
    1314{"name",0,PARAM_NOSTATIC,"Name","s 0 40",GETSET(name),},
    1415{"rawgenotype",0,PARAM_NOSTATIC+PARAM_READONLY,"Raw genotype","s 1",GETONLY(genotype),"Genotype, excluding the format specifier"},
     
    2324{"newFrom",0,0,"create new object","p oGeno(s genotype,d format,s name,s description)",PROCEDURE(p_newfrom),},
    2425{"autoname",0,PARAM_NOSTATIC+PARAM_READONLY,"Autogenerated name","s",GETONLY(autoname),},
     26{"toVector",0,PARAM_READONLY+PARAM_NOSTATIC,"serialization support","oVector",GETONLY(toVector),},
     27{"newFromVector",0,0,"serialization support","p oGeno(oVector)",PROCEDURE(p_newfromvector),},
    2528{0,0,0,},
    2629};
     
    111114return (Geno*)v.getObjectTarget(getStaticParam().getName(), warn);
    112115}
     116
     117void GenoObj::get_toVector(ExtValue *ret)
     118{
     119VectorObject *vec=new VectorObject;
     120vec->data+=new ExtValue(shortString());
     121vec->data+=new ExtValue(getName());
     122vec->data+=new ExtValue(getComment());
     123ret->setObject(ExtObject(&VectorObject::par,vec));
     124}
     125
     126void GenoObj::p_newfromvector(ExtValue *args,ExtValue *ret)
     127{
     128VectorObject *vec=VectorObject::fromObject(args->getObject());
     129if (vec && (vec->data.size()>=3))
     130        {
     131        SString g=vec->get(0)?vec->get(0)->getString():"";
     132        SString n=vec->get(1)?vec->get(1)->getString():"";
     133        SString c=vec->get(2)?vec->get(2)->getString():"";
     134        *ret=makeDynamicObjectAndDecRef(new Geno(g,-1,n,c));
     135        }
     136else
     137        ret->setEmpty();
     138}
  • cpp/frams/vm/classes/genoobj.h

    r197 r203  
    2828PARAMPROCDEF(p_newfrom);
    2929PARAMPROCDEF(p_newfromstring);
     30PARAMPROCDEF(p_newfromvector);
     31PARAMGETDEF(toVector);
    3032#undef STATRICKCLASS
    3133
Note: See TracChangeset for help on using the changeset viewer.