Why and when to perform this task
Use this task to add code for a CORBA server implementation class to its skeleton implementation file, servant_I.cpp. The code defines the methods that implement the business logic for the server implementation class, servant.
This task follows the task to add declarations for class variables, constructors, and destructors to the servant implementation header file, servant.ih. For more information about adding declarations to an implementation header, see Adding declarations to a CORBA servant implementation header (servant.ih).
Steps for this task
::CORBA::Void WSLogger_Impl::setFileName (const char* newFileName) { } char* WSLogger_Impl::getFileName () { } ::CORBA::Void WSLogger_Impl::setMethodName (const char* newMethodName) { } char* WSLogger_Impl::getMethodName () { } ::CORBA::Short WSLogger_Impl::openLogFile () { } ::CORBA::Short WSLogger_Impl::closeLogFile () { } // This method writes one line of message text to the log file. The line // prefaced with the current date and time in the currently specified // format, the current method name (if any), the severity level, and // the message text. ::CORBA::Short WSLogger_Impl::writeLogMessage (const char* newMessage, ::CORBA::Short newSeverity) { ::CORBA::String_var timeString; if ( logFileOpen == FALSE ) return( -1 ); // Get the date and time string. time_t tp; time_t tp2; if ( ( tp = time(&tp2) ) != -1 ) { struct tm *x = gmtime( &tp2 ); timeString = ::CORBA::string_dup( ctime( &tp2 ) ); } // Determine the day and month. ::CORBA::String_var day = ::CORBA::string_alloc( 3 ); ::CORBA::String_var month = ::CORBA::string_alloc( 4 ); day[0] = timeString[8]; day[1] = timeString[9]; day[2] = 0; month[0] = timeString[4]; month[1] = timeString[5]; month[2] = timeString[6]; month[3] = 0; // Copy the time and year. ::CORBA::String_var time = ::CORBA::string_alloc( 14 ); strncpy( time, (const char *) &timeString[11], 13 ); time[13] = 0; // Output the time of the log message. if ( dateFormat == DMY_DATE_FORMAT ) logFile << day << " " << month; else if ( dateFormat == MDY_DATE_FORMAT ) logFile << month << " " << day; logFile << " " << time << ", "; if ( getMethodName() != NULL ) logFile << getMethodName() << ", "; logFile << "severity " << newSeverity << ": "; // Output the log message. logFile << newMessage << endl; return 0; } ::CORBA::Void WSLogger_Impl::setDateFormat (::CORBA::UShort newDateFormat) { } ::CORBA::UShort WSLogger_Impl::getDateFormat () { }
What to do next
Create the server main code (server.cpp), to implement the server as described in Creating a CORBA server main code (server.cpp).