- Main Page
- Namespaces
- Classes
- Files
- Related Pages

# /Users/fpy/titan-1-5-MBARI/Mers/Models/Base/Io/SaveLoad/AssignmentSerializer.cpp

    00001
    00002 //
    00003 // Copyright (c) 2005           Model-based Embedded and Robotic Systems Group
    00004 // All Rights Reserved          Massachusetts Institute of Technology
    00005 //
    00006 // This software is provided as is. Model-based Embedded and Robotic Systems
    00007 // (MERS) group does not assume any responsibility.
    00008 //
    00010
    00012 // This file implements the BaseModelAssignment portion of the
    00013 // Serializer class.
    00015
    00016 #include "Serializer.h"
    00017 #include <Mers/Utils/Io/SaveLoad/ISaveLoad.h>
    00018 #include <Mers/Models/Base/BaseModel.h>
    00019 #include <Mers/Models/Base/BaseModelAssignment.h>
    00020 #include <Mers/Utils/Lang/String.h>
    00021 #include <cassert>
    00022
    00024
    00025 using namespace Mers::Models::Base::Io::SaveLoad;
    00026 using Mers::Utils::Io::SaveLoad::ISaveLoad;
    00027 using Mers::Models::Base::BaseModel;
    00028 using Mers::Models::Base::BaseModelAssignment;
    00029 using Mers::Utils::Lang::String;
    00030
    00032
    00033 void Serializer::saveLoad( ISaveLoad * sl, const char *,
    00034         BaseModelAssignment * &assign )
    00035 {
    00036         String variable, value, opName;
    00037
    00038         // Get the data from the variable.
    00039         if( sl->isSaving() ) {
    00040                 assert( assign != NULL );
    00041                 variable = assign->getVariable()->getName();
    00042                 value = assign->getValue()->getName();
    00043                 opName = BaseModelAssignment::operatorToSymbolString(
    00044                                                                                                                          assign->getOperator() );
    00045         }
    00046
    00047         // save/load the data.
    00048         sl->saveLoad( "variable", variable );
    00049         sl->saveLoad( "value", value );
    00050         sl->saveLoad( "operator", opName );
    00051
    00052         // If loading, construct the BaseModelAssignment from the data.
    00053         if( sl->isLoading() ) {
    00054                 BaseModelAssignment::OperatorType opType =
    00055                         BaseModelAssignment::symbolStringToOperator( opName );
    00056
    00057                 assert( m_model != NULL );
    00058
    00059                 assign = m_model->getAssignment( variable, value, opType );
    00060                 assert( assign != NULL );
    00061         }
    00062 }
    00063
    00065