void qlTimeSeriesDataReaderListenerImpl::on_data_available( DDS::DataReader_ptr reader )
  throw (CORBA::SystemException)
{

  try {
   timeseries::qlTimeSeriesDataReader_var obj_dr
     = timeseries::qlTimeSeriesDataReader::_narrow(reader);
   if (CORBA::is_nil (obj_dr.in ())) {
     ACE_ERROR((LM_ERROR,
               ACE_TEXT("(%P|%t) ERROR: ")
               ACE_TEXT("qlTimeSeriesDataReaderListenerImpl::on_data_available: _narrow failed.\n")));
  } 

  on_reading_start( reader );

  int count = 0;
  while ( true )
  {
    timeseries::qlTimeSeries obj;
    DDS::SampleInfo si ;
    DDS::ReturnCode_t status = obj_dr->take_next_sample(obj, si) ;

    if ( status == DDS::RETCODE_OK )
    {
      if ( si.valid_data == true )
      {
         ++count;

         if ( pre_quantlib_addin_call( reader, si, obj ) )
         {
            std::string returnObject;;

            try {

              ACE_Guard<ACE_Mutex> guard( get_ACE_Mutex() );

              returnObject = QuantLibAddinCpp::qlTimeSeries ( 
              obj.ObjectId.in(),
             qldds_utils::vector_cast<ObjectHandler::property_t,CORBA::StringSeq>(obj.Dates),
             qldds_utils::vector_cast<double,CORBA::DoubleSeq>(obj.Values),
              static_cast<bool>(obj.Permanent),
              obj.Trigger,
              static_cast<bool>(obj.Overwrite) );
              ;
          
            } catch ( std::exception& e )
            {
              on_std_exception( reader, obj, e );
              continue;
            }

            if ( !post_quantlib_addin_call( reader, obj, returnObject ) )
             break; 
         }
      }

    } else if (status == DDS::RETCODE_NO_DATA) {

       on_reading_end( reader, count );

       break;

    }  else {
       std::string err = "ERROR: read qlTimeSeries: Error: ";
       err += status;

       on_dds_reading_error( reader, err );
    }
  }

  } catch (CORBA::Exception& e) {
       on_dds_exception( reader, e );
  }

}
예제 #2
0
파일: Svc_Conf_Lexer.cpp 프로젝트: CCJY/ACE
int
ACE_Svc_Conf_Lexer::yylex (YYSTYPE* ace_yylval,
                           ACE_Svc_Conf_Param* param)
{
#if defined (ACE_USES_WCHAR)
  bool look_for_bom = false;
  ACE_Encoding_Converter_Factory::Encoding_Hint hint =
                ACE_Encoding_Converter_Factory::ACE_NONE;
#endif /* ACE_USES_WCHAR */
  if (param->buffer == 0)
    {
#if defined (ACE_USES_WCHAR)
      look_for_bom = true;
#endif /* ACE_USES_WCHAR */
      ACE_NEW_RETURN (param->buffer,
                      ace_yy_buffer_state,
                      -1);
    }

  int token = ACE_NO_STATE;
  do {
    if (param->buffer->need_more_)
      {
#if defined (ACE_USES_WCHAR)
        size_t skip_bytes = 0;
#endif /* ACE_USES_WCHAR */
        param->buffer->need_more_ = false;
        size_t amount =
               input (param,
                      param->buffer->input_ + param->buffer->size_,
                      normalize (ACE_YY_BUF_SIZE -
                                 param->buffer->size_));
        if (amount == 0)
          {
            param->buffer->eof_ = true;
#if defined (ACE_USES_WCHAR)
            skip_bytes = param->buffer->size_;
#endif /* ACE_USES_WCHAR */
          }
        else
          {
#if defined (ACE_USES_WCHAR)
            if (look_for_bom)
              {
                size_t read_more = 0;

                look_for_bom = false;
                hint = locate_bom (param->buffer->input_, amount, read_more);

                if (read_more != 0)
                  {
                    input (param,
                           param->buffer->input_ + amount,
                           read_more);
                    ACE_OS::memmove (param->buffer->input_,
                                     param->buffer->input_ + read_more,
                                     amount);
                  }
              }
            skip_bytes = param->buffer->size_;
#endif /* ACE_USES_WCHAR */
            param->buffer->size_ += amount;
          }

#if defined (ACE_USES_WCHAR)
        if (!convert_to_utf8 (param, skip_bytes, hint))
          {
            ace_yyerror (++param->yyerrno,
                         param->yylineno,
                         ACE_TEXT ("Unable to convert input stream to UTF-8"));
            return ACE_NO_STATE;
          }
#endif /* ACE_USES_WCHAR */
      }

    token = scan (ace_yylval, param);
  } while (token == ACE_NO_STATE && param->buffer->need_more_);

  return token;
}
예제 #3
0
void
TAO::PG_Object_Group::add_member (const PortableGroup::Location & the_location,
                                  CORBA::Object_ptr member)

