Appendices

 

Appendix A Code Examples

Appendix B Doxygen Commands

Appendix A: C++ Code Examples


 A.1 Example of a header file.

//$Id:$ //------------------------------------------------------------------------------ // EopFile //------------------------------------------------------------------------------ // GMAT: General Mission Analysis Tool. // // Copyright (c) 2002-2011 United States Government as represented by the // Administrator of The National Aeronautics and Space Administration. // All Other Rights Reserved. // // Developed jointly by NASA/GSFC and Thinking Systems, Inc. under // MOMS Task order 124. // // Author: Wendy C. Shoan/GSFC/MAB // Created: 2005/01/26 // /**

  • Definition of the EopFile class. This is the code that reads the polar*
  • motion information, as well as the UT1-UTC offset, from EOP file.

* *** *///------------------------------------------------------------------------------

#ifndefEopFile_hpp#defineEopFile_hpp
#include "gmatdefs.hpp"#include "Rmatrix.hpp"
namespaceGmatEop{enumEopFileType{EOP_C04,FINALS};};
class GMAT_API EopFile{public:// default constructorEopFile(conststd::string &fileName = "eopc04.62-now",GmatEop::EopFileTypeeop = GmatEop::EOP_C04);// copy constructorEopFile(constEopFile &eopF);// operator =constEopFile& operator=(constEopFile &eopF);// destructorvirtual ~EopFile();

// initializes the EopFile (reads it and stores the data)virtualvoid Initialize();
// method to return the name of the EOP filevirtualstd::string GetFileName() const;
// method to return the UT1-UTC offset for the given UTCMjdvirtual Real GetUt1UtcOffset(const Real utcMjd);
// method to return JD, X, Y, LOD data (for use by coordinate systems)virtualRmatrixGetPolarMotionData();// interpolate x, y, and lod to input timevirtualboolGetPolarMotionAndLod(Real forUtcMjd, Real &xval, Real &yval,Real &lodval);
protected:
staticconst Integer MAX_TABLE_SIZE;
GmatEop::EopFileTypeeopFType;std::stringeopFileName;Integer tableSz;
/// table of polar motion data : MJD, X, Y, LODRmatrix polarMotion;* /// vector of UT1-UTC offsets : MJD, offsetRmatrix ut1UtcOffsets;*
Real lastUtcJd;Real lastOffset;Integer lastIndex;
boolisInitialized;
boolIsBlank(constchar aLine);*
// Performance codeInteger previousIndex;
};#endif // EopFile_hpp A.2 Example of a source file.

//$Id:$//------------------------------------------------------------------------------// EopFile//------------------------------------------------------------------------------// GMAT: General Mission Analysis Tool.//// Copyright (c) 2002-2011 United States Government as represented by the// Administrator of The National Aeronautics and Space Administration.// All Other Rights Reserved.//// Developed jointly by NASA/GSFC and Thinking Systems, Inc. under// MOMS Task order 124.//// Author: Wendy C. Shoan// Created: 2005/01/26///**

 

  • Implementation of the EopFile class. This is the code that reads the polar*
  • motion information from EOP file.

* *** *///------------------------------------------------------------------------------

#include <iostream>#include <fstream>#include <sstream>#include <iomanip>#include "gmatdefs.hpp"#include "EopFile.hpp"#include "TimeTypes.hpp"#include "UtilityException.hpp"#include "RealUtilities.hpp"#include "MessageInterface.hpp"
//#define DEBUG_OFFSET//#define DEBUG_EOP_READ//#define DEBUG_EOP_INITIALIZE
//------------------------------------------------------------------------------// static data//------------------------------------------------------------------------------const Integer EopFile::MAX_TABLE_SIZE = 50405; // up to year >= 2100
//------------------------------------------------------------------------------// public methods//------------------------------------------------------------------------------
//---------------------------------------------------------------------------// EopFile(conststd::string &fileName,// GmatEop::EopFileTypeeop = GmatEop::EOP_C04);//---------------------------------------------------------------------------/**

 

  • Constructs base EopFile structures used in derived classes*

(default constructor).* ***

