Пример #1
0
// Listing 4
// Listing 5 code/ch05
void
ListTest::displayList (MyList& list)
{
  ACE_TRACE ("ListTest::displayList");

  ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("Forward iteration\n")));
  ACE_DLList_Iterator<DataElement> iter (list);
  while (!iter.done ())
    {
      ACE_DEBUG
        ((LM_DEBUG, ACE_TEXT ("%d:"), iter.next()->getData()));
      iter++;
    }
  ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\n")));

  ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("Reverse Iteration\n")));
  ACE_DLList_Reverse_Iterator<DataElement> riter (list);
  while (!riter.done ())
    {
      ACE_DEBUG
        ((LM_DEBUG, ACE_TEXT ("%d:"), riter.next()->getData()));
      riter++;
    }
  ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\n")));
}
Пример #2
0
RPG_Net_Protocol_Stream::RPG_Net_Protocol_Stream ()
 : inherited ()
 , myIRCMarshal (std::string ("IRCMarshal"),
                 NULL)
 , myIRCParser (std::string ("IRCParser"),
                NULL)
 //, myIRCHandler (std::string ("IRCHandler"),
 //                NULL)
 , myRuntimeStatistic (std::string ("RuntimeStatistic"),
                       NULL)
{
  RPG_TRACE (ACE_TEXT ("RPG_Net_Protocol_Stream::RPG_Net_Protocol_Stream"));

  // remember the ones we "own"...
  // *TODO*: clean this up
  // *NOTE*: one problem is that we need to explicitly close() all
  // modules which we have NOT enqueued onto the stream (e.g. because init()
  // failed...)
  inherited::availableModules_.insert_tail (&myIRCMarshal);
  inherited::availableModules_.insert_tail (&myIRCParser);
  inherited::availableModules_.insert_tail (&myRuntimeStatistic);

  // fix ACE bug: modules should initialize their "next" member to NULL !
//   for (MODULE_CONTAINERITERATOR_TYPE iter = myAvailableModules.begin();
  inherited::MODULE_T* module_p = NULL;
  for (ACE_DLList_Iterator<inherited::MODULE_T> iterator (inherited::availableModules_);
       iterator.next (module_p);
       iterator.advance ())
    module_p->next (NULL);
}
Пример #3
0
// Listing 3
// Listing 4 code/ch05
void
ListTest::destroyList (MyList& list)
{
  ACE_TRACE ("ListTest::destroyList");

  ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("Destroying data elements\n")));

  // Iterate through and delete all the data elements on the list.
  for (ACE_DLList_Iterator<DataElement> iter (list);
       !iter.done ();
       iter++)
    {
      DataElement *de = iter.next ();
      delete de;
    }
}
Пример #4
0
Файл: Log.cpp Проект: manut/TAO
void
Log::get_preamble ()
{
  char * p = ACE_OS::strstr (this->line_, "(");
  char * t = 0;

  this->info_ = this->line_;

  if (p == 0)
    return;

  if (p != this->line_)
    {
      char * x = ACE_OS::strstr (this->line_, "TAO (");
      if (x+4 != p)
        {
          x = ACE_OS::strstr (this->line_, "@(");
          if (x + 1 != p)
            return;
        }
    }


  long pid = ACE_OS::strtol(p + 1, &t, 10);
  if (pid == 0)
    return;

  long tid = 0;
  if ( *t == '|' )
    tid = ACE_OS::strtol(t + 1, 0, 10);
  else if ( *t != ')')
    return; // not either (pid) or (pid|tid)

  this->info_ = ACE_OS::strstr (p, ")") + 1;
  this->hostproc_ = 0;
  for (ACE_DLList_Iterator<HostProcess> i (this->procs_);
       !i.done();
       i.advance())
    {
      i.next(this->hostproc_);
      if (this->hostproc_->pid() == pid)
        {
          break;
        }
      this->hostproc_ = 0;
    }

  if (this->hostproc_ == 0)
    this->hostproc_ = this->session_.find_process(pid);

  if (this->hostproc_ == 0)
    {
      size_t numprocs = this->procs_.size();
      this->hostproc_ = new HostProcess (this->origin_,pid);
      this->procs_.insert_tail(this->hostproc_);
      ACE_CString &procname = this->alias_.length() > 0 ?
        this->alias_ : this->origin_;
      switch (numprocs)
        {
        case 0:
          this->hostproc_->proc_name(procname);
          break;
        case 1:
          {
            ACE_CString a2 = procname + "_1";
            HostProcess *first;
            if (this->procs_.get(first) == 0)
              first->proc_name(a2);
          }
          //fallthru
        default:
          {
            char ext[10];
            ACE_OS::sprintf(ext,"_" ACE_SIZE_T_FORMAT_SPECIFIER_ASCII,numprocs+1);
            ACE_CString a2 = procname + ext;
            this->hostproc_->proc_name(a2);
          }
        }

      this->session_.add_process (this->hostproc_);
    }
  this->thr_ = this->hostproc_->find_thread (tid, this->offset_);
  return;
}