{
  ACE_GUARD (TAO_SYNCH_MUTEX, guard, this->internals_);

  if (CORBA::is_nil (member))
    {
      if (TAO_debug_level > 3)
        {
          ORBSVCS_ERROR ((LM_ERROR,
                      ACE_TEXT ("%T %n (%P|%t) - TAO::PG_Object_Group::add_member")
                      ACE_TEXT ("Can't add a null member to object group\n")
                      ));
        }
      throw PortableGroup::ObjectNotAdded ();
    }

  /////////////////////////////////////////
  // Convert the new member to a string IOR
  // This keeps a clean IOR (not an IOGR!)
  // while we add it to a group.  We need a
  // IORs, not IOGRs to send new IOGRs out
  // to replicas.

  // Verify that the member is not using V1.0 profiles
  // since IIOP V1.0 does not support tagged components
  const TAO_MProfile &member_profiles =
    member->_stubobj ()->base_profiles ();
  CORBA::ULong member_profile_count =
    member_profiles.profile_count ();
  if (member_profile_count > 0)
    {
      const TAO_GIOP_Message_Version & version =
        member_profiles.get_profile (0)->version ();
      if (version.major_version () == 1 &&
          version.minor_version () == 0)
        {
          if (TAO_debug_level > 3)
            {
              ORBSVCS_ERROR ((LM_ERROR,
                          ACE_TEXT ("%T %n (%P|%t) - ")
                          ACE_TEXT ("Can't add member because first profile ")
                          ACE_TEXT ("is IIOP version 1.0, which does not ")
                          ACE_TEXT ("support tagged components.\n")
                          ));
            }
          throw PortableGroup::ObjectNotAdded ();
        }
    }

  CORBA::String_var member_ior_string =
    orb_->object_to_string (member);

  PortableGroup::ObjectGroup_var new_reference;
  try {
    new_reference =
      this->add_member_to_iogr (member);
  }
  catch (const TAO_IOP::Duplicate&)
    {
      throw PortableGroup::MemberAlreadyPresent ();
    }
  catch (const TAO_IOP::Invalid_IOR&)
    {
      throw PortableGroup::ObjectNotAdded ();
    }
  catch (...)
    {
      throw;
    }

  if (CORBA::is_nil (new_reference.in ()))
    throw PortableGroup::ObjectNotAdded ();

  // Convert new member back to a (non group) ior.
  CORBA::Object_var member_ior =
    this->orb_->string_to_object (member_ior_string.in ());

  MemberInfo * info = 0;
  ACE_NEW_THROW_EX (info,
                    MemberInfo (member_ior.in (),
                                the_location),
                    CORBA::NO_MEMORY());

  if (this->members_.bind (the_location, info) != 0)
    {
      delete info;

      // @@ Dale why this is a NO MEMORY exception?
      throw CORBA::NO_MEMORY();
    }

  this->reference_ = new_reference; // note var-to-var assignment does
                                    // a duplicate

  if (this->increment_version ())
    {
      this->distribute_iogr ();
    }
  else
    { // Issue with incrementing the version

      if (TAO_debug_level > 6)
        {
          ORBSVCS_DEBUG ((LM_DEBUG,
                      ACE_TEXT ("PG (%P|%t) Issue incrementing the ")
                      ACE_TEXT ("version in Object_Group add_member\n")));
        }
      // Must unbind the new member and delete it.
      if (this->members_.unbind (the_location, info) == 0)
        delete info;
      throw PortableGroup::ObjectNotAdded ();
    }

  if (TAO_debug_level > 6)
  {
    ORBSVCS_DEBUG ((LM_DEBUG,
      ACE_TEXT("PG (%P|%t) exit Object_Group add_member\n")));
  }
}
예제 #4
0
void
SDL_GUI_MainWindow::initScrollSpots()
{
  RPG_TRACE(ACE_TEXT("SDL_GUI_MainWindow::initScrollSpots"));

  // upper left
  RPG_Graphics_HotSpot::initialize(*this,             // parent
                             std::make_pair(RPG_GRAPHICS_WINDOW_HOTSPOT_SCROLL_MARGIN,
                                            RPG_GRAPHICS_WINDOW_HOTSPOT_SCROLL_MARGIN), // size
                             std::make_pair(0,
                                            0), // offset
                             CURSOR_SCROLL_UL); // (hover) cursor graphic
  // up
  RPG_Graphics_HotSpot::initialize(*this,             // parent
                             std::make_pair((clipRectangle_.w -
                                             (2 * RPG_GRAPHICS_WINDOW_HOTSPOT_SCROLL_MARGIN)),
                                            RPG_GRAPHICS_WINDOW_HOTSPOT_SCROLL_MARGIN), // size
                             std::make_pair(RPG_GRAPHICS_WINDOW_HOTSPOT_SCROLL_MARGIN,
                                            0), // offset
                             CURSOR_SCROLL_U);  // (hover) cursor graphic
  // upper right
  RPG_Graphics_HotSpot::initialize(*this,             // parent
                             std::make_pair(RPG_GRAPHICS_WINDOW_HOTSPOT_SCROLL_MARGIN,
                                            RPG_GRAPHICS_WINDOW_HOTSPOT_SCROLL_MARGIN), // size
                             std::make_pair((clipRectangle_.w -
                                             RPG_GRAPHICS_WINDOW_HOTSPOT_SCROLL_MARGIN),
                                            0), // offset
                             CURSOR_SCROLL_UR); // (hover) cursor graphic
  // left
  RPG_Graphics_HotSpot::initialize(*this,            // parent
                             std::make_pair(RPG_GRAPHICS_WINDOW_HOTSPOT_SCROLL_MARGIN,
                                            (clipRectangle_.h -
                                             (2 * RPG_GRAPHICS_WINDOW_HOTSPOT_SCROLL_MARGIN))), // size
                             std::make_pair(0,
                                            RPG_GRAPHICS_WINDOW_HOTSPOT_SCROLL_MARGIN), // offset
                             CURSOR_SCROLL_L); // (hover) cursor graphic
  // right
  RPG_Graphics_HotSpot::initialize(*this,            // parent
                             std::make_pair(RPG_GRAPHICS_WINDOW_HOTSPOT_SCROLL_MARGIN,
                                            (clipRectangle_.h -
                                             (2 * RPG_GRAPHICS_WINDOW_HOTSPOT_SCROLL_MARGIN))), // size
                             std::make_pair((clipRectangle_.w -
                                             RPG_GRAPHICS_WINDOW_HOTSPOT_SCROLL_MARGIN),
                                            RPG_GRAPHICS_WINDOW_HOTSPOT_SCROLL_MARGIN), // offset
                             CURSOR_SCROLL_R); // (hover) cursor graphic
  // lower left
  RPG_Graphics_HotSpot::initialize(*this,             // parent
                             std::make_pair(RPG_GRAPHICS_WINDOW_HOTSPOT_SCROLL_MARGIN,
                                            RPG_GRAPHICS_WINDOW_HOTSPOT_SCROLL_MARGIN), // size
                             std::make_pair(0,
                                            (clipRectangle_.h -
                                             RPG_GRAPHICS_WINDOW_HOTSPOT_SCROLL_MARGIN)), // offset
                             CURSOR_SCROLL_DL); // (hover) cursor graphic
  // down
  RPG_Graphics_HotSpot::initialize(*this,            // parent
                             std::make_pair(clipRectangle_.w -
                                            (2 * RPG_GRAPHICS_WINDOW_HOTSPOT_SCROLL_MARGIN),
                                            RPG_GRAPHICS_WINDOW_HOTSPOT_SCROLL_MARGIN), // size
                             std::make_pair(RPG_GRAPHICS_WINDOW_HOTSPOT_SCROLL_MARGIN,
                                            (clipRectangle_.h -
                                             RPG_GRAPHICS_WINDOW_HOTSPOT_SCROLL_MARGIN)), // offset
                             CURSOR_SCROLL_D); // (hover) cursor graphic
  // lower right
  RPG_Graphics_HotSpot::initialize(*this,             // parent
                             std::make_pair(RPG_GRAPHICS_WINDOW_HOTSPOT_SCROLL_MARGIN,
                                            RPG_GRAPHICS_WINDOW_HOTSPOT_SCROLL_MARGIN), // size
                             std::make_pair((clipRectangle_.w -
                                             RPG_GRAPHICS_WINDOW_HOTSPOT_SCROLL_MARGIN),
                                            (clipRectangle_.h -
                                             RPG_GRAPHICS_WINDOW_HOTSPOT_SCROLL_MARGIN)), // offset
                             CURSOR_SCROLL_DR); // (hover) cursor graphic
}
예제 #5
0
void
SDL_GUI_MainWindow::draw(SDL_Surface* targetSurface_in,
                         unsigned int offsetX_in,
                         unsigned int offsetY_in)
{
  RPG_TRACE(ACE_TEXT("SDL_GUI_MainWindow::draw"));

  // sanity check(s)
  SDL_Surface* target_surface = (targetSurface_in ? targetSurface_in
                                                  : inherited::screen_);
  ACE_ASSERT(target_surface);
  ACE_ASSERT(static_cast<int>(offsetX_in) <= target_surface->w);
  ACE_ASSERT(static_cast<int>(offsetY_in) <= target_surface->h);

  // *NOTE*: drawBorder() does its own locking
  // step1: draw borders
  drawBorder(target_surface,
             offsetX_in,
             offsetY_in);

  lock();

  // step2: draw title
  drawTitle(myTitleFont,
            title_,
            target_surface);

  // step3: fill central area
  SDL_Rect prev_clip_rect, clip_rect, dirty_region;
  SDL_GetClipRect (target_surface, &prev_clip_rect);
  clip_rect.x = static_cast<Sint16> (offsetX_in + borderLeft_);
  clip_rect.y = static_cast<Sint16> (offsetY_in + borderTop_);
  clip_rect.w = static_cast<Uint16> (target_surface->w               -
                                     offsetX_in                      -
                                     (borderLeft_ + borderRight_));
  clip_rect.h = static_cast<Uint16> (target_surface->h               -
                                     offsetY_in                      -
                                     (borderTop_ + borderBottom_));
  if (!SDL_SetClipRect (target_surface, &clip_rect))
  {
    ACE_DEBUG((LM_ERROR,
               ACE_TEXT("failed to SDL_SetClipRect(): %s, aborting\n"),
               ACE_TEXT(SDL_GetError())));

    // clean up
    unlock();

    return;
  } // end IF
  RPG_Graphics_InterfaceElementsConstIterator_t iterator;
  iterator = myElementGraphics.find(INTERFACEELEMENT_BORDER_CENTER);
  ACE_ASSERT(iterator != myElementGraphics.end());
  for (unsigned int i = (offsetY_in + borderTop_);
       i < (target_surface->h - borderBottom_);
       i += (*iterator).second->h)
    for (unsigned int j = (offsetX_in + borderLeft_);
         j < (target_surface->w - borderRight_);
         j += (*iterator).second->w)
    {
      RPG_Graphics_Surface::put(std::make_pair(j,
                                               i),
                                *(*iterator).second,
                                target_surface,
                                dirty_region);
      invalidate (clip_rect);
    } // end FOR
  if (!SDL_SetClipRect(target_surface, &prev_clip_rect))
  {
    ACE_DEBUG((LM_ERROR,
               ACE_TEXT("failed to SDL_SetClipRect(): %s, aborting\n"),
               ACE_TEXT(SDL_GetError())));

    // clean up
    unlock();

    return;
  } // end IF
  unlock();

  // init clipping
  clip(target_surface,
       offsetX_in,
       offsetY_in);

  // step4: realize hotspots (and any other children)
  for (RPG_Graphics_WindowsIterator_t iterator = children_.begin();
       iterator != children_.end();
       iterator++)
  {
    try
    {
      (*iterator)->draw(target_surface,
                        offsetX_in,
                        offsetY_in);
    }
    catch (...)
    {
      ACE_DEBUG((LM_ERROR,
                 ACE_TEXT("caught exception in RPG_Graphics_IWindow::draw(), continuing\n")));
    }
  } // end FOR

  // restore previous clipping area
  unclip(target_surface);

  // remember position of last realization
  lastAbsolutePosition_ = std::make_pair(offsetX_in,
                                         offsetY_in);
}
예제 #6
0
int
be_visitor_operation_ch::visit_operation (be_operation *node)
{
  TAO_OutStream *os = this->ctx_->stream ();

  this->ctx_->node (node);

  *os << be_nl_2;

  // STEP I: generate the return type.
  be_type *bt = be_type::narrow_from_decl (node->return_type ());

  if (!bt)
    {
      ACE_ERROR_RETURN ((LM_ERROR,
                         ACE_TEXT ("be_visitor_operation_ch::")
                         ACE_TEXT ("visit_operation - ")
                         ACE_TEXT ("Bad return type\n")),
                        -1);
    }
  //Only if we are generating exec header file, generate DOxygen documentation
  if (this->ctx_->state () == TAO_CodeGen::TAO_ROOT_EXH)
    {
      if (this->void_return_type (bt))
        {
           *os << "/// Setter for " << node->local_name() << " attribute" << be_nl
               << "/// @param[in] " << node->local_name() << " - New value for "
               << node->local_name() << " attribute" << be_nl;


        }
      else
        {
          *os << "/// Getter for " << node->local_name() << " attribute" << be_nl
                 << "/// @return value of " << node->local_name() << " attribute" << be_nl;
        }
    }
  *os << "virtual ";

  // Grab the right visitor to generate the return type.
  be_visitor_context ctx (*this->ctx_);
  be_visitor_operation_rettype or_visitor (&ctx);

  if (bt->accept (&or_visitor) == -1)
    {
      ACE_ERROR_RETURN ((LM_ERROR,
                         "(%N:%l) be_visitor_operation_ch::"
                         "visit_operation - "
                         "codegen for return type failed\n"),
                        -1);
    }

  // STEP 2: generate the operation name. The port prefix should
  // be an empty string except for operations from attributes
  // defined in a porttype.
  *os << " " << node->local_name ();

  // STEP 3: generate the argument list with the appropriate mapping. For these
  // we grab a visitor that generates the parameter listing.
  ctx = *this->ctx_;
  ctx.state (TAO_CodeGen::TAO_OPERATION_ARGLIST_CH);
  be_visitor_operation_arglist oa_visitor (&ctx);

  if (node->accept (&oa_visitor) == -1)
    {
      ACE_ERROR_RETURN ((LM_ERROR,
                         "(%N:%l) be_visitor_operation_ch::"
                         "visit_operation - "
                         "codegen for argument list failed\n"),
                        -1);
    }

  be_interface *intf =
    be_interface::narrow_from_scope (node->defined_in ());

  /// If we are in a reply handler, are not an excep_* operation,
  /// and have no native args, then generate the AMI static
  /// reply stub declaration.
  if (intf != 0
      && intf->is_ami_rh ()
      && !node->is_excep_ami ()
      && !node->has_native ())
    {
      *os << be_nl_2
          << "static void" << be_nl
          << node->local_name () << "_reply_stub (" << be_idt_nl
          << "TAO_InputCDR &_tao_reply_cdr," << be_nl
          << "::Messaging::ReplyHandler_ptr _tao_reply_handler,"
          << be_nl
          << "::CORBA::ULong reply_status);" << be_uidt;
    }

  return 0;
}
예제 #7
0
void
SDL_GUI_MainWindow::handleEvent(const SDL_Event& event_in,
                                RPG_Graphics_IWindowBase* window_in,
                                SDL_Rect& dirtyRegion_out)
{
  RPG_TRACE(ACE_TEXT("SDL_GUI_MainWindow::handleEvent"));

  // init return value(s)
  ACE_OS::memset(&dirtyRegion_out, 0, sizeof(dirtyRegion_out));

//   ACE_DEBUG((LM_DEBUG,
//              ACE_TEXT("SDL_GUI_MainWindow::handleEvent\n")));

  switch (event_in.type)
  {
    // *** visibility ***
    case SDL_ACTIVEEVENT:
    {
      if (event_in.active.state & SDL_APPMOUSEFOCUS)
      {
        if (event_in.active.gain & SDL_APPMOUSEFOCUS)
        {
//           ACE_DEBUG((LM_DEBUG,
//                      ACE_TEXT("gained mouse coverage...\n")));

//          // *HACK*: prevents MOST "mouse trails" (NW borders)...
//          drawBorder(inherited::screen_,
//                     0,
//                     0);
//          drawTitle(myTitleFont,
//                    myTitle,
//                    inherited::screen_);
//          refresh();

          myHaveMouseFocus = true;
        } // end IF
        else
        {
//           ACE_DEBUG((LM_DEBUG,
//                      ACE_TEXT("lost mouse coverage...\n")));

//          // *HACK*: prevents MOST "mouse trails" (NW borders)...
//          drawBorder(inherited::screen_,
//                     0,
//                     0);
//          drawTitle(myTitleFont,
//                    myTitle,
//                    inherited::screen_);
//          refresh();

          myHaveMouseFocus = false;
        } // end ELSE
      } // end IF
      if (event_in.active.state & SDL_APPINPUTFOCUS)
      {
        if (event_in.active.gain & SDL_APPINPUTFOCUS)
        {
//           ACE_DEBUG((LM_DEBUG,
//                      ACE_TEXT("gained input focus...\n")));
        } // end IF
        else
        {
//           ACE_DEBUG((LM_DEBUG,
//                      ACE_TEXT("lost input focus...\n")));
        } // end ELSE
      } // end IF
      if (event_in.active.state & SDL_APPACTIVE)
      {
        if (event_in.active.gain & SDL_APPACTIVE)
        {
//           ACE_DEBUG((LM_DEBUG,
//                      ACE_TEXT("activated...\n")));
        } // end IF
        else
        {
//           ACE_DEBUG((LM_DEBUG,
//                      ACE_TEXT("iconified...\n")));
        } // end ELSE
      } // end IF

      break;
    }
    // *** keyboard ***
    case SDL_KEYDOWN:
    {
//       ACE_DEBUG((LM_DEBUG,
//                  ACE_TEXT("%s key\n%s\n"),
//                  ((event_in.type == SDL_KEYDOWN) ? ACE_TEXT("pressed") : ACE_TEXT("released")),
//                  ACE_TEXT(RPG_Graphics_SDL_Tools::keyToString(event_in.key.keysym).c_str())));

      switch (event_in.key.keysym.sym)
      {
        case SDLK_s:
        {
          std::ostringstream converter;
          converter << myScreenshotIndex++;
          std::string dump_path = Common_File_Tools::getDumpDirectory();
          dump_path += ACE_DIRECTORY_SEPARATOR_CHAR_A;
          dump_path += ACE_TEXT_ALWAYS_CHAR(RPG_CLIENT_SCREENSHOT_DEF_PREFIX);
          dump_path += ACE_TEXT_ALWAYS_CHAR("_");
          dump_path += converter.str();
          dump_path += ACE_TEXT_ALWAYS_CHAR(RPG_CLIENT_SCREENSHOT_DEF_EXT);
          RPG_Graphics_Surface::savePNG(*SDL_GetVideoSurface(), // image
                                        dump_path,              // file
                                        false);                 // no alpha

          break;
        }
        default:
          break;
      } // end SWITCH

      break;
    }
    case SDL_KEYUP:
    {
      ACE_DEBUG((LM_DEBUG,
                 ACE_TEXT("key released...\n")));

      break;
    }
    // *** mouse ***
    case SDL_MOUSEMOTION:
    {
//       ACE_DEBUG((LM_DEBUG,
//                  ACE_TEXT("mouse motion...\n")));

      break;
    }
    case SDL_MOUSEBUTTONDOWN:
    {
//       ACE_DEBUG((LM_DEBUG,
//                  ACE_TEXT("mouse button [%u,%u] pressed\n"),
//                  static_cast<unsigned int>(event_in.button.which),
//                  static_cast<unsigned int>(event_in.button.button)));

      // (left-)clicking on a hotspot (edge) area triggers a scroll of the viewport
      if ((window_in->getType() == WINDOW_HOTSPOT) &&
          (event_in.button.button == 1))
      {
        // retrieve hotspot window handle
        RPG_Graphics_HotSpot* hotspot = NULL;
        try
        {
          hotspot = dynamic_cast<RPG_Graphics_HotSpot*>(window_in);
        }
        catch (...)
        {
          hotspot = NULL;
        }
        if (!hotspot)
        {
          ACE_DEBUG((LM_ERROR,
                    ACE_TEXT("failed to dynamic_cast<RPG_Graphics_HotSpot*>(%@), aborting\n"),
                    window_in));

          break;
        } // end IF

        // retrieve map window handle
        RPG_Graphics_WindowsConstIterator_t iterator = children_.begin();
        for (;
             iterator != children_.end();
             iterator++)
        {
          if ((*iterator)->getType() == WINDOW_MAP)
            break;
        } // end FOR
        ACE_ASSERT((*iterator)->getType() == WINDOW_MAP);
        RPG_Client_IWindowLevel* level_window = NULL;
        try
        {
          level_window = dynamic_cast<RPG_Client_IWindowLevel*>(*iterator);
        }
        catch (...)
        {
          level_window = NULL;
        }
        if (!level_window)
        {
          ACE_DEBUG((LM_ERROR,
                    ACE_TEXT("failed to dynamic_cast<RPG_Client_IWindowLevel*>(%@), aborting\n"),
                    *iterator));

          break;
        } // end IF

        switch (hotspot->getCursorType())
        {
          case CURSOR_SCROLL_UL:
          {
            level_window->setView(-RPG_GRAPHICS_WINDOW_SCROLL_OFFSET,
                                  -RPG_GRAPHICS_WINDOW_SCROLL_OFFSET);
            level_window->setView(-RPG_GRAPHICS_WINDOW_SCROLL_OFFSET,
                                  RPG_GRAPHICS_WINDOW_SCROLL_OFFSET);

            break;
          }
          case CURSOR_SCROLL_U:
          {
            level_window->setView(-RPG_GRAPHICS_WINDOW_SCROLL_OFFSET,
                                  -RPG_GRAPHICS_WINDOW_SCROLL_OFFSET);

            break;
          }
          case CURSOR_SCROLL_UR:
          {
            level_window->setView(-RPG_GRAPHICS_WINDOW_SCROLL_OFFSET,
                                  -RPG_GRAPHICS_WINDOW_SCROLL_OFFSET);
            level_window->setView(RPG_GRAPHICS_WINDOW_SCROLL_OFFSET,
                                  -RPG_GRAPHICS_WINDOW_SCROLL_OFFSET);

            break;
          }
          case CURSOR_SCROLL_L:
          {
            level_window->setView(-RPG_GRAPHICS_WINDOW_SCROLL_OFFSET,
                                  RPG_GRAPHICS_WINDOW_SCROLL_OFFSET);

            break;
          }
          case CURSOR_SCROLL_R:
          {
            level_window->setView(RPG_GRAPHICS_WINDOW_SCROLL_OFFSET,
                                  -RPG_GRAPHICS_WINDOW_SCROLL_OFFSET);

            break;
          }
          case CURSOR_SCROLL_DL:
          {
            level_window->setView(RPG_GRAPHICS_WINDOW_SCROLL_OFFSET,
                                  RPG_GRAPHICS_WINDOW_SCROLL_OFFSET);
            level_window->setView(-RPG_GRAPHICS_WINDOW_SCROLL_OFFSET,
                                  RPG_GRAPHICS_WINDOW_SCROLL_OFFSET);

            break;
          }
          case CURSOR_SCROLL_D:
          {
            level_window->setView(RPG_GRAPHICS_WINDOW_SCROLL_OFFSET,
                                  RPG_GRAPHICS_WINDOW_SCROLL_OFFSET);

            break;
          }
          case CURSOR_SCROLL_DR:
          {
            level_window->setView(RPG_GRAPHICS_WINDOW_SCROLL_OFFSET,
                                  RPG_GRAPHICS_WINDOW_SCROLL_OFFSET);
            level_window->setView(RPG_GRAPHICS_WINDOW_SCROLL_OFFSET,
                                  -RPG_GRAPHICS_WINDOW_SCROLL_OFFSET);

            break;
          }
          default:
          {
            ACE_DEBUG((LM_DEBUG,
                      ACE_TEXT("invalid/unknown cursor type (was: \"%s\"), aborting\n"),
                      ACE_TEXT(RPG_Graphics_CursorHelper::RPG_Graphics_CursorToString(hotspot->getCursorType()).c_str())));

            return;
          }
        } // end SWITCH

        // redraw
        try
        {
          level_window->draw();
          level_window->getArea(dirtyRegion_out);
        }
        catch (...)
        {
          ACE_DEBUG((LM_ERROR,
                    ACE_TEXT("caught exception in RPG_Graphics_IWindowBase::draw/getArea, continuing\n")));
        }
        RPG_GRAPHICS_CURSOR_MANAGER_SINGLETON::instance()->reset(true);

  //       ACE_DEBUG((LM_DEBUG,
  //                  ACE_TEXT("scrolled map (%s)...\n"),
  //                  ACE_TEXT(RPG_Graphics_TypeHelper::RPG_Graphics_TypeToString(hotspot->getHotSpotType()).c_str())));
      } // end IF

      break;
    }
    case SDL_MOUSEBUTTONUP:
    {
      ACE_DEBUG((LM_DEBUG,
                 ACE_TEXT("mouse button [%u,%u] released...\n"),
                 static_cast<unsigned int>(event_in.button.which),
                 static_cast<unsigned int>(event_in.button.button)));

      break;
    }
    // *** joystick ***
    case SDL_JOYAXISMOTION:
    case SDL_JOYBALLMOTION:
    case SDL_JOYHATMOTION:
    case SDL_JOYBUTTONDOWN:
    case SDL_JOYBUTTONUP:
    {
      ACE_DEBUG((LM_DEBUG,
                 ACE_TEXT("joystick activity...\n")));

      break;
    }
    case SDL_QUIT:
    {
      ACE_DEBUG((LM_DEBUG,
                 ACE_TEXT("SDL_QUIT event...\n")));

      break;
    }
    case SDL_SYSWMEVENT:
    {
      ACE_DEBUG((LM_DEBUG,
                 ACE_TEXT("SDL_SYSWMEVENT event...\n")));

      break;
    }
    case SDL_VIDEORESIZE:
    {
      ACE_DEBUG((LM_DEBUG,
                 ACE_TEXT("SDL_VIDEORESIZE event...\n")));

      break;
    }
    case SDL_VIDEOEXPOSE:
    {
      ACE_DEBUG((LM_DEBUG,
                 ACE_TEXT("SDL_VIDEOEXPOSE event...\n")));

      break;
    }
    case RPG_GRAPHICS_SDL_HOVEREVENT:
    {
//       ACE_DEBUG((LM_DEBUG,
//                  ACE_TEXT("RPG_GRAPHICS_SDL_HOVEREVENT event (%d ms)...\n"),
//                  event_in.user.code));

      // don't hover if we've lost the mouse in the meantime...
      if (!myHaveMouseFocus)
        break;

      // hovering on a hotspot (edge) area triggers a scroll of the viewport
      if (window_in == this)
        break; // not a hotspot

      // sanity check
      ACE_ASSERT(window_in->getType() == WINDOW_HOTSPOT);

      // retrieve hotspot window handle
      RPG_Graphics_HotSpot* hotspot = NULL;
      try
      {
        hotspot = dynamic_cast<RPG_Graphics_HotSpot*>(window_in);
      }
      catch (...)
      {
        hotspot = NULL;
      }
      if (!hotspot)
      {
        ACE_DEBUG((LM_ERROR,
                   ACE_TEXT("failed to dynamic_cast<RPG_Graphics_HotSpot*>(%@), aborting\n"),
                   window_in));

        break;
      } // end IF

      // retrieve map window handle
      RPG_Graphics_WindowsConstIterator_t iterator = children_.begin();
      for (;
           iterator != children_.end();
           iterator++)
      {
        if ((*iterator)->getType() == WINDOW_MAP)
          break;
      } // end FOR
      ACE_ASSERT((iterator != children_.end()) &&
                 (*iterator)->getType() == WINDOW_MAP);
      RPG_Client_IWindowLevel* level_window = NULL;
      try
      {
        level_window = dynamic_cast<RPG_Client_IWindowLevel*>(*iterator);
      }
      catch (...)
      {
        level_window = NULL;
      }
      if (!level_window)
      {
        ACE_DEBUG((LM_ERROR,
                   ACE_TEXT("failed to dynamic_cast<RPG_Client_IWindowLevel*>(%@), aborting\n"),
                   *iterator));

        break;
      } // end IF

      if (myLastHoverTime)
      {
        // throttle scrolling
        if ((event_in.user.code - myLastHoverTime) < RPG_GRAPHICS_WINDOW_HOTSPOT_HOVER_SCROLL_DELAY)
          break; // don't scroll this time
      } // end ELSE
      myLastHoverTime = event_in.user.code;

      switch (hotspot->getCursorType())
      {
        case CURSOR_SCROLL_UL:
        {
          level_window->setView(-RPG_GRAPHICS_WINDOW_SCROLL_OFFSET,
                                -RPG_GRAPHICS_WINDOW_SCROLL_OFFSET);
          level_window->setView(-RPG_GRAPHICS_WINDOW_SCROLL_OFFSET,
                                RPG_GRAPHICS_WINDOW_SCROLL_OFFSET);

          break;
        }
        case CURSOR_SCROLL_U:
        {
          level_window->setView(-RPG_GRAPHICS_WINDOW_SCROLL_OFFSET,
                                -RPG_GRAPHICS_WINDOW_SCROLL_OFFSET);

          break;
        }
        case CURSOR_SCROLL_UR:
        {
          level_window->setView(-RPG_GRAPHICS_WINDOW_SCROLL_OFFSET,
                                -RPG_GRAPHICS_WINDOW_SCROLL_OFFSET);
          level_window->setView(RPG_GRAPHICS_WINDOW_SCROLL_OFFSET,
                                -RPG_GRAPHICS_WINDOW_SCROLL_OFFSET);

          break;
        }
        case CURSOR_SCROLL_L:
        {
          level_window->setView(-RPG_GRAPHICS_WINDOW_SCROLL_OFFSET,
                                RPG_GRAPHICS_WINDOW_SCROLL_OFFSET);

          break;
        }
        case CURSOR_SCROLL_R:
        {
          level_window->setView(RPG_GRAPHICS_WINDOW_SCROLL_OFFSET,
                                -RPG_GRAPHICS_WINDOW_SCROLL_OFFSET);

          break;
        }
        case CURSOR_SCROLL_DL:
        {
          level_window->setView(RPG_GRAPHICS_WINDOW_SCROLL_OFFSET,
                                RPG_GRAPHICS_WINDOW_SCROLL_OFFSET);
          level_window->setView(-RPG_GRAPHICS_WINDOW_SCROLL_OFFSET,
                                RPG_GRAPHICS_WINDOW_SCROLL_OFFSET);

          break;
        }
        case CURSOR_SCROLL_D:
        {
          level_window->setView(RPG_GRAPHICS_WINDOW_SCROLL_OFFSET,
                                RPG_GRAPHICS_WINDOW_SCROLL_OFFSET);

          break;
        }
        case CURSOR_SCROLL_DR:
        {
          level_window->setView(RPG_GRAPHICS_WINDOW_SCROLL_OFFSET,
                                RPG_GRAPHICS_WINDOW_SCROLL_OFFSET);
          level_window->setView(RPG_GRAPHICS_WINDOW_SCROLL_OFFSET,
                                -RPG_GRAPHICS_WINDOW_SCROLL_OFFSET);

          break;
        }
        default:
        {
          ACE_DEBUG((LM_DEBUG,
                     ACE_TEXT("invalid/unknown cursor type (was: \"%s\"), aborting\n"),
                     ACE_TEXT(RPG_Graphics_CursorHelper::RPG_Graphics_CursorToString(hotspot->getCursorType()).c_str())));

          return;
        }
      } // end SWITCH

      // redraw
      try
      {
        level_window->draw();
        level_window->getArea(dirtyRegion_out);
      }
      catch (...)
      {
        ACE_DEBUG((LM_ERROR,
                  ACE_TEXT("caught exception in RPG_Graphics_IWindowBase::draw/getArea, continuing\n")));
      }
      RPG_GRAPHICS_CURSOR_MANAGER_SINGLETON::instance()->reset(true);

//       ACE_DEBUG((LM_DEBUG,
//                  ACE_TEXT("scrolled map (%s)...\n"),
//                  ACE_TEXT(RPG_Graphics_TypeHelper::RPG_Graphics_TypeToString(hotspot->getHotSpotType()).c_str())));

      break;
    }
    case RPG_GRAPHICS_SDL_MOUSEMOVEOUT:
    {
//       ACE_DEBUG((LM_DEBUG,
//                  ACE_TEXT("RPG_GRAPHICS_SDL_MOUSEMOVEOUT event...\n")));

      break;
    }
    default:
    {
      ACE_DEBUG((LM_ERROR,
                 ACE_TEXT("received unknown event (was: %u)...\n"),
                 static_cast<unsigned int>(event_in.type)));

      break;
    }
  } // end SWITCH

  // if necessary, reset last hover time
  if (event_in.type != RPG_GRAPHICS_SDL_HOVEREVENT)
    myLastHoverTime = 0;

  // pass events to any children ?
  if (window_in == this)
  {
    SDL_Rect dirty_region;
    ACE_OS::memset(&dirty_region, 0, sizeof(dirty_region));
    inherited::handleEvent(event_in,
                           window_in,
                           dirty_region);
    dirtyRegion_out = RPG_Graphics_SDL_Tools::boundingBox(dirty_region,
                                                          dirtyRegion_out);
  } // end IF
}
예제 #8
0
#include "test_config.h"


