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

# /Users/fpy/titan-1-5-MBARI/Mers/Models/CCA/Io/Mof/MOFReader.h

    00001
    00002 //
    00003 // Copyright (c) 2004           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 //
    00009 // Organization:        Model-based Embedded and Robotic Systems Group
    00010 //                                      Massachusetts Institute of Technology
    00011 //
    00013
    00014 #ifndef MOFREADER_HEADER_FILE
    00015 #define MOFREADER_HEADER_FILE
    00016
    00017 #include <Mers/Models/CCA/CCAModel.h>
    00018 #ifndef EMBEDDED
    00019 #include <stdio.h>
    00020 #endif
    00021
    00022 #define CCATextFileType 0x1000
    00023
    00024 namespace Mers {
    00025         namespace Models {
    00026                 namespace CCA {
    00027                         namespace Io {
    00028                                 namespace Mof {
    00029
    00030                                         class MOFReader {
    00031                                         public:
    00032
    00038                                                 enum CCAFileType { CCABinary001 = 0x0001,
    00039                                                                                                                          CCABinaryLatest = CCABinary001,
    00040                                                                                                                          CCAText001 = 0x0001 | CCATextFileType,
    00041                                                                                                                          CCAText002 = 0x0002 | CCATextFileType,
    00042                                                                                                                          CCATextLatest = CCAText002};
    00043
    00044 #ifndef EMBEDDED
    00045
    00059                                                 static int loadMOF(const char * filename, Mers::Models::CCA::CCAModel & mdl);
    00076                                                 static int loadMOF(const char * filename, Mers::Models::CCA::CCAModel * &mdl);
    00077 #endif
    00078
    00094                                                 static int loadMOFFromString(char const * fileString, Mers::Models::CCA::CCAModel &mdl);
    00111                                                 static int loadMOFFromString(char const * fileString, Mers::Models::CCA::CCAModel * &mdl);
    00112
    00113 #ifndef EMBEDDED
    00114
    00131                                                 static int saveCCAModel(const char * filename, CCAFileType saveType, Mers::Models::CCA::CCAModel const &mdl);
    00148                                                 static int saveCCAModel(FILE * file, char const * fileName, CCAFileType saveType, Mers::Models::CCA::CCAModel const &mdl);
    00149 #endif
    00150
    00160                                                 static char const * ccaFileTypeToString(CCAFileType fileType);
    00161
    00169                                                 static bool isTextFileFormat(CCAFileType fileType);
    00170
    00171                                         protected:
    00180                                                 static char const * getCCAFileHeader(CCAFileType fileType);
    00181
    00182 #ifndef EMBEDDED
    00183
    00194                                                 static int writeText002(FILE * file, char const * fileName, char const * headerString, Mers::Models::CCA::CCAModel const &model);
    00195
    00207                                                 static int writeTextConstraint(FILE * file, CCASentence const &constraint,
    00208                                                                                                                                                                          char const * clauseSeperator = " ");
    00209
    00219                                                 static int writeTextConstraint(FILE * file, CCAClause const &constraint);
    00220
    00230                                                 static int writeTextConstraint(FILE * file, CCAAssignment const &constraint);
    00231
    00252                                                 static int writeSizedString(FILE * file, char const * str);
    00253
    00279                                                 static int writeIndexSizedValue(FILE * file, unsigned char indexSize, unsigned int value);
    00280
    00294                                                 static int writeConstraint(FILE * file, unsigned int indexSize, CCASentence const * constraint);
    00295
    00310                                                 static int writeConstraint(FILE * file, unsigned int indexSize, CCAClause const * constraint);
    00311
    00326                                                 static int writeAssignment(FILE * file, unsigned int indexSize, CCAAssignment const * assign);
    00327
    00342                                                 static int writeFloat(FILE * file, float value);
    00343 #endif
    00344
    00365                                                 static int readIndexSizedValue(char const * &fileString, unsigned int fileLen,
    00366                                                                                                                                                                          unsigned char indexSize, unsigned int &value);
    00367
    00388                                                 static int readSizedString(char const * &fileString, unsigned int fileLen, char * &str);
    00389
    00410                                                 static int readConstraint(char const * &fileString, unsigned int fileLen, unsigned int indexSize,
    00411                                                                                                                                                         Mers::Models::CCA::CCAModel &mdl, CCASentence * &constraint);
    00412
    00431                                                 static int readConstraint(char const * &fileString, unsigned int fileLen, unsigned int indexSize,
    00432                                                                                                                                                         Mers::Models::CCA::CCAModel &mdl, CCAClause * &constraint);
    00433
    00450                                                 static int readAssignment(char const * &fileString, unsigned int fileLen, unsigned int indexSize,
    00451                                                                                                                                                         Mers::Models::CCA::CCAModel &mdl, CCAAssignment * &assign);
    00452
    00469                                                 static int readFloat(char const * &fileString, unsigned int fileLen, float &value);
    00470
    00490                                                 static int readInt(char const * &fileString, unsigned int fileLen,
    00491                                                                                                                          unsigned int numBytes, unsigned int &value);
    00492                                         };
    00493                                 }
    00494                         }
    00495                 }
    00496         }
    00497 }
    00498
    00499 #endif
    00500