[Enterprise Extensions only]
Previous topic Next topic

Adding declarations to a CORBA servant class definition (servant.ih)

Use this task to add declarations for class variables, constructors, and destructors for a CORBA servant class to its skeleton implementation header file, servant.ih. This defines any private variables for the implementation code in the associated servant_I.cpp file.

This task follows on from the task to compile the servant.idl file that defines the public interface for the server implementation class. For more information about compiling the IDL file, which creates the servant.ih file, see Compiling the servant IDL (using idlc).

To add declarations for class variables, constructors, and destructors to an implementation header file,servant.ih, complete the following steps:

  1. At a command line change to the directory that contains the servant.ih file, where servant is the name of the servant class.
  2. Edit the implementation header file, servant.ih, to add appropriate declarations for class variables, constructors, and destructors. For more information about the types of declarations that you can add to an implementation header file, see IDL type declarations.
    For example, the idlc command idlc -ehh:ih:ic:uc:sc -mdllname=WSLogger WSLogger.idl converted the following interface declaration to the class declaration in the WSLogger.ih file. The WSLogger.ih file was then edited to add the extra declarations shown in bold.

    Example: WSLogger interface and declarations added to the skeleton implementation header

    Interface declaration in WSLogger.idl Implementation header in WSLogger.ih
     interface WSLogger {
       void setFileName(in string newFileName);
       string getFileName();
       void setMethodName( in string newMethodName );
       string getMethodName();
       short openLogFile();
       short closeLogFile();
       short writeLogMessage(in string newMessage, in short newSeverity);
       const short DMY_DATE_FORMAT = 1;
       const short MDY_DATE_FORMAT = 2;
       void setDateFormat(in unsigned short newDateFormat);
       unsigned short getDateFormat();
     };
    
     class WSLogger_Impl : public virtual ::WSLogger_Skeleton {
         public:
          ::CORBA::Void setFileName (const char* newFileName);  
          char*  getFileName ();
          ::CORBA::Void setMethodName (const char* newMethodName);
          char*  getMethodName ();
          ::CORBA::Short openLogFile ();
          ::CORBA::Short closeLogFile ();
          ::CORBA::Short writeLogMessage (const char* newMessage, ::CORBA::Short newSeverity);
          ::CORBA::Void setDateFormat (::CORBA::UShort newDateFormat);
          ::CORBA::UShort getDateFormat ();  
    
        private:
          char * fileName;
          char * methodName;
          ::CORBA::UShort dateFormat;
          ofstream logFile;      
          ::CORBA::UShort logFileOpen;
        public:  
          WSLogger_Impl( char * newFileName );
          virtual ~WSLogger_Impl(); 
    
     };
    


You can next add code to skeleton implementation definition, servant_I.cpp, to implement the business logic, as described in Completing the server implementation (server_I.cpp).

This task is one step of the parent task, Developing a CORBA server.

Previous topic Next topic