#include "Cfg.h"
#include "PSession.h"

#include "ace/INET_Addr.h"
//#include "ace/Countdown_Time.h"

#include "Asynch_RW.h"

static TestCfg cfg;

static ACE_TCHAR complete_message[] =
  ACE_TEXT ("GET / HTTP/1.1\r\n")
  ACE_TEXT ("Accept: */*\r\n")
  ACE_TEXT ("Accept-Language: C++\r\n")
  ACE_TEXT ("Accept-Encoding: gzip, deflate\r\n")
  ACE_TEXT ("User-Agent: P_Test /1.0 (non-compatible)\r\n")
  ACE_TEXT ("Connection: Keep-Alive\r\n")
  ACE_TEXT ("\r\n");


#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION)

template class TRB_Asynch_Acceptor<PSession>;
template class TRB_Asynch_Connector<PSession>;
template class TRB_Asynch_RW<TRB_Asynch_Read_Stream,TRB_Asynch_Write_Stream>;
template class TRB_Asynch_RW_Stream<TRB_Asynch_Read_Stream,TRB_Asynch_Write_Stream>;
예제 #9
0
 // Virtual from PSession
 virtual const ACE_TCHAR * get_name (void) const 
   {
      return ACE_TEXT("Sender");
   }
예제 #10
0
int
ACE_SUN_Proactor::handle_events_i (ACE_Time_Value *delta)
{
  int retval = 0;
  aio_result_t *result = 0;

  if (0 == delta)
    {
      if (this->num_started_aio_ == 0)
        this->wait_for_start (0);

      result = aiowait (0);
    }
  else
    {
      if (this->num_started_aio_ == 0)
        {
          // Decrement delta with the amount of time spent waiting
          ACE_Countdown_Time countdown (delta);
          ACE_Time_Value tv (*delta);
          tv += ACE_OS::gettimeofday ();
          if (this->wait_for_start (&tv) == -1)
            return -1;
        }
      struct timeval delta_tv = *delta;
      result = aiowait (&delta_tv);
    }

  if (result == 0)
    {
      // timeout, do nothing,
      // we should process "post_completed" queue
    }
  else if (reinterpret_cast<long> (result) == -1)
    {
      // Check errno  for  EINVAL,EAGAIN,EINTR ??
      switch (errno)
       {
       case EINTR :     // aiowait() was interrupted by a signal.
       case EINVAL:     // there are no outstanding asynchronous I/O requests.
         break;         // we should process "post_completed" queue

       default:         // EFAULT
         ACE_ERROR_RETURN ((LM_ERROR,
                       ACE_TEXT("%N:%l:(%P | %t)::%p \nNumAIO=%d\n"),
                       ACE_TEXT("ACE_SUN_Proactor::handle_events: aiowait failed"),
                        num_started_aio_),
                      -1);
       }
    }
  else
    {
      int error_status = 0;
      size_t transfer_count = 0;

      ACE_POSIX_Asynch_Result *asynch_result =
        find_completed_aio (result,
                            error_status,
                            transfer_count);

      if (asynch_result != 0)
        {
          // Call the application code.
          this->application_specific_code (asynch_result,
                                           transfer_count,
                                           0,             // No completion key.
                                           error_status); // Error
          retval++;
        }
    }

  // process post_completed results
  retval += this->process_result_queue ();

  return retval > 0 ? 1 : 0 ;

}
예제 #11
0
#include "../Scheduler.h"
#include "tao/RTScheduling/RTScheduler_Manager.h"
#include "testC.h"
#include "ace/Get_Opt.h"
#include "ace/SString.h"

