If -genFactoryoption is specified and C++ code generation is selected, a Factory class definition is generated. The class contains a constructor for initialization of member variables. Method declarations will also be generated instead of C function prototypes for decoding, validating and printing.
A sample section from sample CSTA C++ header file is as follows:
class EXTERN CSTA_Factory { protected: /** * The mpContext member variable holds a reference-counted C runtime * variable. This context is used in calls to all C run-time functions. The * context pointed at by this smart-pointer object is shared with the * message buffer object contained within this class. */ OSRTCtxtPtr mpContext; /** * The mpMsgBuf member variable is a pointer to a derived message buffer or * stream class that will manage the message being decoded. */ OSRTMessageBufferIF* mpMsgBuf; public: CSTA_Factory () : mpContext (new OSRTContext()), mpMsgBuf (0) {} CSTA_Factory (OSRTMessageBufferIF& msgbuf) : mpMsgBuf(&msgbuf) { mpContext = msgbuf.getContext(); } ~CSTA_Factory () {} /** * The getCtxtPtr method returns the underlying C runtime context. This * context can be used in calls to C runtime functions. */ inline OSCTXT* getCtxtPtr () { return (!mpContext.isNull ()) ? mpContext->getPtr() : 0; } // element tags enum { T_cause = 1, T_consultOptions = 2, T_servicesPermitted = 3, ... } ; #define Num_Global_Elem_CSTA_Project 19 OSUINT16 t; union { /* t = 1 */ cause_CC *cause; /* t = 2 */ consultOptions_CC *consultOptions; /* t = 3 */ servicesPermitted_CC *servicesPermitted; ... } u; /** * Decode factory function. This function * decodes complete XML document when the message type * is unknown. */ int decode (); /** * Validate factory function. This function * validates complete XML document when the message type * is unknown. */ int validate (); void print (const char* name); /** * This method tests to see if the cause * element is selected. * @return TRUE if selected; FALSE otherwise. */ inline OSBOOL is_cause () { return (t == T_cause); } /** * This method tests to see if the consultOptions * element is selected. * @return TRUE if selected; FALSE otherwise. */ inline OSBOOL is_consultOptions () { return (t == T_consultOptions); } /** * This method tests to see if the servicesPermitted * element is selected. * @return TRUE if selected; FALSE otherwise. */ inline OSBOOL is_servicesPermitted () { return (t == T_servicesPermitted); } ... } ;