Class CppGenerator
java.lang.Object
edu.nps.moves.dis7.source.generator.pdus.AbstractGenerator
edu.nps.moves.dis7.source.generator.pdus.CppGenerator
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Stringivars are often preceded by a special character.Fields inherited from class edu.nps.moves.dis7.source.generator.pdus.AbstractGenerator
classDescriptions, generatedSourceDirectoryName, languageProperties -
Constructor Summary
ConstructorsConstructorDescriptionCppGenerator(Map<String, GeneratedClass> pClassDescriptions, Properties pCppProperties) Constructor -
Method Summary
Modifier and TypeMethodDescriptioninitialCapital(String aString) returns a string with the first letter capitalized.voidGenerates the cpp source code classesvoidwriteCppFile(GeneratedClass aClass) output file for this classvoidwriteEqualityOperator(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 ...)voidwriteGetMarshalledSizeMethod(PrintWriter pw, GeneratedClass aClass) output marshalled sizevoidwriteHeaderFile(GeneratedClass aClass) Generate a c++ header file for the classesvoidMicrosoft C++ requires a macro file to generate dlls.voidwriteMarshalMethod(PrintWriter pw, GeneratedClass aClass) Write the code for a method that marshals out the object into a DIS format byte array.voidwriteSetterMethod(PrintWriter pw, GeneratedClass aClass, GeneratedClassAttribute anAttribute) write out setter methodvoidwriteUnmarshalMethod(PrintWriter pw, GeneratedClass aClass) write out unmarshal methodMethods inherited from class edu.nps.moves.dis7.source.generator.pdus.AbstractGenerator
createGeneratedSourceDirectory, getBitsToShift, getGeneratedSourceDirectoryName, initialLower, setGeneratedSourceDirectoryName
-
Field Details
-
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
Constructor- Parameters:
pClassDescriptions- String Map of GeneratedClasspCppProperties- C++ properties
-
-
Method Details
-
writeClasses
public void writeClasses()Generates the cpp source code classes- Specified by:
writeClassesin classAbstractGenerator
-
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
Generate a c++ header file for the classes- Parameters:
aClass- class of interest
-
writeCppFile
output file for this class- Parameters:
aClass- GeneratedClass to write file for
-
writeEqualityOperator
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- outputaClass- class of interest
-
writeMarshalMethod
Write the code for a method that marshals out the object into a DIS format byte array.- Parameters:
pw- PrintWriteraClass- class of interest
-
writeUnmarshalMethod
write out unmarshal method- Parameters:
pw- PrintWriteraClass- a GeneratedClass
-
writeSetterMethod
public void writeSetterMethod(PrintWriter pw, GeneratedClass aClass, GeneratedClassAttribute anAttribute) write out setter method- Parameters:
pw- PrintWriteraClass- GeneratedClassanAttribute- a GeneratedClassAttribute
-
writeGetMarshalledSizeMethod
output marshalled size- Parameters:
pw- PrintWriter to useaClass- a GeneratedClass
-
initialCapital
returns a string with the first letter capitalized.- Overrides:
initialCapitalin classAbstractGenerator- Parameters:
aString- of interest- Returns:
- same string with first letter capitalized
-