ACE_TString ior = ACE_TEXT("file://test.ior");

int
parse_args (int argc,
            ACE_TCHAR* argv [])
{
  // Parse command line arguments
  ACE_Get_Opt opts (argc, argv, ACE_TEXT("f:"));

  int c;
  while ((c= opts ()) != -1)
    {
      switch (c)
        {
        case 'f':
          ior = ACE_TEXT("file://");
          ior += opts.opt_arg ();
          break;
        default:
          ACE_DEBUG ((LM_DEBUG, "Unknown Option\n"));
          return -1;
        }
    }
  return 0;
}
예제 #12
0
파일: Registry.cpp 프로젝트: CCJY/ACE
// of Win32 Reg*() functions
#define ACE_REGISTRY_CALL_RETURN(X) \
  do { \
    if (X != ERROR_SUCCESS) \
    { \
      errno = X; \
      return -1; \
    } \
    else \
      return 0; \
    } while (0)


ACE_BEGIN_VERSIONED_NAMESPACE_DECL

ACE_TCHAR const ACE_Registry::STRING_SEPARATOR[] = ACE_TEXT ("\\");

bool
ACE_Registry::Name_Component::operator== (const Name_Component &rhs) const
{
  return
    rhs.id_ == this->id_ &&
    rhs.kind_ == this->kind_;
}