@param* fileNme EOP file name. *///---------------------------------------------------------------------------EopFile::EopFile(conststd::string &fileName, GmatEop::EopFileTypeeop) :eopFType (eop),eopFileName (fileName),tableSz (0),polarMotion (new Rmatrix(MAX_TABLE_SIZE,4)),ut1UtcOffsets (new Rmatrix(MAX_TABLE_SIZE,2)),lastUtcJd (0.0),lastOffset (0.0),lastIndex (0),isInitialized (false){}
//---------------------------------------------------------------------------// EopFile(constEopFile &eopF);//---------------------------------------------------------------------------/**

 

  • Constructs base EopFile structures, by copying*

the input instance (copy constructor).* ***

@param* eopFEopFile instance to copy to create "this" instance.*

*///---------------------------------------------------------------------------EopFile::EopFile(constEopFile &eopF) :eopFType (eopF.eopFType),eopFileName (eopF.eopFileName),tableSz (eopF.tableSz),polarMotion (new Rmatrix((eopF.polarMotion))),* ut1UtcOffsets (new Rmatrix((eopF.ut1UtcOffsets))),* lastUtcJd (eopF.lastUtcJd),lastOffset (eopF.lastOffset),lastIndex (eopF.lastIndex),isInitialized (eopF.isInitialized){}
//---------------------------------------------------------------------------// EopFile& operator=(constEopFile &eopF)//---------------------------------------------------------------------------/**

  • Assignment operator for EopFile structures.* ***

@param* eopF The original that is being copied. ***

@return Reference to this object* *///---------------------------------------------------------------------------constEopFile& EopFile::operator=(constEopFile &eopF){if (&eopF == this)return *this;eopFType = eopF.eopFType;eopFileName = eopF.eopFileName;tableSz = eopF.tableSz;deletepolarMotion;delete ut1UtcOffsets;polarMotion = new Rmatrix((eopF.polarMotion));* ut1UtcOffsets = new Rmatrix((eopF.ut1UtcOffsets));* lastUtcJd = eopF.lastUtcJd;lastOffset = eopF.lastOffset;lastIndex = eopF.lastIndex;isInitialized = eopF.isInitialized;return *this;}

//---------------------------------------------------------------------------// ~EopFile()//---------------------------------------------------------------------------/**

Destructor.* *///---------------------------------------------------------------------------EopFile::~EopFile(){deletepolarMotion;delete ut1UtcOffsets;}

//------------------------------------------------------------------------------// void Initialize()//------------------------------------------------------------------------------/**

This method initializes the EopFile class, by reading the file and*

storing the UT1-UTC offset and polar motion data.* *** *///------------------------------------------------------------------------------voidEopFile::Initialize(){#ifdef DEBUG_EOP_INITIALIZEMessageInterface::ShowMessage("Initializing EopFile: eopFileName = %s\n", eopFileName.c_str());#endifif (isInitialized) return;
…… (implementation details go here)…
isInitialized = true;}
//---------------------------------------------------------------------------// std::string GetFileName() const//---------------------------------------------------------------------------/**

Returns the name of the EOP file.* ***

@return name of the EOP file.* *///---------------------------------------------------------------------------std::string EopFile::GetFileName() const{returneopFileName;}

//---------------------------------------------------------------------------// Real GetUt1UtcOffset(const Real utcMjd)//---------------------------------------------------------------------------/**

Returns the UT1-UTC offset for the given utc* mjd. ***

@param* utcMjd Theutcmjd for which to return the offset. ***

@return UT1-UTC offset for the given time; values between table entries*

are interpolated linearly.* *///---------------------------------------------------------------------------Real EopFile::GetUt1UtcOffset(const Real utcMjd){if (!isInitialized) Initialize();
if (lastUtcJd == (utcMjd + GmatTimeConstants::JD_NOV_17_1858)) return lastOffset;
…… (implementation details go here)…
return off;}
//---------------------------------------------------------------------------// RmatrixGetPolarMotionData()//---------------------------------------------------------------------------/**

Returns the polar motion data.*

for each row: mjd, x, y* ***

@return polar motion data.* *///---------------------------------------------------------------------------RmatrixEopFile::GetPolarMotionData(){returnRmatrix(*polarMotion);}
//---------------------------------------------------------------------------// boolGetPolarMotionAndLod(Real forUtcMjd, Real &xval, Real &yval,// Real &lodval)//---------------------------------------------------------------------------/**

Returns the polar motion data X, Y, and LOD, for the input UTC MJD time.*

@param* forUtcMjd time for which to return the data

@param* xval return X value of polar motion data (arcsec)

