Changeset 19220


Ignore:
Timestamp:
03/24/15 12:04:33 (10 years ago)
Author:
Eric.Larour
Message:

CHG: staying away from switch statements, which go erratic when providing them with enums that are very large.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • issm/trunk-jpl/src/c/datastructures/DataSet.cpp

    r19215 r19220  
    9292        int obj_enum;
    9393        int i;
    94        
     94
    9595        if(marshall_direction==MARSHALLING_FORWARD || marshall_direction==MARSHALLING_SIZE){
    9696                numsorted=objects.size();
     
    121121                        /*Recover enum of object first: */
    122122                        MARSHALLING_ENUM(obj_enum);
    123 
    124123                        /*Reset the file pointer to point again to the beginning of the object: */
    125124                        *pmarshalled_data-=sizeof(int);
     
    127126                        /*Giant case statement to spin-up the right object, and demarshall into it the information
    128127                         *stored in the buffer: */
    129                         switch(enum_type){
    130                                 case NodeEnum:{
     128                        if(obj_enum==NodeEnum){
    131129                                        Node* node=NULL;
    132130                                        node=new Node();
    133131                                        node->Marshall(pmarshalled_data,pmarshalled_data_size,marshall_direction);
    134                                         this->AddObject(node);}
    135                                         break;
    136                                 case VertexEnum:{
    137                                         Vertex* vertex=NULL;
    138                                         vertex=new Vertex();
    139                                         vertex->Marshall(pmarshalled_data,pmarshalled_data_size,marshall_direction);
    140                                         this->AddObject(vertex);}
    141                                         break;
    142                                 case DoubleParamEnum:{
    143                                         DoubleParam* doubleparam=NULL;
    144                                         doubleparam=new DoubleParam();
    145                                         doubleparam->Marshall(pmarshalled_data,pmarshalled_data_size,marshall_direction);
    146                                         this->AddObject(doubleparam);}
    147                                         break;
    148                                 case IntParamEnum:{
    149                                         IntParam* intparam=NULL;
    150                                         intparam=new IntParam();
    151                                         intparam->Marshall(pmarshalled_data,pmarshalled_data_size,marshall_direction);
    152                                         this->AddObject(intparam);}
    153                                         break;
    154                                 default:
    155                                         _error_("could not recognize enum type: " << EnumToStringx(enum_type));
     132                                        this->AddObject(node);
    156133                        }
     134                        else if(obj_enum==VertexEnum){
     135                                Vertex* vertex=NULL;
     136                                vertex=new Vertex();
     137                                vertex->Marshall(pmarshalled_data,pmarshalled_data_size,marshall_direction);
     138                                this->AddObject(vertex);
     139                                break;
     140                        }
     141                        else if(obj_enum==DoubleParamEnum){
     142                                DoubleParam* doubleparam=NULL;
     143                                doubleparam=new DoubleParam();
     144                                doubleparam->Marshall(pmarshalled_data,pmarshalled_data_size,marshall_direction);
     145                                this->AddObject(doubleparam);
     146                                break;
     147                        }
     148                        else if(obj_enum==IntParamEnum){
     149                                IntParam* intparam=NULL;
     150                                intparam=new IntParam();
     151                                intparam->Marshall(pmarshalled_data,pmarshalled_data_size,marshall_direction);
     152                                this->AddObject(intparam);
     153                                break;
     154                        }
     155                        else _error_("could not recognize enum type: " << obj_enum);
    157156                }
    158157        }
Note: See TracChangeset for help on using the changeset viewer.