bool
ACE_Registry::Name_Component::operator!= (const Name_Component &rhs) const
{
  return !this->operator== (rhs);
}
int
ACE_Bounded_Cached_Connect_Strategy<SVC_HANDLER, ACE_PEER_CONNECTOR_2, CACHING_STRATEGY, ATTRIBUTES, MUTEX>::find_or_create_svc_handler_i
(SVC_HANDLER *&sh,
 const ACE_PEER_CONNECTOR_ADDR &remote_addr,
 ACE_Time_Value *timeout,
 const ACE_PEER_CONNECTOR_ADDR &local_addr,
 bool reuse_addr,
 int flags,
 int perms,
 ACE_Hash_Map_Entry<ACE_Refcounted_Hash_Recyclable<ACE_PEER_CONNECTOR_ADDR>,
 std::pair<SVC_HANDLER *, ATTRIBUTES> > *&entry,
 int &found)
{

  REFCOUNTED_HASH_RECYCLABLE_ADDRESS search_addr (remote_addr);

  // Try to find the address in the cache.  Only if we don't find it
  // do we create a new <SVC_HANDLER> and connect it with the server.
  while (this->find (search_addr, entry) != -1)
    {
      // We found a cached svc_handler.
      // Get the cached <svc_handler>
      sh = entry->int_id_.first ();

      // Is the connection clean?
      int state_result= ACE::handle_ready (sh->peer ().get_handle (),
                                           &ACE_Time_Value::zero,
                                           1, // read ready
                                           0, // write ready
                                           1);// exception ready

      if (state_result == 1)
        {
          // The connection was disconnected during idle.
          // close the svc_handler down.
          if (sh->close () == -1)
            {
              ACE_ASSERT (0);
              return -1;
            }
          sh = 0;
          // and rotate once more...
        }
      else if ((state_result == -1) && (errno == ETIME))
        {
          // Found!!!
          // Set the flag
          found = 1;

          // Tell the <svc_handler> that it should prepare itself for
          // being recycled.
          if (this->prepare_for_recycling (sh) == -1)
            {
              ACE_ASSERT (0);
              return -1;
            }

          return 0;
        }
      else  // some other return value or error...
        {
          ACE_ASSERT (0); // just to see it coming

          ACE_ERROR ((LM_ERROR,
                      ACE_TEXT ("(%t)ACE_Bounded_Cached_Connect_Strategy<>::")
                      ACE_TEXT ("find_or_create_svc_handler_i - ")
                      ACE_TEXT ("error polling server socket state.\n")));

          return -1;
        }
    }

  // Not found...

  // Set the flag
  found = 0;

  // Check the limit of handlers...
  if ((this->max_size_ > 0) &&
      (this->connection_cache_.current_size () >= this->max_size_))
    {
      // Try to purge idle connections
      if (this->purge_connections () == -1)
        return -1;

      // Check limit again.
      if (this->connection_cache_.current_size () >= this->max_size_)
        // still too much!
        return -1;

      // OK, we have room now...
    }

  // We need to use a temporary variable here since we are not
  // allowed to change <sh> because other threads may use this
  // when we let go of the lock during the OS level connect.
  //
  // Note that making a new svc_handler, connecting remotely,
  // binding to the map, and assigning of the hint and recycler
  // should be atomic to the outside world.
  SVC_HANDLER *potential_handler = 0;

  // Create a new svc_handler
  if (this->make_svc_handler (potential_handler) == -1)
    return -1;

  // Connect using the svc_handler.
  if (this->cached_connect (potential_handler,
                            remote_addr,
                            timeout,
                            local_addr,
                            reuse_addr,
                            flags,
                            perms) == -1)
    {
      // Close the svc handler.
      potential_handler->close (0);
      return -1;
    }
  else
    {
      // Insert the new SVC_HANDLER instance into the cache.
      if (this->connection_cache_.bind (search_addr,
                                        potential_handler,
                                        entry) == -1)
        {
          // Close the svc handler and reset <sh>.
          potential_handler->close (0);

          return -1;
        }

      // Everything succeeded as planned. Assign <sh> to
      // <potential_handler>.
      sh = potential_handler;

      // Set the recycler and the recycling act
      this->assign_recycler (sh, this, entry);
    }

  return 0;
}
int
run_main (int argc, ACE_TCHAR *argv[])
{
#if defined (ACE_LACKS_FORK)
  ACE_UNUSED_ARG (argc);
  ACE_UNUSED_ARG (argv);

  ACE_START_TEST (ACE_TEXT ("Process_Mutex_Test"));
  ACE_ERROR ((LM_INFO,
              ACE_TEXT ("fork is not supported on this platform\n")));
  ACE_END_TEST;
#else  /* ! ACE_LACKS_FORK */

  parse_args (argc, argv);

  // Child process code.
  if (child_process)
    {
      ACE_APPEND_LOG ("Process_Mutex_Test-children");
      acquire_release ();
      ACE_END_LOG;
    }
  else
    {
      ACE_START_TEST (ACE_TEXT ("Process_Mutex_Test"));
      ACE_INIT_LOG ("Process_Mutex_Test-children");

      ACE_Process_Options options;
      if (release_mutex == 0)
        options.command_line (ACE_TEXT (".") ACE_DIRECTORY_SEPARATOR_STR
                              ACE_TEXT ("Process_Mutex_Test")
                              ACE_PLATFORM_EXE_SUFFIX
                              ACE_TEXT (" -c -n %s -d"),
                              ACE_TEXT_CHAR_TO_TCHAR (mutex_name));
      else
        options.command_line (ACE_TEXT (".") ACE_DIRECTORY_SEPARATOR_STR
                              ACE_TEXT ("Process_Mutex_Test")
                              ACE_PLATFORM_EXE_SUFFIX
                              ACE_TEXT (" -c -n %s"),
                              ACE_TEXT_CHAR_TO_TCHAR (mutex_name));

      // Spawn <n_processes> child processes that will contend for the
      // lock.
      ACE_Process children[n_processes];
      size_t i;

      for (i = 0;
           i < n_processes;
           i++)
        {
          // Spawn the child process.
          int result = children[i].spawn (options);
          ACE_ASSERT (result != -1);
          ACE_DEBUG ((LM_DEBUG,
                      ACE_TEXT ("Parent spawned child process with pid = %d.\n"),
                      children[i].getpid ()));

          // Give the newly spawned child process a chance to start...
          // David Levine thinks this sleep() is required because
          // calling ::waitpid () before a fork'ed child has actually
          // been created may be a problem on some platforms.  It's
          // not enough for fork() to have returned to the parent.
          ACE_OS::sleep (1);
        }

      for (i = 0; i < n_processes; i++)
        {
          ACE_exitcode child_status;
          // Wait for the child processes we created to exit.
          ACE_ASSERT (children[i].wait (&child_status) != -1);
          if (child_status == 0)
            ACE_DEBUG ((LM_DEBUG,
                        ACE_TEXT ("Child %d finished ok\n"),
                        children[i].getpid ()));
          else
            ACE_ERROR ((LM_ERROR,
                        ACE_TEXT ("Child %d finished with status %d\n"),
                        children[i].getpid (), child_status));
        }

      ACE_END_TEST;
    }
#endif /* ! ACE_LACKS_FORK */

  return 0;
}
예제 #15
0
void
Writer::write(bool reliable, int num_messages)
{
  DDS::InstanceHandleSeq handles;

  try {
    // Block until Subscriber is available
    wait_for_match(writer1_);
    wait_for_match(writer2_);
    ACE_DEBUG((LM_DEBUG, ACE_TEXT("(%P|%t) Writers matched\n")));

    // Write samples
    Messenger::MessageDataWriter_var message_dw1
      = Messenger::MessageDataWriter::_narrow(writer1_);
    Messenger::MessageDataWriter_var message_dw2
      = Messenger::MessageDataWriter::_narrow(writer2_);

    if (CORBA::is_nil(message_dw1.in())) {
        ACE_ERROR((LM_ERROR,
                   ACE_TEXT("%N:%l: svc()")
                   ACE_TEXT(" ERROR: _narrow dw1 failed!\n")));
        ACE_OS::exit(-1);
    }

    if (CORBA::is_nil(message_dw2.in())) {
        ACE_ERROR((LM_ERROR,
                   ACE_TEXT("%N:%l: svc()")
                   ACE_TEXT(" ERROR: _narrow dw2 failed!\n")));
        ACE_OS::exit(-1);
    }

    std::ostringstream pid;
    pid << std::setw(5) << my_pid_;

    Messenger::Message message1;
    message1.writer_id  = 1;
    message1.from       = "Comic Book Guy 1";
    message1.process_id = pid.str().c_str();
    message1.text       = "Worst. Movie. Ever.";
    message1.sample_id  = 0;

    Messenger::Message message2 = message1;
    message2.writer_id  = 2;
    message2.from       = "Comic Book Guy 2";

    DDS::InstanceHandle_t handle1 = message_dw1->register_instance(message1);
    DDS::InstanceHandle_t handle2 = message_dw2->register_instance(message2);

    for (int i = 0; i < num_messages; i++) {

      // Because the reader does not have infinite buffer space
      if (!reliable) {
        ACE_OS::sleep(ACE_Time_Value(0,100000));
      }

      extend_sample(message1);
      for (CORBA::ULong j = 0; j < message1.data.length(); ++j) {
        message1.data[j] = j % 256;
      }

      ACE_DEBUG((LM_DEBUG,
                 ACE_TEXT("(%P|%t)%N:%l: Sending Message: process_id = %C ")
                 ACE_TEXT("writer_id = %d ")
                 ACE_TEXT("sample_id = %d ")
                 ACE_TEXT("extra data length = %d\n"),
                 message1.process_id.in(),
                 message1.writer_id,
                 message1.sample_id,
                 message1.data.length()));
      DDS::ReturnCode_t error;
      do {
        error = message_dw1->write(message1, handle1);

        if (error != DDS::RETCODE_OK) {
          if (error == DDS::RETCODE_TIMEOUT) {
            timeout_writes_++;
          } else {
            ACE_ERROR((LM_ERROR,
                       ACE_TEXT("%N:%l: svc()")
                       ACE_TEXT(" ERROR: write dw1 returned %d!\n"), error));
          }
        }
      } while (error == DDS::RETCODE_TIMEOUT);

      extend_sample(message2);
      for (CORBA::ULong j = 0; j < message2.data.length(); ++j) {
        message2.data[j] = 255 - (j % 256);
      }

      ACE_DEBUG((LM_DEBUG,
                 ACE_TEXT("(%P|%t)%N:%l: Sending Message: process_id = %C ")
                 ACE_TEXT("writer_id = %d ")
                 ACE_TEXT("sample_id = %d ")
                 ACE_TEXT("extra data length = %d\n"),
                 message2.process_id.in(),
                 message2.writer_id,
                 message2.sample_id,
                 message2.data.length()));
      do {
        error = message_dw2->write(message2, handle2);
        if (error != DDS::RETCODE_OK) {
          if (error == DDS::RETCODE_TIMEOUT) {
            timeout_writes_++;
          } else {
            ACE_ERROR((LM_ERROR,
                       ACE_TEXT("%N:%l: svc()")
                       ACE_TEXT(" ERROR: write dw2 returned %d!\n"), error));
          }
        }
      } while (error == DDS::RETCODE_TIMEOUT);

      ++message1.sample_id;
      ++message2.sample_id;
    }

    // Let readers disconnect first, once they either get the data or
    // give up and time-out.  This allows the writer to be alive while
    // processing requests for retransmission from the readers.
    wait_for_match(writer1_, false);
    wait_for_match(writer2_, false);

  } catch (const CORBA::Exception& e) {
    e._tao_print_exception("Exception caught in svc():");
  }
}
예제 #16
0
 // Virtual from PSession
 virtual const ACE_TCHAR * get_name (void) const 
   {
      return ACE_TEXT("Receiver");
   }
예제 #17
0
const ACE_TCHAR *
ACE_Proactor::name (void)
{
  return ACE_TEXT ("ACE_Proactor");
}
예제 #18
0
파일: server.cpp 프로젝트: asdlei00/ACE
// $Id: server.cpp 91825 2010-09-17 09:10:22Z johnnyw $

#include "Service.h"

#include "tao/Messaging/Messaging.h"
#include "tao/AnyTypeCode/Any.h"
#include "ace/Get_Opt.h"
#include "ace/OS_NS_stdio.h"

const ACE_TCHAR *ior_output_file = ACE_TEXT("test.ior");

