Class CppGenerator
java.lang.Object
edu.nps.moves.dis7.source.generator.pdus.AbstractGenerator
edu.nps.moves.dis7.source.generator.pdus.CppGenerator
PDU autogeneration supporting class.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final String
ivars 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.void
Generates the cpp source code classesvoid
writeCppFile
(GeneratedClass aClass) output file for this classvoid
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 ...)void
writeGetMarshalledSizeMethod
(PrintWriter pw, GeneratedClass aClass) output marshalled sizevoid
writeHeaderFile
(GeneratedClass aClass) Generate a c++ header file for the classesvoid
Microsoft C++ requires a macro file to generate dlls.void
writeMarshalMethod
(PrintWriter pw, GeneratedClass aClass) Write the code for a method that marshals out the object into a DIS format byte array.void
writeSetterMethod
(PrintWriter pw, GeneratedClass aClass, GeneratedClassAttribute anAttribute) write out setter methodvoid
writeUnmarshalMethod
(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:
writeClasses
in 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:
initialCapital
in classAbstractGenerator
- Parameters:
aString
- of interest- Returns:
- same string with first letter capitalized
-