How to add a field to an existing class

Development related to the GMAT core and GUI

How to add a field to an existing class

Postby shughes » Thu Mar 25, 2010 7:39 pm

This is the basic set of steps to add a new field to an existing object:

  • Add new item to enumerated list with unique label in ObjectName.hpp before the *ParamCount (final) entry.
    According to style, use all upper case here with underscores separating words.
  • Add string to the PARAMETER_TEXT array with case identical to script name (in .cpp file).
    Enter in the same order that it appears in the enumeration.
  • Add data type to PARAMETER_TYPE array placing the type declaration in the (in .cpp file)
    Enter in the same order that it appears in the enumeration.
  • Add the variable to the class in .hpp file (usually as protected).
  • Add the parameter to GetxxxParameter and SetxxxParameter. (xxx is the data type name)
    ( this assumes that the method for the data type already exists). If the new field is an array, you need another
    access method.
  • Add range checks to SetXXXParameter. If not in range throw an exception using the standard messag in GMATBase.cpp.
  • If the parameter is not visible to user, must add to IsParameterReadOnly method in .cpp.
  • Initialize in constructors (copy and default) and Operator=.
  • If required, delete the field in the destructor.
  • If this is a pointer to an object, check for the appropriate type in SetRefObject
    and need to set up object name in GetRefObjectNameArray.
  • Create a script with your new parameter and test with valid and invalid inputs.
shughes
 
Posts: 443
Joined: Mon Jun 09, 2008 6:27 pm

Return to Core Development

Who is online

Users browsing this forum: No registered users and 1 guest

cron