int
parse_args (int argc, ACE_TCHAR *argv[])
{
  ACE_Get_Opt get_opts (argc, argv, ACE_TEXT("o:"));
  int c;

  while ((c = get_opts ()) != -1)
    switch (c)
      {
      case 'o':
        ior_output_file = get_opts.opt_arg ();
        break;
      case '?':
      default:
        ACE_ERROR_RETURN ((LM_ERROR,
                           "usage:  %s "
                           "-o <iorfile>"
                           "\n",
                           argv [0]),
                          -1);
예제 #19
0
int
ACE_SUN_Proactor::start_aio_i (ACE_POSIX_Asynch_Result *result)
{
  ACE_TRACE ("ACE_SUN_Proactor::start_aio_i");

  int ret_val;
  const ACE_TCHAR *ptype;

  // ****** from Sun man pages *********************
  // Upon completion of the operation both aio_return and aio_errno
  // are set to reflect the result of the operation.
  // AIO_INPROGRESS is not a value used by the system
  // so the client may detect a change in state
  // by initializing aio_return to this value.
  result->aio_resultp.aio_return = AIO_INPROGRESS;
  result->aio_resultp.aio_errno  = EINPROGRESS;

  // Start IO
  switch (result->aio_lio_opcode)
    {
    case LIO_READ :
      ptype = ACE_TEXT ("read");
      ret_val = aioread (result->aio_fildes,
                         (char *) result->aio_buf,
                         result->aio_nbytes,
                         result->aio_offset,
                         SEEK_SET,
                         &result->aio_resultp);
      break;

    case LIO_WRITE :
      ptype = ACE_TEXT ("write");
      ret_val = aiowrite (result->aio_fildes,
                          (char *) result->aio_buf,
                          result->aio_nbytes,
                          result->aio_offset,
                          SEEK_SET,
                          &result->aio_resultp);
      break;

    default:
      ptype = ACE_TEXT ("?????");
      ret_val = -1;
      break;
    }

  if (ret_val == 0)
    {
      this->num_started_aio_++;
      if (this->num_started_aio_ == 1)  // wake up condition
        this->condition_.broadcast ();
    }
  else // if (ret_val == -1)
    {
      if (errno == EAGAIN || errno == ENOMEM) // Defer - retry this later.
        ret_val = 1;
      else
        ACE_ERROR ((LM_ERROR,
                    ACE_TEXT ("%N:%l:(%P | %t)::start_aio: aio%s %p\n"),
                    ptype,
                    ACE_TEXT ("queueing failed\n")));
    }

  return ret_val;
}
예제 #20
0
#include "orbsvcs/CosNotifyChannelAdminS.h"
#include "orbsvcs/CosNotifyCommC.h"
#include "orbsvcs/CosNamingC.h"
#include "orbsvcs/TimeBaseC.h"
#include "Notify_StructuredPushSupplier.h"
#include "goS.h"

#include "Notify_Test_Client.h"

// ******************************************************************
// Data Section
// ******************************************************************

static TAO_Notify_Tests_StructuredPushSupplier* supplier_1 = 0;
static int max_events = 20;
static const ACE_TCHAR *ior_output_file = ACE_TEXT ("supplier.ior");
static const ACE_TCHAR *notify2ior = ACE_TEXT ("notify2.ior");

// ******************************************************************
// Subroutine Section
// ******************************************************************
class sig_i : public POA_sig
{
public:
    sig_i(CORBA::ORB_ptr orb)
        : orb_(orb)
        , started_(false)
    {
    }

    void go ()
예제 #21
0
SDL_GUI_MainWindow::~SDL_GUI_MainWindow ()
{
  RPG_TRACE (ACE_TEXT ("SDL_GUI_MainWindow::~SDL_GUI_MainWindow"));

}
예제 #22
0
      //Kokyu timeout generator?
    }
#endif
  return this->TAO_EC_Default_Factory::create_timeout_generator (ec);
}

TAO_EC_Scheduling_Strategy*
TAO_EC_Kokyu_Factory::create_scheduling_strategy (TAO_EC_Event_Channel_Base* ec)
{
  if (this->scheduling_ == 2)
    {
      CORBA::Object_var tmp = ec->scheduler ();
      RtecScheduler::Scheduler_var scheduler =
        RtecScheduler::Scheduler::_narrow (tmp.in ());
      return new TAO_EC_Kokyu_Scheduling (scheduler.in ());
    }
  return this->TAO_EC_Default_Factory::create_scheduling_strategy (ec);
}

TAO_END_VERSIONED_NAMESPACE_DECL

// ****************************************************************

ACE_STATIC_SVC_DEFINE (TAO_EC_Kokyu_Factory,
                       ACE_TEXT ("EC_Factory"),
                       ACE_SVC_OBJ_T,
                       &ACE_SVC_NAME (TAO_EC_Kokyu_Factory),
                       ACE_Service_Type::DELETE_THIS | ACE_Service_Type::DELETE_OBJ,
                       0)
ACE_FACTORY_DEFINE (TAO_RTKokyuEvent, TAO_EC_Kokyu_Factory)
예제 #23
0
bool
SDL_GUI_MainWindow::initMap(state_t* state_in,
                            RPG_Engine* engine_in,
                            const RPG_Client_GraphicsMode& mode_in)
{
  RPG_TRACE(ACE_TEXT("SDL_GUI_MainWindow::initMap"));

  RPG_Graphics_IWindowBase* window_base = NULL;
  switch (mode_in)
  {
    case GRAPHICSMODE_2D_ISOMETRIC:
    {
      ACE_NEW_NORETURN(window_base,
                       SDL_GUI_LevelWindow_Isometric(*this,
                                                     engine_in));
      ACE_ASSERT(window_base);
      // init window
      SDL_GUI_LevelWindow_Isometric* map_window =
          dynamic_cast<SDL_GUI_LevelWindow_Isometric*>(window_base);
      ACE_ASSERT(map_window);
      map_window->init(state_in,
                       this);

      break;
    }
    case GRAPHICSMODE_2D_OPENGL:
    {
      ACE_NEW_NORETURN(window_base,
                       SDL_GUI_LevelWindow_3D(*this,
                                              engine_in));
      ACE_ASSERT(window_base);
      // init window
      SDL_GUI_LevelWindow_3D* map_window =
          dynamic_cast<SDL_GUI_LevelWindow_3D*>(window_base);
      ACE_ASSERT(map_window);
      map_window->init(state_in,
                       this);

      break;
    }
    case GRAPHICSMODE_3D: // *TODO*
    default:
    {
      ACE_DEBUG((LM_ERROR,
                 ACE_TEXT("invalid graphics mode (was: \"%s\"), aborting\n"),
                 ACE_TEXT(RPG_Client_GraphicsModeHelper::RPG_Client_GraphicsModeToString(mode_in).c_str())));

     return false;
    }
  } // end SWITCH
  if (!window_base)
  {
    ACE_DEBUG((LM_CRITICAL,
               ACE_TEXT("failed to allocate memory: %m, aborting\n")));

    return false;
  } // end IF

  // init window
  window_base->setScreen(inherited::screen_);

  return true;
}
예제 #24
0
int
TAO_EC_Kokyu_Factory::init (int argc, ACE_TCHAR* argv[])
{
  ACE_Arg_Shifter arg_shifter (argc, argv);

  while (arg_shifter.is_anything_left ())
    {
      const ACE_TCHAR* arg = arg_shifter.get_current ();

      if (ACE_OS::strcasecmp (arg, ACE_TEXT("-ECDispatching")) == 0)
        {
          arg_shifter.consume_arg ();

          if (arg_shifter.is_parameter_next ())
            {
              const ACE_TCHAR* opt = arg_shifter.get_current ();
              if (ACE_OS::strcasecmp (opt, ACE_TEXT("reactive")) == 0)
                {
                  this->dispatching_ = 0;
                }
              else if (ACE_OS::strcasecmp (opt, ACE_TEXT("mt")) == 0)
                {
                  this->dispatching_ = 1;
                }
              else if (ACE_OS::strcasecmp (opt, ACE_TEXT("kokyu")) == 0)
                {
                  this->dispatching_ = 2;
                }
              else
                {
                  ORBSVCS_ERROR ((LM_ERROR,
                              ACE_TEXT("EC_Kokyu_Factory - ")
                              ACE_TEXT("unsupported dispatching <%s>\n"),
                              opt));
                }
              arg_shifter.consume_arg ();
            }
          //if Kokyu dispatching - look for sched policy
          if (this->dispatching_ == 2)
            {
              if (arg_shifter.is_parameter_next ())
                {
                  const ACE_TCHAR* opt = arg_shifter.get_current ();
                  if (ACE_OS::strcasecmp (opt, ACE_TEXT("SCHED_FIFO")) == 0)
                    {
                      this->disp_sched_policy_ = ACE_SCHED_FIFO;
                    }
                  else if (ACE_OS::strcasecmp (opt, ACE_TEXT("SCHED_RR")) == 0)
                    {
                      this->disp_sched_policy_ = ACE_SCHED_RR;
                    }
                  else
                    {
                      this->disp_sched_policy_ = ACE_SCHED_OTHER;
                    }
                  arg_shifter.consume_arg ();

                  if (arg_shifter.is_parameter_next ())
                    {
                      const ACE_TCHAR* opt = arg_shifter.get_current ();
                      if (ACE_OS::strcasecmp (opt, ACE_TEXT("SYSTEM")) == 0)
                        {
                          this->disp_sched_scope_ = ACE_SCOPE_THREAD;
                        }
                      else if (ACE_OS::strcasecmp (opt, ACE_TEXT("PROCESS")) == 0)
                        {
                          this->disp_sched_scope_ = ACE_SCOPE_PROCESS;
                        }
                      arg_shifter.consume_arg ();
                    }
                }
            }
        }

      else if (ACE_OS::strcasecmp (arg, ACE_TEXT("-ECFiltering")) == 0)
        {
          arg_shifter.consume_arg ();

          if (arg_shifter.is_parameter_next ())
            {
              const ACE_TCHAR* opt = arg_shifter.get_current ();
              if (ACE_OS::strcasecmp (opt, ACE_TEXT("null")) == 0)
                {
                  this->filtering_ = 0;
                }
              else if (ACE_OS::strcasecmp (opt, ACE_TEXT("basic")) == 0)
                {
                  this->filtering_ = 1;
                }
              else if (ACE_OS::strcasecmp (opt, ACE_TEXT("prefix")) == 0)
                {
                  this->filtering_ = 2;
                }
              else if (ACE_OS::strcasecmp (opt, ACE_TEXT("kokyu")) == 0)
                {
                  this->filtering_ = 3;
                }
              else
                {
                  ORBSVCS_ERROR ((LM_ERROR,
                              ACE_TEXT("EC_Kokyu_Factory - ")
                              ACE_TEXT("unsupported filtering <%s>\n"),
                              opt));
                }
              arg_shifter.consume_arg ();
            }
        }

      else if (ACE_OS::strcasecmp (arg, ACE_TEXT("-ECTimeout")) == 0)
        {
          arg_shifter.consume_arg ();

          if (arg_shifter.is_parameter_next ())
            {
              const ACE_TCHAR* opt = arg_shifter.get_current ();
              if (ACE_OS::strcasecmp (opt, ACE_TEXT("reactive")) == 0)
                {
                  this->timeout_ = 0;
                }
#if 0
              else if (ACE_OS::strcasecmp (opt, ACE_TEXT("kokyu")) == 0)
                {
                  this->timeout_ = 1;
                }
#endif /* 0 */
              else
                {
                  ORBSVCS_ERROR ((LM_ERROR,
                              ACE_TEXT("EC_Kokyu_Factory - ")
                              ACE_TEXT("unsupported timeout <%s>\n"),
                              opt));
                }
              arg_shifter.consume_arg ();
            }
        }

      else if (ACE_OS::strcasecmp (arg, ACE_TEXT("-ECScheduling")) == 0)
        {
          arg_shifter.consume_arg ();

          if (arg_shifter.is_parameter_next ())
            {
              const ACE_TCHAR* opt = arg_shifter.get_current ();
              if (ACE_OS::strcasecmp (opt, ACE_TEXT("null")) == 0)
                {
                  this->scheduling_ = 0;
                }
              else if (ACE_OS::strcasecmp (opt, ACE_TEXT("group")) == 0)
                {
                  this->scheduling_ = 1;
                }
              else if (ACE_OS::strcasecmp (opt, ACE_TEXT("kokyu")) == 0)
                {
                  this->scheduling_ = 2;
                }
              else
                {
                  ORBSVCS_ERROR ((LM_ERROR,
                              ACE_TEXT("EC_Kokyu_Factory - ")
                              ACE_TEXT("unsupported scheduling <%s>\n"),
                              opt));
                }
              arg_shifter.consume_arg ();
            }
        }

      else
        {
          arg_shifter.ignore_arg ();
        }
    }
  return this->TAO_EC_Default_Factory::init (argc, argv);
}
예제 #25
0
void
SDL_GUI_MainWindow::drawBorder(SDL_Surface* targetSurface_in,
                               const unsigned int& offsetX_in,
                               const unsigned int& offsetY_in)
{
  RPG_TRACE(ACE_TEXT("SDL_GUI_MainWindow::drawBorder"));

  // sanity check(s)
  SDL_Surface* target_surface = (targetSurface_in ? targetSurface_in
                                                  : inherited::screen_);
  ACE_ASSERT(target_surface);
  ACE_ASSERT(static_cast<int>(offsetX_in) <= target_surface->w);
  ACE_ASSERT(static_cast<int>(offsetY_in) <= target_surface->h);

  lock();

  RPG_Graphics_InterfaceElementsConstIterator_t iterator;
  SDL_Rect dirty_region, prev_clip_rect, clip_rect;
  unsigned int i = 0;

  // step0: retain previous clip rect
  SDL_GetClipRect(target_surface, &prev_clip_rect);

  // step1: draw border elements
  clip_rect.x = static_cast<Sint16>(offsetX_in + borderLeft_);
  clip_rect.y = static_cast<Sint16>(offsetY_in);
  clip_rect.w = static_cast<Uint16>(clipRectangle_.w -
                                    (borderLeft_ + borderRight_));
  clip_rect.h = static_cast<Uint16>(borderTop_);
  if (!SDL_SetClipRect(target_surface, &clip_rect))
  {
    ACE_DEBUG((LM_ERROR,
               ACE_TEXT("failed to SDL_SetClipRect(): %s, aborting\n"),
               ACE_TEXT(SDL_GetError())));

    return;
  } // end IF
  iterator = myElementGraphics.find(INTERFACEELEMENT_BORDER_TOP);
  ACE_ASSERT(iterator != myElementGraphics.end());
  for (i = offsetX_in + borderLeft_;
       i < (static_cast<unsigned int>(clipRectangle_.w) - borderRight_);
       i += (*iterator).second->w)
  {
    RPG_Graphics_Surface::put(std::make_pair(i,
                                             offsetY_in),
                              *(*iterator).second,
                              target_surface,
                              dirty_region);
    invalidate(dirty_region);
  } // end FOR
  if (!SDL_SetClipRect(target_surface, &prev_clip_rect))
  {
    ACE_DEBUG((LM_ERROR,
               ACE_TEXT("failed to SDL_SetClipRect(): %s, aborting\n"),
               ACE_TEXT(SDL_GetError())));

    return;
  } // end IF

  iterator = myElementGraphics.find(INTERFACEELEMENT_BORDER_LEFT);
  ACE_ASSERT(iterator != myElementGraphics.end());
  for (i = (offsetY_in + borderTop_);
       i < (static_cast<unsigned int>(clipRectangle_.h) - borderBottom_);
       i += (*iterator).second->h)
  {
    RPG_Graphics_Surface::put(std::make_pair(offsetX_in,
                                             i),
                              *(*iterator).second,
                              target_surface,
                              dirty_region);
    invalidate(dirty_region);
  } // end FOR

  iterator = myElementGraphics.find(INTERFACEELEMENT_BORDER_RIGHT);
  ACE_ASSERT(iterator != myElementGraphics.end());
  for (i = (offsetY_in + borderTop_);
       i < (static_cast<unsigned int>(clipRectangle_.h) - borderBottom_);
       i += (*iterator).second->h)
  {
    RPG_Graphics_Surface::put(std::make_pair((clipRectangle_.w - borderRight_),
                                             i),
                               *(*iterator).second,
                               target_surface,
                              dirty_region);
    invalidate(dirty_region);
  } // end FOR

  clip_rect.x = static_cast<Sint16>(offsetX_in + borderLeft_);
  clip_rect.y = static_cast<Sint16>(offsetY_in + clipRectangle_.h - borderBottom_);
  clip_rect.w = static_cast<Uint16>(clipRectangle_.w -
                                    (borderLeft_ + borderRight_));
  clip_rect.h = static_cast<Uint16>(borderBottom_);
  if (!SDL_SetClipRect(target_surface, &clip_rect))
  {
    ACE_DEBUG((LM_ERROR,
               ACE_TEXT("failed to SDL_SetClipRect(): %s, aborting\n"),
               ACE_TEXT(SDL_GetError())));

    return;
  } // end IF
  iterator = myElementGraphics.find(INTERFACEELEMENT_BORDER_BOTTOM);
  ACE_ASSERT(iterator != myElementGraphics.end());
  for (i = (offsetX_in + borderLeft_);
       i < (clipRectangle_.w - borderRight_);
       i += (*iterator).second->w)
  {
    RPG_Graphics_Surface::put(std::make_pair(i,
                                             (offsetY_in +
                                              (clipRectangle_.h - borderBottom_))),
                              *(*iterator).second,
                              target_surface,
                              dirty_region);
    invalidate(dirty_region);
  } // end FOR
  if (!SDL_SetClipRect(target_surface, &prev_clip_rect))
  {
    ACE_DEBUG((LM_ERROR,
               ACE_TEXT("failed to SDL_SetClipRect(): %s, aborting\n"),
               ACE_TEXT(SDL_GetError())));

    return;
  } // end IF

  // step2: draw corners
  // NW
  iterator = myElementGraphics.find(INTERFACEELEMENT_BORDER_TOP_LEFT);
  ACE_ASSERT(iterator != myElementGraphics.end());
  RPG_Graphics_Surface::put(std::make_pair(offsetX_in,
                                           offsetY_in),
                            *(*iterator).second,
                            target_surface,
                            dirty_region);
  invalidate(dirty_region);

  // NE
  iterator = myElementGraphics.find(INTERFACEELEMENT_BORDER_TOP_RIGHT);
  ACE_ASSERT(iterator != myElementGraphics.end());
  RPG_Graphics_Surface::put(std::make_pair((clipRectangle_.w -
                                            (*iterator).second->w),
                                           offsetY_in),
                            *(*iterator).second,
                            target_surface,
                            dirty_region);
  invalidate(dirty_region);

  // SW
  iterator = myElementGraphics.find(INTERFACEELEMENT_BORDER_BOTTOM_LEFT);
  ACE_ASSERT(iterator != myElementGraphics.end());
  RPG_Graphics_Surface::put(std::make_pair(offsetX_in,
                                           (clipRectangle_.h -
                                            (*iterator).second->h)),
                            *(*iterator).second,
                            target_surface,
                            dirty_region);
  invalidate(dirty_region);

  // SE
  iterator = myElementGraphics.find(INTERFACEELEMENT_BORDER_BOTTOM_RIGHT);
  ACE_ASSERT(iterator != myElementGraphics.end());
  RPG_Graphics_Surface::put(std::make_pair((clipRectangle_.w -
                                            (*iterator).second->w),
                                           (clipRectangle_.h -
                                            (*iterator).second->h)),
                            *(*iterator).second,
                            target_surface,
                            dirty_region);
  invalidate(dirty_region);

  unlock();
}
예제 #26
0
파일: Mem_Map_Test.cpp 프로젝트: manut/ACE
int
run_main (int, ACE_TCHAR *[])
{
  ACE_START_TEST (ACE_TEXT ("Mem_Map_Test"));

#if !defined (ACE_LACKS_MMAP)

#if defined (__QNXNTO__) || (defined (ACE_VXWORKS) && (ACE_VXWORKS <= 0x670))
  ACE_ERROR ((LM_INFO,
                 ACE_TEXT ("mmap on QNX Neutrino/VxWorks can map only shared memory files\n")));
#endif

  // = Initialize the temporary variable names

  ACE_TCHAR test_file[MAXPATHLEN + 1];
  ACE_TCHAR temp_file1[MAXPATHLEN + 1];
  ACE_TCHAR temp_file2[MAXPATHLEN + 1];

  // Get the temporary directory
  // - 18 is for the filenames, ace_mem_map_temp_1 is the longest
  if (ACE::get_temp_dir (test_file, MAXPATHLEN - 18) == -1)
    ACE_ERROR_RETURN ((LM_ERROR,
                       ACE_TEXT ("Temporary path too long\n")),
                      -1);

  // Copy the temp directory to the other variables
  ACE_OS::strcpy (temp_file1, test_file);
  ACE_OS::strcpy (temp_file2, test_file);

  // Add the filenames to the end
  ACE_OS::strcat (test_file,
                  ACE_TEXT ("ace_mem_map_test"));
  ACE_OS::strcat (temp_file1,
                  ACE_TEXT ("ace_mem_map_temp_1"));
  ACE_OS::strcat (temp_file2,
                  ACE_TEXT ("ace_mem_map_temp_2"));

  // First create a test file to work on
  if (create_test_file (test_file, LINE_LENGTH, NUM_LINES) != 0)
    ACE_ERROR_RETURN ((LM_ERROR,
                       ACE_TEXT ("Create test file failed\n")),
                      -1);
  ACE_Mem_Map mmap;

  // First memory map the test file
  if (mmap.map (test_file) == -1)
    ACE_ERROR_RETURN ((LM_ERROR,
                       ACE_TEXT ("%n: %p %s\n%a"),
                       ACE_TEXT ("mmap"),
                       test_file),
                      -1);

  // Now create a temporary file for intermediate processing
#if defined (__QNXNTO__) || (defined (ACE_VXWORKS) && (ACE_VXWORKS <= 0x670))
  ACE_Mem_Map mmap_4_open;
  mmap_4_open.open(temp_file1,
                   O_RDWR | O_TRUNC | O_CREAT,
                   ACE_DEFAULT_FILE_PERMS);
  ACE_HANDLE temp_file_handle = mmap_4_open.handle();
#else
  ACE_HANDLE temp_file_handle = ACE_OS::open (temp_file1,
                                              O_RDWR | O_TRUNC | O_CREAT,
                                              ACE_DEFAULT_FILE_PERMS);
#endif

  if (temp_file_handle == ACE_INVALID_HANDLE)
    ACE_ERROR_RETURN ((LM_ERROR,
                       ACE_TEXT ("Open failed\n")),
                      -1);

  // Reverse the original file and write the output to the temporary
  // file.
  reverse_file (temp_file_handle,
                (char *) mmap.addr (),
                mmap.size ());
#if defined (__QNXNTO__) || (defined (ACE_VXWORKS) && (ACE_VXWORKS <= 0x670))
  mmap_4_open.close();
#else
  ACE_OS::close (temp_file_handle);
#endif

  ACE_Mem_Map temp_mmap;

  // Now memory map the temporary file
  if (temp_mmap.map (temp_file1) == -1)
    ACE_ERROR_RETURN ((LM_ERROR,
                       ACE_TEXT ("%n: %p %s\n%a"),
                       ACE_TEXT ("mmap"),
                       temp_file1),
                      -1);
#if defined (__QNXNTO__) || (defined (ACE_VXWORKS) && (ACE_VXWORKS <= 0x670))
  mmap_4_open.open(temp_file2,
                   O_RDWR | O_TRUNC | O_CREAT,
                   ACE_DEFAULT_FILE_PERMS);
                   temp_file_handle = mmap_4_open.handle();
#else
  temp_file_handle = ACE_OS::open (temp_file2,
                                   O_RDWR | O_TRUNC | O_CREAT,
                                   ACE_DEFAULT_FILE_PERMS);
#endif
  if ( temp_file_handle == ACE_INVALID_HANDLE)

    ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("Open failed\n")), -1);

  // Now reverse the temporary file and write everything to the second
  // temporary file.
  reverse_file (temp_file_handle,
                (char *) temp_mmap.addr (),
                temp_mmap.size ());
