Пример #1
0
/**
 * Sets the dimension type for this IndexBlockSet.
 * @param theType
 */
void IndexBlockSet::setType(adstring theType){
    type = theType;
    int p = theType.pos("_");
    if (p)  type = theType(1,p-1);//strip off type
    if (type==tcsam::STR_YEAR){
        modMin = ModelConfiguration::mnYr;
        modMax = ModelConfiguration::mxYr;
    } else
    if (type==tcsam::STR_SEX){
        modMin = 1;
        modMax = tcsam::nSXs;
    } else
    if (type==tcsam::STR_MATURITY_STATE){
        modMin = 1;
        modMax = tcsam::nMSs;
    } else
    if (type==tcsam::STR_SHELL_CONDITION){
        modMin = 1;
        modMax = tcsam::nSCs;
    } else 
    if (type==tcsam::STR_SIZE){
        modMin = 1;
        modMax = ModelConfiguration::nZBs;
    } else 
    if (type==tcsam::STR_FISHERY){
        modMin = 1;
        modMax = ModelConfiguration::nFsh;
    } else 
    if (type==tcsam::STR_SURVEY){
        modMin = 1;
        modMax = ModelConfiguration::nSrv;
    } else 
    {
        cout<<"WARNING...WARNING...WARNING..."<<endl;
        cout<<"Defining non-standard index type '"<<type<<"'."<<endl;
        cout<<"Make sure this is what you want."<<endl;
        cout<<"WARNING...WARNING...WARNING..."<<endl;
    }
    if (debug) cout<<"modMin = "<<modMin<<tb<<"modMax = "<<modMax<<endl;
}
Пример #2
0
/**
 * Parse a range string ("x:y" or "y") to obtain actual min, max for range.
 * If result finds x (y) < 0, then x (y) will be substituted using
 *  if x<0, x = modMin+1+x (so x=-1->x=modMin, x=-2->x=modMin-1, etc)
 *  if y<0, y = modMax-1-y (so y=-1->y=modMax, y=-2->y=modMax+1, etc)
 * @param str
 */
void IndexRange::parse(adstring str){
    if (debug) cout<<"IndexRange parse("<<str<<")"<<endl;
    int i = str.pos(":");
    if (debug) cout<<"':' located at position "<<i<<endl;
    if (i){
        mn = ::atoi(str(1,i-1));          
        if (mn<0){mn=modMin+1+mn;} else
        if (mn<modMin){mn=modMin;} else
        if (mn>modMax){mn=modMax;}
        mx = ::atoi(str(i+1,str.size())); 
        if (mx<0){mx=modMax-1-mx;} else
        if (mx<modMin){mx=modMin;} else
        if (mx>modMax){mx=modMax;}
    } else {
        mx = ::atoi(str);
        if (mx<0){mx=modMax-1-mx;} else
        if (mx<modMin){mx=modMin;} else
        if (mx>modMax){mx=modMax;}
        mn=mx;
    }
    if (debug) cout<<"mn,mx = "<<mn<<cc<<mx<<endl;
    createRangeVector(mn,mx);
}