@param* yval return Y value of polar motion data (arcsec)

@param* lodval return LOD value (seconds) ***

@return true, for successful computation; false otherwise* *///---------------------------------------------------------------------------boolEopFile::GetPolarMotionAndLod(Real forUtcMjd, Real &xval, Real &yval,Real &lodval){if (!isInitialized) Initialize();
…… (implementation details go here)…
return true;}
//------------------------------------------------------------------------------// boolIsBlank(char aLine)* //------------------------------------------------------------------------------/**

This method returns true if the string is empty or is all white space.* ***

@return flag indicating whether or not the input string is blank* *///------------------------------------------------------------------------------boolEopFile::IsBlank(const char aLine)* {Integer i;for (i=0;i<(int)strlen(aLine);i++){//loj: 5/18/04 if (!isblank(aLine[i])) return false;if (!isspace(aLine[i])) return false;}return true;}

Appendix B: Doxygen Commands

Below is a list of widely used commands with a description of their arguments. For a full list of all commands, refer to the Doxygen Documentation Section 21 Special Commands from http://www.stack.nl/~dimitri/doxygen/download.html#latestman.

 

  • @author {list of authors} Starts a paragraph where one or more author names may be entered.
  • @class <name> [<header-file>] [<header-name>] Indicates that a comment block contains documentation for a class with name. Optionally a header file and a header name can be specified.
  • @date {date description} Starts a paragraph where one or more dates may be entered.
  • @defgroup <name> (group title) Indicates that a comment block contains documentation for a group of classes, files or namespaces.
  • @endlink This command ends a link that is started with the @link command.
  • @enum <name> Indicates that a comment block contains documentation for an enumeration.
  • @example <file-name> Indicates that a comment block contains documentation for a source code example.
  • @exception <exception-object> {exception description} Starts an exception description for an exception object with name <exception-object>. Followed by a description of the exception.
  • @file [<name>] Indicates that a comment block contains documentation for a source or header file with name <name>.
  • @fn (function declaration) Indicates that a comment block contains documentation for a function (either global or as a member of a class).
  • @include <file-name> This command can be used to include a source file as a block of code. The command takes the name of an include file as an argument.
  • @interface <name> Indicates that a comment block contains documentation for an interface with name <name>.
  • @link <link-object> This command can be used to create a link to an object (a file, class, or member) with a user specified link-text. The link command should end with an @endlink command.
  • @name (header) This command turns a comment block into a header definition of a member group.
  • @namespace <name> Indicates that a comment block contains documentation for a namespace with name <name>.
  • @package <name> Indicates that a comment block contains documentation for a Java package with name <name>.
  • @param <parameter-name> {parameter description} Starts a parameter description for a function parameter with name <parameter-name>. Followed by a description of the parameter.
  • @return {description of the return value} Starts a return value description for a function.
  • @retval <return value> {description} Starts a return value description for a function with name <return value>. Followed by a description of the return value.
  • @struct <name> [<header-file>] [<header-name>] Indicates that a comment block contains documentation for a struct with name <name>.
  • @test {paragraph describing a test case} Starts a paragraph where a test case can be described.
  • @union <name> [<header-file>] [<header-name>] Indicates that a comment block contains documentation for a union with name <name>.
  • @var (variable declaration) Indicates that a comment block contains documentation for a variable or enum value (either global or as a member of a class).
  • @version {version number} Starts a paragraph where one or more version strings may be entered.
  • @warning {warning message} Starts a paragraph where one or more warning messages may be entered.
References
  • C Style Guide", Doland, J. et. al., SEL-94-003, Software Engineering Laboratory Series, Goddard Space Flight Center, August 1994.
  • Effective C++, Meyers. S., Addison-Wesley Professional Computing Series, 1992.
  • C++ Primer, 2nd Edition, Lippman, S., AT&T Bell Laboratories, 1991.
  • "Programming in C++ Rules and Recommendations", Henricson, M. and Nyquist, E., Ellemtel Telecommunication Systems Laboratories, 1990-1992.
  • C++ Style Guide, Version 1.0, Software and Automation Systems Branch, Goddard Space Flight Center, July 1992.
  • "C++ Programming Style Guides", Eckel, B., UNIX Review, March 1995.
  • "C++ Coding Standard", http://www.chris-lott.org/resources/cstyle/CppCodingStandard.html.