#if defined (__QNXNTO__) || (defined (ACE_VXWORKS) && (ACE_VXWORKS <= 0x670))
  mmap_4_open.close();
#else
  ACE_OS::close (temp_file_handle);
#endif

  // Memory map the second temporary file
  ACE_Mem_Map temp_mmap2;

  if (temp_mmap2.map (temp_file2) == -1)
    ACE_ERROR_RETURN ((LM_ERROR,
                       ACE_TEXT ("%n: %p %s\n%a"),
                       ACE_TEXT ("mmap"),
                       temp_file2),
                      -1);

  // Now do a memcmp -- the orig file and the second temporary file
  // should be identical.
  ACE_TEST_ASSERT (ACE_OS::memcmp (temp_mmap2.addr (),
                              mmap.addr (),
                              mmap.size ()) == 0);

  // Delete the test file
  mmap.remove ();

  // Delete ACE_TEMP_TEST_FILE
  temp_mmap.remove ();

  // Delete ACE_TEMP_TEST_FILE_2
  temp_mmap2.remove ();

#else /* !ACE_LACKS_MMAP */

  ACE_ERROR ((LM_INFO,
              ACE_TEXT ("mmap is not supported on this platform\n")));

#endif /* !ACE_LACKS_MMAP */

  ACE_END_TEST;
  return 0;
}
예제 #27
0
파일: Svc_Conf_Lexer.cpp 프로젝트: CCJY/ACE
int
ACE_Svc_Conf_Lexer::scan (YYSTYPE* ace_yylval,
                          ACE_Svc_Conf_Param* param)

