trick/trick_source/codegen/Interface_Code_Gen/PrintFileContentsBase.hh
ninotarantino 91a348d7e0
Fix several ICG class template bugs (#1871)
* Fix several bugs with processing templates in ICG

- Fixed an issue where io_src code for some templates was being placed in the
  wrong file.
- Fixed an issue with templates being instantiated with templates as parameters.
- Fixed an issue with templates that instantiate templates.

Added additional tests to cover these cases.

* Moved the list of template argument header dependencies from ClassValues to PrintFileContents10 so they can be printed to the io_ file regardless of the order in which class info is printed.

* Moved the list of template argument header dependencies from ClassValues to PrintFileContents10 so they can be printed to the io_ file regardless of the order in which class info is printed.

Moved the list of template argument header dependencies from ClassValues to PrintFileContents10 so they can be printed to the io_ file regardless of the order in which class info is printed.

* Added support to handle template enum class type argument and removed some commented code.

Added support to handle template enum class type argument and removed some commented code.

---------

Co-authored-by: Hong Chen <hchen99@users.noreply.github.com>
2025-04-29 15:30:49 -05:00

67 lines
2.2 KiB
C++

#ifndef PRINTFILECONTENTSBASE_HH
#define PRINTFILECONTENTSBASE_HH
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
class ConstructValues ;
class ClassValues ;
class EnumValues ;
class FieldDescription ;
/**
This class prints Trick 10 style io_src code. Given a vector of class information,
this class determines the io_src code file names, excluding files in system directories,
and writes out the attributes.
@author Alexander S. Lin
@date July 2012
*/
class PrintFileContentsBase {
public:
PrintFileContentsBase() ;
virtual void printIOHeader(std::ostream & ostream, std::string header_file_name) = 0 ;
virtual void printClass(std::ostream & ostream, ClassValues * cv) = 0 ;
virtual void printEnum(std::ostream & ostream, EnumValues * ev) = 0 ;
// these routines provide default empty implementation
virtual void printClassMapHeader(std::ostream & ostream, std::string function_name ) ;
virtual void printClassMap(std::ostream & ostream, ClassValues * cv) ;
virtual void printClassMapFooter(std::ostream & ostream) ;
virtual void printEnumMapHeader(std::ostream & ostream, std::string function_name ) ;
virtual void printEnumMap(std::ostream & ostream, EnumValues * ev) ;
virtual void printEnumMapFooter(std::ostream & ostream) ;
/* gets a vector of fields that can be printed */
std::vector<FieldDescription*> getPrintableFields(ClassValues& classValues, unsigned int ioMask = 0xFFFFFFF);
/** stores template argument header dependencies to be printed */
virtual void addTemplateArgumentHeaderDependency(const std::string& header, const std::string& dependency) = 0;
protected:
/** Prints the io_src_allocate function */
virtual void print_units_map(std::ostream & ostream, ClassValues * cv) ;
/** Prints "extern \"C\" {" */
void print_open_extern_c(std::ostream & ostream) ;
/** Prints "} // extern C" */
void print_close_extern_c(std::ostream & ostream) ;
/* internal function determines if a particular field is printable */
bool isPrintable(ClassValues * c , FieldDescription *fdes , unsigned int ioMask = 0xFFFFFFF) ;
} ;
#endif