Class CppGenerator

java.lang.Object
edu.nps.moves.dis7.source.generator.pdus.AbstractGenerator
edu.nps.moves.dis7.source.generator.pdus.CppGenerator

public class CppGenerator extends AbstractGenerator
PDU autogeneration supporting class.
  • Field Details

    • IVAR_PREFIX

      public static final String IVAR_PREFIX
      ivars are often preceded by a special character. This sets what that character is, so that instance variable names will be preceded by a "_".
      See Also:
  • Constructor Details

    • CppGenerator

      public CppGenerator(Map<String,GeneratedClass> pClassDescriptions, Properties pCppProperties)
      Constructor
      Parameters:
      pClassDescriptions - String Map of GeneratedClass
      pCppProperties - C++ properties
  • Method Details

    • writeClasses

      public void writeClasses()
      Generates the cpp source code classes
      Specified by:
      writeClasses in class AbstractGenerator
    • writeMacroFile

      public void writeMacroFile()
      Microsoft C++ requires a macro file to generate dlls. The preprocessor will import this and resolve it to an empty string in the gcc/unix world. In the Microsoft C++ world, the macro will resolve and do something useful about creating libraries.
    • writeHeaderFile

      public void writeHeaderFile(GeneratedClass aClass)
      Generate a c++ header file for the classes
      Parameters:
      aClass - class of interest
    • writeCppFile

      public void writeCppFile(GeneratedClass aClass)
      output file for this class
      Parameters:
      aClass - GeneratedClass to write file for
    • writeEqualityOperator

      public void writeEqualityOperator(PrintWriter pw, GeneratedClass aClass)
      Write the code for an equality operator.This allows you to compare two objects for equality.The code should look like bool operator ==(const ClassName& rhs) return (_ivar1==rhs._ivar1 && _var2 == rhs._ivar2 ...)
      Parameters:
      pw - output
      aClass - class of interest
    • writeMarshalMethod

      public void writeMarshalMethod(PrintWriter pw, GeneratedClass aClass)
      Write the code for a method that marshals out the object into a DIS format byte array.
      Parameters:
      pw - PrintWriter
      aClass - class of interest
    • writeUnmarshalMethod

      public void writeUnmarshalMethod(PrintWriter pw, GeneratedClass aClass)
      write out unmarshal method
      Parameters:
      pw - PrintWriter
      aClass - a GeneratedClass
    • writeSetterMethod

      public void writeSetterMethod(PrintWriter pw, GeneratedClass aClass, GeneratedClassAttribute anAttribute)
      write out setter method
      Parameters:
      pw - PrintWriter
      aClass - GeneratedClass
      anAttribute - a GeneratedClassAttribute
    • writeGetMarshalledSizeMethod

      public void writeGetMarshalledSizeMethod(PrintWriter pw, GeneratedClass aClass)
      output marshalled size
      Parameters:
      pw - PrintWriter to use
      aClass - a GeneratedClass
    • initialCapital

      public String initialCapital(String aString)
      returns a string with the first letter capitalized.
      Overrides:
      initialCapital in class AbstractGenerator
      Parameters:
      aString - of interest
      Returns:
      same string with first letter capitalized