{
  ace_yy_buffer_state* buffer = param->buffer;

  // If we are not currently in any state, skip over whitespace
  if (buffer->state_ == ACE_NO_STATE)
    {
      while (buffer->index_ < buffer->size_ &&
             isspace (buffer->input_[buffer->index_]))
        {
          // Make sure that we count all of the new lines
          if (buffer->input_[buffer->index_] == '\n')
            {
              ++param->yylineno;
            }
          ++buffer->index_;
        }
    }

  size_t current;
  size_t last = buffer->size_ + (buffer->eof_ ? 1 : 0);
  for (current = buffer->index_; current < last; current++)
    {
      static const char* separators = " \t\r\n:*(){}";
      char c = (buffer->eof_ && current == buffer->size_ ?
                                     '\n' : buffer->input_[current]);
      switch (buffer->state_)
        {
          case ACE_COMMENT:
            if (c == '\n')
              {
                buffer->state_ = ACE_NO_STATE;
                buffer->index_ = current + 1;
                ++param->yylineno;
              }
            break;
          case ACE_STRING:
            if (!(c >= ' ' && c <= '~'))
              {
                // The character at currrent is definitely not part of
                // the string so we need to move current back one.
                --current;

                // Get the starting point of our string (skipping the quote)
                char* source = buffer->input_ + buffer->index_ + 1;

                // Now, we need to move back in the string until we find the
                // same character that started the string
                bool string_end_found = false;
                if (current > buffer->index_)
                  {
                    for (size_t i = current - buffer->index_; i-- != 0; )
                      {
                        if (source[i] == buffer->string_start_)
                          {
                            current = buffer->index_ + i + 1;
                            string_end_found = true;
                            break;
                          }
                      }
                  }

                if (!string_end_found)
                  {
                    ace_yyerror (++param->yyerrno,
                                 param->yylineno,
                                 ACE_TEXT ("Unable to find the end of the string"));
                    return ACE_NO_STATE;
                  }

                size_t amount = (current - buffer->index_) - 1;
#if defined (ACE_USES_WCHAR)
                ACE_TCHAR target[ACE_YY_CONVERSION_SPACE] = ACE_TEXT ("");
                size_t length = 0;
                if (!convert_from_utf8 (buffer->converter_,
                                        source,
                                        amount,
                                        target,
                                        ACE_YY_CONVERSION_SPACE,
                                        length))
                  {
                    ace_yyerror (++param->yyerrno,
                                 param->yylineno,
                                 ACE_TEXT ("Unable to convert string from UTF-8"));
                    return ACE_NO_STATE;
                  }
                amount = length;
#else
                char* target = source;
#endif /* ACE_USES_WCHAR */
                ace_yylval->ident_ = param->obstack.copy (target, amount);
                buffer->state_ = ACE_NO_STATE;
                buffer->index_ = current + 1;
                return ACE_STRING;
              }
            break;
          case ACE_NO_STATE:
            if (c == '"' || c == '\'')
              {
                buffer->string_start_ = c;
                buffer->state_ = ACE_STRING;
              }
            else if (c == '#')
              {
                buffer->state_ = ACE_COMMENT;
              }
            else if (ACE_OS::strchr (separators, c) != 0)
              {
                if (c == '\n')
                  {
                    ++param->yylineno;
                  }

                if (current == buffer->index_ + 1)
                  {
                    int const lower = ACE_OS::ace_tolower (
                                          buffer->input_[current - 1]);
                    if (c == ':' &&
                        (buffer->input_[current - 1] == '%' ||
                         (lower >= 'a' && lower <= 'z')))
                      {
                        // This is considered a path, so we need to
                        // skip over the ':' and go around the loop
                        // again
                        break;
                      }
                  }

                if (current == buffer->index_)
                  {
                    buffer->index_ = current + 1;
                    if (isspace (c))
                      {
                        // This is an empty line.
                        // Let's look for something else.
                        break;
                      }
                    else
                      {
                        return c;
                      }
                  }

                // String from buffer->index_ to current (inclusive)
                size_t size = (current - buffer->index_) + 1;
                ACE_TEMPORARY_STRING (str, size);
                ACE_OS::strncpy (str, buffer->input_ + buffer->index_,
                                 size - 1);
                str[size - 1] = '\0';


                if (ACE_OS::strcmp (str, "dynamic") == 0)
                  {
                    buffer->index_ = current;
                    return ACE_DYNAMIC;
                  }
                else if (ACE_OS::strcmp (str, "static") == 0)
                  {
                    buffer->index_ = current;
                    return ACE_STATIC;
                  }
                else if (ACE_OS::strcmp (str, "suspend") == 0)
                  {
                    buffer->index_ = current;
                    return ACE_SUSPEND;
                  }
                else if (ACE_OS::strcmp (str, "resume") == 0)
                  {
                    buffer->index_ = current;
                    return ACE_RESUME;
                  }
                else if (ACE_OS::strcmp (str, "remove") == 0)
                  {
                    buffer->index_ = current;
                    return ACE_REMOVE;
                  }
                else if (ACE_OS::strcmp (str, "stream") == 0)
                  {
                    buffer->index_ = current;
                    return ACE_USTREAM;
                  }
                else if (ACE_OS::strcmp (str, "Module") == 0)
                  {
                    buffer->index_ = current;
                    return ACE_MODULE_T;
                  }
                else if (ACE_OS::strcmp (str, "Service_Object") == 0)
                  {
                    buffer->index_ = current;
                    return ACE_SVC_OBJ_T;
                  }
                else if (ACE_OS::strcmp (str, "STREAM") == 0)
                  {
                    buffer->index_ = current;
                    return ACE_STREAM_T;
                  }
                else if (ACE_OS::strcmp (str, "active") == 0)
                  {
                    buffer->index_ = current;
                    return ACE_ACTIVE;
                  }
                else if (ACE_OS::strcmp (str, "inactive") == 0)
                  {
                    buffer->index_ = current;
                    return ACE_INACTIVE;
                  }
                else
                  {
                    // Get the string and save it in ace_yylval
                    int token = ACE_IDENT;
                    size_t amount = size - 1;
#if defined (ACE_USES_WCHAR)
                    ACE_TCHAR target[ACE_YY_CONVERSION_SPACE] = ACE_TEXT ("");
                    size_t length = 0;
                    if (!convert_from_utf8 (buffer->converter_,
                                            str,
                                            amount,
                                            target,
                                            ACE_YY_CONVERSION_SPACE,
                                            length))
                      {
                        ace_yyerror (++param->yyerrno,
                                     param->yylineno,
                                     ACE_TEXT ("Unable to convert ")
                                     ACE_TEXT ("identifier from UTF-8"));
                        return ACE_NO_STATE;
                      }
                    amount = length;
#else
                    char* target = str;
#endif /* ACE_USES_WCHAR */
                    ace_yylval->ident_ = param->obstack.copy (target, amount);

                    // Determine the difference between pathname and ident
                    if (ACE_OS::ace_isdigit (ace_yylval->ident_[0]))
                      {
                        token = ACE_PATHNAME;
                      }
                    else
                      {
                        static const ACE_TCHAR* path_parts =
                                                ACE_TEXT ("/\\:%.~-");
                        for (const ACE_TCHAR* p = path_parts; *p != '\0'; p++)
                          {
                            if (ACE_OS::strchr (ace_yylval->ident_, *p) != 0)
                              {
                                token = ACE_PATHNAME;
                                break;
                              }
                          }
                      }

                    buffer->state_ = ACE_NO_STATE;
                    buffer->index_ = current;
                    return token;
                  }
              }
            break;
          default:
            ace_yyerror (++param->yyerrno,
                         param->yylineno,
                         ACE_TEXT ("Unexpected state in ACE_Svc_Conf_Lexer::scan"));
            return ACE_NO_STATE;
        }
    }

  // We need more from the input source so, we will move the remainder of
  // the buffer to the front and signal that we need more
  if (!buffer->eof_)
    {
      buffer->need_more_ = true;
      if (buffer->state_ == ACE_COMMENT)
        {
          buffer->index_ = 0;
          buffer->size_  = 0;
        }
      else
        {
          buffer->size_ = current - buffer->index_;
          if (buffer->size_ != 0 && buffer->index_ != 0)
            ACE_OS::memmove (buffer->input_,
                             buffer->input_ + buffer->index_, buffer->size_);
          buffer->index_ = 0;
          buffer->state_ = ACE_NO_STATE;
        }
    }
  return ACE_NO_STATE;
}
예제 #28
0
파일: Mem_Map_Test.cpp 프로젝트: manut/ACE
static int
create_test_file (ACE_TCHAR *filename, int line_length, int num_lines)
{
  char *mybuf = 0;

  ACE_NEW_RETURN (mybuf, char[line_length + 1], -1);
  const char *c = ACE_ALPHABET;
  const char *d = c;
#if defined (__QNXNTO__) || (defined (ACE_VXWORKS) && (ACE_VXWORKS <= 0x670))
  // For NTO has to applied to open the file, as Mem_Map can map only shared memory
  ACE_Mem_Map mmap_4_open;
  mmap_4_open.open (filename, O_RDWR | O_CREAT | O_TRUNC, ACE_DEFAULT_FILE_PERMS);
  ACE_HANDLE file_handle  = mmap_4_open.handle();
#else
  ACE_HANDLE file_handle = ACE_OS::open (filename,
                                         O_RDWR | O_CREAT | O_TRUNC,
                                         ACE_DEFAULT_FILE_PERMS);
#endif
  if (file_handle  == ACE_INVALID_HANDLE)
    {
      delete [] mybuf;
      ACE_ERROR_RETURN ((LM_ERROR,
                         ACE_TEXT ("Open failed for %s\n"),
                         filename),
                        -1);
    }

  for (int j = 0; j < num_lines; j++)
    {
      for (int i = 0; i < line_length; i++)
        {
          mybuf[i] = *c;
          c++;
        }

      mybuf[line_length] = '\0';

      c = ++d;

      if (ACE_OS::write (file_handle, mybuf, line_length) != line_length)
        {
          delete [] mybuf;
          ACE_ERROR_RETURN ((LM_ERROR,
                             ACE_TEXT ("%p (%d) <%s>\n"),
                             ACE_TEXT ("Write to file failed:"),
                             ACE_ERRNO_GET,
                             filename),
                            -1);
        }

      if (ACE_OS::write (file_handle, ACE_TEXT ("\n"), 1) != 1)
        {
          delete [] mybuf;
          ACE_ERROR_RETURN ((LM_ERROR,
                             ACE_TEXT ("write to file %s failed\n"),
                             filename),
                            -1);
        }
    }
#if defined (__QNXNTO__) || (defined (ACE_VXWORKS) && (ACE_VXWORKS <= 0x670))
  mmap_4_open.close();
#else
  ACE_OS::close (file_handle);
#endif

  delete [] mybuf;
  return 0;
}
예제 #29
0
int
TAO::PG_Object_Group::set_primary_member (
    TAO_IOP::TAO_IOR_Property * prop,
    const PortableGroup::Location & the_location)
{
  ACE_GUARD_RETURN (TAO_SYNCH_MUTEX,
                    guard,
                    this->internals_,
                    0);
  int result = 1;
  MemberInfo * info = 0;
  if (this->members_.find (the_location, info) == 0)
    {
      int cleared = 0;
      this->primary_location_ = the_location;
      for (MemberMap_Iterator it = this->members_.begin ();
           !cleared && it != this->members_.end ();
           ++it)
        {
          cleared = (*it).int_id_->is_primary_;
          (*it).int_id_->is_primary_ = 0;
        }
      info->is_primary_ = 1;

      int set_ok =
        this->manipulator_.set_primary (prop,
                                        this->reference_.in (),
                                        info->member_.in ());
      if (!set_ok)
        {
          if (TAO_debug_level > 3)
            {
              ORBSVCS_ERROR ((LM_ERROR,
                          ACE_TEXT ("%T %n (%P|%t) - ")
                          ACE_TEXT ("Can't set primary in IOGR .\n")
                          ));
            }
//@@: ACE_THROW (FT::PrimaryNotSet());
          result = 0;
        }

      if (result && this->increment_version ())
        {
          this->distribute_iogr ();
        }
      else
        {
          if (TAO_debug_level > 3)
            {
              ORBSVCS_DEBUG ((LM_DEBUG,
                          ACE_TEXT("TAO-PG (%P|%t) - set_primary_location ")
                          ACE_TEXT("throwing PrimaryNotSet because increment")
                          ACE_TEXT("version failed.\n")
                          ));
            }
//@@: ACE_THROW (FT::PrimaryNotSet());
          result = 0;
        }
    }
  else
    {
      if (TAO_debug_level > 3)
        {
          ORBSVCS_DEBUG ((LM_DEBUG,
                      ACE_TEXT ("TAO-PG (%P|%t) - set_primary_location ")
                      ACE_TEXT ("throwing MemberNotFound.\n")));
        }
      throw PortableGroup::MemberNotFound();
    }

  return result;
}
void qlTimeSeriesDataReaderListenerImpl::on_dds_exception( DDS::DataReader_ptr reader, CORBA::Exception& exp )
{
  ACE_ERROR((LM_WARNING,
             ACE_TEXT("(%P|%t) WARNING: ")
             ACE_TEXT("qlTimeSeriesDataReaderListenerImpl::on_dds_reading_error %s\n"), exp._info().c_str() ));
}