commandstream.cpp

来自「ace开发环境 用来开发网络程序 其运用了设计模式、多平台、C++等多种知识」· C++ 代码 · 共 98 行

CPP
98
字号
// $Id: CommandStream.cpp 60975 2004-10-06 16:28:30Z shuston $#include "ace/Log_Msg.h"#include "ace/OS_Memory.h"#include "CommandStream.h"#include "Command.h"#include "CommandModule.h"#include "CommandTasks.h"// Gotcha: superclass' open() won't open head/tail modules// Gotcha!! Must open the stream before pushing modules!// Listing 01 code/ch18int CommandStream::open (void *arg,                         ACE_Module<ACE_MT_SYNCH> *head,                         ACE_Module<ACE_MT_SYNCH> *tail){  ACE_TRACE (ACE_TEXT ("CommandStream::open(peer)"));  if (this->inherited::open (arg, head, tail) == -1)    ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("%p\n"),                       ACE_TEXT ("Failed to open superclass")),                      -1);  // Listing 01  // Listing 02 code/ch18  CommandModule *answerCallModule;  ACE_NEW_RETURN (answerCallModule,                  AnswerCallModule (this->peer_),                  -1);  CommandModule *retrieveCallerIdModule;  ACE_NEW_RETURN (retrieveCallerIdModule,                  RetrieveCallerIdModule (this->peer_),                  -1);  CommandModule *playMessageModule;  ACE_NEW_RETURN (playMessageModule,                  PlayMessageModule (this->peer_),                  -1);  CommandModule *recordMessageModule;  ACE_NEW_RETURN (recordMessageModule,                  RecordMessageModule (this->peer_),                  -1);  // Listing 02  // Listing 03 code/ch18  if (this->push (answerCallModule) == -1)    ACE_ERROR_RETURN ((LM_ERROR,                       ACE_TEXT ("Failed to push %p\n"),                       answerCallModule->name()),                      -1);  if (this->push (retrieveCallerIdModule) == -1)    ACE_ERROR_RETURN ((LM_ERROR,                       ACE_TEXT ("Failed to push %p\n"),                       retrieveCallerIdModule->name()),                      -1);  if (this->push (playMessageModule) == -1)    ACE_ERROR_RETURN ((LM_ERROR,                       ACE_TEXT ("Failed to push %p\n"),                       playMessageModule->name()),                      -1);  if (this->push (recordMessageModule) == -1)    ACE_ERROR_RETURN ((LM_ERROR,                       ACE_TEXT ("Failed to push %p\n"),                       recordMessageModule->name()),                      -1);  // Listing 03  return 0;}// Listing 04 code/ch18Command *CommandStream::execute (Command *command){  ACE_Message_Block *mb;  ACE_NEW_RETURN (mb, ACE_Message_Block (command), 0);  if (this->put (mb) == -1)    ACE_ERROR_RETURN ((LM_ERROR,                       ACE_TEXT ("Fail on put command %d: %p\n"),                       command->command_,                       ACE_TEXT ("")),                      0);  this->get (mb);  command = (Command *)mb->data_block ();  ACE_DEBUG ((LM_DEBUG,              ACE_TEXT ("Command (%d) returns (%d)\n"),              command->command_,              command->numeric_result_));  return command;}// Listing 04

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?