Log_Message_Receiver<ACE_SYNCH_USE>::Log_Message_Receiver (void) : receiver_impl_ (Log_Message_Receiver_Impl<ACE_SYNCH_USE>::create ()) { ACE_ASSERT (receiver_impl_ != 0); }
void RPG_Graphics_Cursor_Manager::updateBG(SDL_Rect& dirtyRegion_out, const SDL_Rect* clipRect_in, const bool& lockedAccess_in, const bool& debug_in) { RPG_TRACE(ACE_TEXT("RPG_Graphics_Cursor_Manager::updateBG")); // sanity check(s) ACE_ASSERT(myBG); ACE_ASSERT(myHighlightWindow); SDL_Surface* target_surface = myHighlightWindow->getScreen(); ACE_ASSERT(target_surface); // init return value(s) ACE_OS::memset(&dirtyRegion_out, 0, sizeof(dirtyRegion_out)); // *NOTE*: this function handles two distinct use-cases: // 1. the map window has changed (clipRect_in == NULL) --> update that // bit (if any) of the cached bg // 2. a part of the screen has changed (clipRect_in != NULL) // --> update that bit (if any) of the cached bg // step1: set clip area SDL_Rect clip_area = {0, 0, 0, 0}; if (clipRect_in == NULL) myHighlightWindow->getArea(clip_area, false); else clip_area = *clipRect_in; // step2: intersect with cached bg SDL_Rect cached_area; cached_area.x = static_cast<int16_t>(myBGPosition.first); cached_area.y = static_cast<int16_t>(myBGPosition.second); cached_area.w = myBG->w; cached_area.h = myBG->h; SDL_Rect intersection = {0, 0, 0, 0}; intersection = RPG_Graphics_SDL_Tools::intersect(cached_area, clip_area); // sanity check(s) if ((intersection.w == 0) || // cached bg fully outside of "dirty" area ? (intersection.h == 0)) return; // --> nothing to do... if ((intersection.w == cached_area.w) && (intersection.h == cached_area.h)) { // cached cursor bg fully inside of map // --> just get a fresh copy RPG_Graphics_Surface::get(myBGPosition, true, // use (fast) blitting method *target_surface, *myBG); // debug info if (debug_in) { // show bg surface in left upper corner ACE_ASSERT(target_surface->w >= myBG->w); ACE_ASSERT(target_surface->h >= myBG->h); // compute bounding box SDL_Rect dirty_region; dirty_region.x = 0; dirty_region.y = 0; dirty_region.w = myBG->w; dirty_region.h = myBG->h; // RPG_Graphics_Surface::unclip(); if (myScreenLock && lockedAccess_in) myScreenLock->lock(); RPG_Graphics_Surface::put(std::make_pair(dirty_region.x, dirty_region.y), *myBG, target_surface, dirty_region); if (myScreenLock && lockedAccess_in) myScreenLock->unlock(); // RPG_Graphics_Surface::clip(); } // end IF return; // --> done... } // end IF // step3: adjust intersection coordinates (relative to cached bg surface) intersection.x -= cached_area.x; intersection.y -= cached_area.y; // step4: get a fresh copy from that part of the map SDL_Surface* new_bg = RPG_Graphics_Surface::create(static_cast<unsigned int>(myBG->w), static_cast<unsigned int>(myBG->h)); ACE_ASSERT(new_bg); RPG_Graphics_Surface::get(myBGPosition, true, // use (fast) blitting method *target_surface, *new_bg); // step5: mask the "dirty" bit of the cached bg if (SDL_FillRect(myBG, &intersection, RPG_Graphics_SDL_Tools::getColor(COLOR_BLACK_A0, // transparent *myBG))) { ACE_DEBUG((LM_ERROR, ACE_TEXT("failed to SDL_FillRect(): \"%s\", aborting\n"), ACE_TEXT(SDL_GetError()))); // clean up SDL_FreeSurface(new_bg); return; } // end IF // step6: blit the cached bg onto the fresh copy if (SDL_BlitSurface(myBG, // source NULL, // aspect (--> everything) new_bg, // target NULL)) // aspect (--> everything) { ACE_DEBUG((LM_ERROR, ACE_TEXT("failed to SDL_BlitSurface(): %s, aborting\n"), ACE_TEXT(SDL_GetError()))); // clean up SDL_FreeSurface(new_bg); return; } // end IF // clean up SDL_FreeSurface(myBG); myBG = new_bg; // debug info if (debug_in) { // show bg surface in left upper corner ACE_ASSERT(target_surface->w >= myBG->w); ACE_ASSERT(target_surface->h >= myBG->h); // compute bounding box SDL_Rect dirty_region; dirty_region.x = 0; dirty_region.y = 0; dirty_region.w = myBG->w; dirty_region.h = myBG->h; // RPG_Graphics_Surface::unclip(); if (myScreenLock && lockedAccess_in) myScreenLock->lock(); RPG_Graphics_Surface::put(std::make_pair(dirty_region.x, dirty_region.y), *myBG, target_surface, dirty_region); if (myScreenLock && lockedAccess_in) myScreenLock->unlock(); // RPG_Graphics_Surface::clip(); } // end IF }
void RPG_Graphics_Cursor_Manager::storeHighlightBG(const RPG_Map_PositionList_t& mapPositions_in, const RPG_Graphics_Offsets_t& graphicsPositions_in, SDL_Rect& dirtyRegion_out, const bool& lockedAccess_in) { RPG_TRACE(ACE_TEXT("RPG_Graphics_Cursor_Manager::storeHighlightBG")); // sanity check ACE_ASSERT(myHighlightWindow); ACE_ASSERT(!mapPositions_in.empty()); ACE_ASSERT(mapPositions_in.size() == graphicsPositions_in.size()); // init return value(s) ACE_OS::memset(&dirtyRegion_out, 0, sizeof(dirtyRegion_out)); // grow/shrink cache as necessary int delta = myHighlightBGCache.size() - mapPositions_in.size(); if (delta > 0) { for (int i = delta; i > 0; i--) { SDL_FreeSurface(myHighlightBGCache.back().second); myHighlightBGCache.pop_back(); } // end FOR } // end IF else if (delta < 0) { SDL_Surface* new_entry = NULL; for (int i = -delta; i > 0; i--) { new_entry = RPG_Graphics_Surface::create(RPG_GRAPHICS_TILE_FLOOR_WIDTH, RPG_GRAPHICS_TILE_FLOOR_HEIGHT); if (!new_entry) { ACE_DEBUG((LM_ERROR, ACE_TEXT("failed to RPG_Graphics_Surface::create(%u,%u), aborting\n"), RPG_GRAPHICS_TILE_FLOOR_WIDTH, RPG_GRAPHICS_TILE_FLOOR_HEIGHT)); return; } // end IF myHighlightBGCache.push_back(std::make_pair(std::make_pair(std::numeric_limits<unsigned int>::max(), std::numeric_limits<unsigned int>::max()), new_entry)); } // end IF } // end ELSEIF ACE_ASSERT(myHighlightBGCache.size() == mapPositions_in.size()); // step1: restore (part of) the cursor bg so it is not included. This is safe, // as the highlight is only redrawn when the cursor moves --> the cursor will // (later) be redrawn anyway... // --> clip to the highlight area ! RPG_Graphics_OffsetsConstIterator_t graphics_position_iterator = graphicsPositions_in.begin(); SDL_Rect clip_rectangle = {static_cast<Sint16>((*graphics_position_iterator).first), static_cast<Sint16>((*graphics_position_iterator).second), static_cast<Uint16>(myHighlightTile->w), static_cast<Uint16>(myHighlightTile->h)}; SDL_Rect temp_rectangle = {0, 0, static_cast<Uint16>(myHighlightTile->w), static_cast<Uint16>(myHighlightTile->h)}; for (++graphics_position_iterator; graphics_position_iterator != graphicsPositions_in.end(); graphics_position_iterator++) { temp_rectangle.x = static_cast<Sint16>((*graphics_position_iterator).first); temp_rectangle.y = static_cast<Sint16>((*graphics_position_iterator).second); clip_rectangle = RPG_Graphics_SDL_Tools::boundingBox(clip_rectangle, temp_rectangle); } // end FOR if (lockedAccess_in && myScreenLock) myScreenLock->lock(); restoreBG(dirtyRegion_out, &clip_rectangle, false); if (lockedAccess_in && myScreenLock) myScreenLock->unlock(); RPG_Graphics_TileCacheIterator_t cache_iterator = myHighlightBGCache.begin(); graphics_position_iterator = graphicsPositions_in.begin(); // myHighlightWindow->clip(); for (RPG_Map_PositionListConstIterator_t map_position_iterator = mapPositions_in.begin(); map_position_iterator != mapPositions_in.end(); map_position_iterator++, graphics_position_iterator++, cache_iterator++) { RPG_Graphics_Surface::clear((*cache_iterator).second); RPG_Graphics_Surface::get(*graphics_position_iterator, true, // use (fast) blitting method *myHighlightWindow->getScreen(), *(*cache_iterator).second); (*cache_iterator).first = *map_position_iterator; } // end FOR // myHighlightWindow->unclip(); }
void RPG_Graphics_Cursor_Manager::restoreHighlightBG(const RPG_Graphics_Position_t& viewPort_in, SDL_Rect& dirtyRegion_out, const SDL_Rect* clipRectangle_in, const bool& lockedAccess_in, const bool& debug_in) { RPG_TRACE(ACE_TEXT("RPG_Graphics_Cursor_Manager::restoreHighlightBG")); // step0: init return value(s) ACE_OS::memset(&dirtyRegion_out, 0, sizeof(dirtyRegion_out)); // sanity check(s) ACE_ASSERT(myHighlightWindow); SDL_Surface* target_surface = myHighlightWindow->getScreen(); ACE_ASSERT(target_surface); ACE_ASSERT(!myHighlightBGCache.empty()); if ((myHighlightBGCache.size() == 1) && (myHighlightBGCache.front().first == std::make_pair(std::numeric_limits<unsigned int>::max(), std::numeric_limits<unsigned int>::max()))) return; // nothing to do SDL_Rect window_area, clip_area, clip_rectangle, source_clip_rectangle; myHighlightWindow->getArea(window_area, true); myHighlightWindow->getArea(clip_area, false); if (clipRectangle_in) clip_area = *clipRectangle_in; RPG_Graphics_Position_t screen_position; SDL_Rect cursor_clip_rectangle = {static_cast<Sint16>(myBGPosition.first), static_cast<Sint16>(myBGPosition.second), static_cast<Uint16>(myBG->w), static_cast<Uint16>(myBG->h)}, temp_rectangle; std::vector<SDL_Rect> cursor_relevant_clip_rectangles; myHighlightWindow->clip(); if (lockedAccess_in && myScreenLock) myScreenLock->lock(); for (RPG_Graphics_TileCacheConstIterator_t iterator = myHighlightBGCache.begin(); iterator != myHighlightBGCache.end(); iterator++) { screen_position = RPG_Graphics_Common_Tools::map2Screen((*iterator).first, std::make_pair(window_area.w, window_area.h), viewPort_in); source_clip_rectangle.x = screen_position.first; source_clip_rectangle.y = screen_position.second; source_clip_rectangle.w = (*iterator).second->w; source_clip_rectangle.h = (*iterator).second->h; clip_rectangle = RPG_Graphics_SDL_Tools::intersect(source_clip_rectangle, clip_area); dirtyRegion_out = RPG_Graphics_SDL_Tools::boundingBox(dirtyRegion_out, clip_rectangle); source_clip_rectangle.x = clip_rectangle.x - screen_position.first; source_clip_rectangle.y = clip_rectangle.y - screen_position.second; if (!clip_rectangle.w || !clip_rectangle.h) continue; // nothing to do... temp_rectangle = clip_rectangle; // restore / clear background if (SDL_BlitSurface((*iterator).second, // source &source_clip_rectangle, // aspect target_surface, // target &clip_rectangle)) // aspect ACE_DEBUG((LM_ERROR, ACE_TEXT("failed to SDL_BlitSurface(): \"%s\", continuing\n"), ACE_TEXT(SDL_GetError()))); temp_rectangle = RPG_Graphics_SDL_Tools::intersect(cursor_clip_rectangle, temp_rectangle); if (temp_rectangle.w || temp_rectangle.h) cursor_relevant_clip_rectangles.push_back(temp_rectangle); } // end FOR if (lockedAccess_in && myScreenLock) myScreenLock->unlock(); myHighlightWindow->unclip(); // *NOTE*: iff the highlight bg(s) intersected the cursor bg, an update is // needed of (that/those bit(s) of) the cursor bg... for (std::vector<SDL_Rect>::const_iterator iterator = cursor_relevant_clip_rectangles.begin(); iterator != cursor_relevant_clip_rectangles.end(); iterator++) { updateBG(temp_rectangle, &(*iterator), lockedAccess_in, debug_in); if (debug_in) dirtyRegion_out = RPG_Graphics_SDL_Tools::boundingBox(temp_rectangle, dirtyRegion_out); } // end FOR }
void RPG_Graphics_Cursor_Manager::setCursor(const RPG_Graphics_Cursor& type_in, SDL_Rect& dirtyRegion_out, const bool& lockedAccess_in) { RPG_TRACE(ACE_TEXT("RPG_Graphics_Cursor_Manager::setCursor")); // step0: init return value(s) ACE_OS::memset(&dirtyRegion_out, 0, sizeof(dirtyRegion_out)); // step1: load graphic (check cache first) RPG_Graphics_Cursor_CacheConstIterator_t iterator = myCache.find(type_in); if (iterator != myCache.end()) myCurrentGraphic = (*iterator).second; else { // not in cache --> (try to) load graphic RPG_Graphics_GraphicTypeUnion type; type.discriminator = RPG_Graphics_GraphicTypeUnion::CURSOR; type.cursor = type_in; RPG_Graphics_t graphic; graphic.category = RPG_GRAPHICS_CATEGORY_INVALID; graphic.type.discriminator = RPG_Graphics_GraphicTypeUnion::INVALID; // retrieve properties from the dictionary graphic = RPG_GRAPHICS_DICTIONARY_SINGLETON::instance()->get(type); ACE_ASSERT((graphic.type.cursor == type_in) && (graphic.type.discriminator == RPG_Graphics_GraphicTypeUnion::CURSOR)); // sanity check if (graphic.category != CATEGORY_CURSOR) { ACE_DEBUG((LM_ERROR, ACE_TEXT("invalid category (was: \"%s\"): \"%s\" not a cursor type, aborting\n"), ACE_TEXT(RPG_Graphics_CategoryHelper::RPG_Graphics_CategoryToString(graphic.category).c_str()), ACE_TEXT(RPG_Graphics_CursorHelper::RPG_Graphics_CursorToString(type_in).c_str()))); return; } // end IF // assemble path std::string filename; RPG_Graphics_Common_Tools::graphicToFile(graphic, filename); ACE_ASSERT(!filename.empty()); // load file myCurrentGraphic = NULL; myCurrentGraphic = RPG_Graphics_Surface::load(filename, // file true); // convert to display format if (!myCurrentGraphic) { ACE_DEBUG((LM_ERROR, ACE_TEXT("failed to RPG_Graphics_Surface::load(\"%s\"), aborting\n"), ACE_TEXT(filename.c_str()))); return; } // end IF // update cache myCache.insert(std::make_pair(type_in, myCurrentGraphic)); iterator = myCache.find(type_in); ACE_ASSERT(iterator != myCache.end()); } // end ELSE // step1: restore old background if (myScreenLock && lockedAccess_in) myScreenLock->lock(); restoreBG(dirtyRegion_out, NULL, false); if (myScreenLock && lockedAccess_in) myScreenLock->unlock(); // step2: create background surface if (myBG) { SDL_FreeSurface(myBG); myBG = NULL; } // end IF myBG = RPG_Graphics_Surface::create((*iterator).second->w, (*iterator).second->h); if (!myBG) { ACE_DEBUG((LM_ERROR, ACE_TEXT("failed to RPG_Graphics_Surface::create(%u,%u), aborting\n"), (*iterator).second->w, (*iterator).second->h)); return; } // end IF myBGPosition = std::make_pair(std::numeric_limits<unsigned int>::max(), std::numeric_limits<unsigned int>::max()); // ACE_DEBUG((LM_DEBUG, // ACE_TEXT("set cursor to: \"%s\"\n"), // ACE_TEXT(RPG_Graphics_TypeHelper::RPG_Graphics_TypeToString(type_in).c_str()))); myCurrentType = type_in; }
int Task::svc (void) { try { CORBA::Object_var object = this->orb_->string_to_object (ior); test_var test = test::_narrow (object.in ()); pid_t pid = ACE_OS::getpid (); CORBA::Long tc = 0; struct timespec millis; millis.tv_sec = 0L; millis.tv_nsec = 50 * 1000000L; // 1e6 nanos per milli ACE_hrtime_t start = ACE_OS::gethrtime(); for (int i = 0; i != iterations; ++i) { // ~20 req/sec means to sleep 50 millis between each ACE_OS::nanosleep(&millis); // ignore signals CORBA::Long mtc = 0; CORBA::Long r = test->method (pid, i, mtc); ACE_ASSERT (r == i); // Assert disappears on with optimizations on. ACE_UNUSED_ARG (r); if (mtc > tc) { // Number of threads increased, so store this. ACE_DEBUG ((LM_DEBUG, "Thread count increased to %d\n", mtc)); tc = mtc; } else if (mtc < tc) { // Number of threads decreased! ACE_DEBUG ((LM_DEBUG, "Thread count decreased to %d\n", mtc)); decreased = true; tc = mtc; } } ACE_hrtime_t duration = ACE_OS::gethrtime() - start; double tp = ((double) iterations) / (duration / 1000000); tp *= 1000.0; ACE_DEBUG ((LM_DEBUG, "Throughput: %d\n", tp)); ACE_OS::sleep (10); CORBA::Long end = 0; CORBA::Long re = test->method (pid, 0, end); ACE_ASSERT (re == 0); // Assert disappears on with optimizations on. ACE_UNUSED_ARG (re); if (end != 0) { ACE_ERROR ((LM_ERROR, "Dynamic thread count should be 0, not %d\n", end)); } if (shutdown_server) { test->shutdown (); } } catch (const CORBA::Exception& ex) { ex._tao_print_exception ("Exception caught:"); return -1; } return 0; }
int ACE_TMAIN(int argc, ACE_TCHAR *argv[]) { try { // Standard initialization: // parse arguments and get all the references (ORB, // RootPOA, RTORB, RTCurrent, POAManager). CORBA::ORB_var orb = CORBA::ORB_init (argc, argv); if (parse_args (argc, argv) != 0) return -1; // Make sure we can support multiple priorities that are required // for this test. if (!check_supported_priorities (orb.in ())) return 2; // Thread Manager for managing task. ACE_Thread_Manager thread_manager; // Create task. Task task (thread_manager, orb.in ()); // Task activation flags. long flags = THR_NEW_LWP | THR_JOINABLE | orb->orb_core ()->orb_params ()->thread_creation_flags (); // Activate task. int result = task.activate (flags); if (result == -1) { if (errno == EPERM) { ACE_ERROR_RETURN ((LM_ERROR, "Cannot create thread with scheduling policy %s\n" "because the user does not have the appropriate privileges, terminating program....\n" "Check svc.conf options and/or run as root\n", sched_policy_name (orb->orb_core ()->orb_params ()->ace_sched_policy ())), 2); } else // Unexpected error. ACE_ASSERT (0); } // Wait for task to exit. result = thread_manager.wait (); ACE_ASSERT (result != -1); } catch (const CORBA::Exception& ex) { ex._tao_print_exception ("Exception caught"); return -1; } return 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); }
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(); }
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 }
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; }
int ACE_TMAIN (int argc, ACE_TCHAR *argv[]) { try { // Initialize the ORB first. CORBA::ORB_var orb = CORBA::ORB_init (argc, argv); CORBA::Object_var object = orb->resolve_initial_references ("RTORB"); RTCORBA::RTORB_var rtorb = RTCORBA::RTORB::_narrow (object.in ()); /* * The following code should be reenabled once the OMG spec has * been fixed such that a RTCORBA::PriorityModelPolicy can be * created by using the ORB::create_policy interface. * { RTCORBA::PriorityModelPolicy_var policy1 = rtorb->create_priority_model_policy (RTCORBA::CLIENT_PROPAGATED, RTCORBA::minPriority); CORBA::Any policy_value; policy_value <<= RTCORBA::CLIENT_PROPAGATED; policy_value <<= RTCORBA::minPriority; CORBA::Policy_var policy = orb->create_policy (RTCORBA::PRIORITY_MODEL_POLICY_TYPE, policy_value); RTCORBA::PriorityModelPolicy_var policy2 = RTCORBA::PriorityModelPolicy::_narrow (policy.in ()); ACE_ASSERT (policy1->priority_model () == policy2->priority_model ()); ACE_ASSERT (policy1->server_priority () == policy2->server_priority ()); } */ { RTCORBA::ThreadpoolId poolid = 0; RTCORBA::ThreadpoolPolicy_var policy1 = rtorb->create_threadpool_policy (poolid); CORBA::Any policy_value; policy_value <<= poolid; CORBA::Policy_var policy = orb->create_policy (RTCORBA::THREADPOOL_POLICY_TYPE, policy_value); RTCORBA::ThreadpoolPolicy_var policy2 = RTCORBA::ThreadpoolPolicy::_narrow (policy.in ()); ACE_ASSERT (policy1->threadpool () == policy2->threadpool ()); } { RTCORBA::ProtocolList empty_protocols; RTCORBA::ServerProtocolPolicy_var policy1 = rtorb->create_server_protocol_policy (empty_protocols); CORBA::Any policy_value; policy_value <<= empty_protocols; CORBA::Policy_var policy = orb->create_policy (RTCORBA::SERVER_PROTOCOL_POLICY_TYPE, policy_value); RTCORBA::ServerProtocolPolicy_var policy2 = RTCORBA::ServerProtocolPolicy::_narrow (policy.in ()); RTCORBA::ProtocolList_var protocols1 = policy1->protocols (); RTCORBA::ProtocolList_var protocols2 = policy2->protocols (); ACE_ASSERT (protocols1->length () == protocols2->length ()); } { RTCORBA::ProtocolList empty_protocols; RTCORBA::ClientProtocolPolicy_var policy1 = rtorb->create_client_protocol_policy (empty_protocols); CORBA::Any policy_value; policy_value <<= empty_protocols; CORBA::Policy_var policy = orb->create_policy (RTCORBA::CLIENT_PROTOCOL_POLICY_TYPE, policy_value); RTCORBA::ClientProtocolPolicy_var policy2 = RTCORBA::ClientProtocolPolicy::_narrow (policy.in ()); RTCORBA::ProtocolList_var protocols1 = policy1->protocols (); RTCORBA::ProtocolList_var protocols2 = policy2->protocols (); ACE_ASSERT (protocols1->length () == protocols2->length ()); } { RTCORBA::PrivateConnectionPolicy_var policy1 = rtorb->create_private_connection_policy (); CORBA::Any policy_value; CORBA::Policy_var policy = orb->create_policy (RTCORBA::PRIVATE_CONNECTION_POLICY_TYPE, policy_value); RTCORBA::PrivateConnectionPolicy_var policy2 = RTCORBA::PrivateConnectionPolicy::_narrow (policy.in ()); } { RTCORBA::PriorityBands empty_priority_bands; RTCORBA::PriorityBandedConnectionPolicy_var policy1 = rtorb->create_priority_banded_connection_policy (empty_priority_bands); CORBA::Any policy_value; policy_value <<= empty_priority_bands; CORBA::Policy_var policy = orb->create_policy (RTCORBA::PRIORITY_BANDED_CONNECTION_POLICY_TYPE, policy_value); RTCORBA::PriorityBandedConnectionPolicy_var policy2 = RTCORBA::PriorityBandedConnectionPolicy::_narrow (policy.in ()); RTCORBA::PriorityBands_var priority_bands1 = policy1->priority_bands (); RTCORBA::PriorityBands_var priority_bands2 = policy2->priority_bands (); ACE_ASSERT (priority_bands1->length () == priority_bands2->length ()); } ACE_DEBUG ((LM_DEBUG, "%s successful\n", argv[0])); orb->destroy (); } catch (const CORBA::Exception& ex) { ex._tao_print_exception ("Exception caught"); return -1; } return 0; }
Log_Message_Receiver<ACE_SYNCH_USE>::~Log_Message_Receiver (void) { ACE_ASSERT (receiver_impl_ != 0); Log_Message_Receiver_Impl<ACE_SYNCH_USE>::detach (receiver_impl_); }
Log_Message_Receiver<ACE_SYNCH_USE>::Log_Message_Receiver (Log_Message_Receiver<ACE_SYNCH_USE> const &rhs) : receiver_impl_ (Log_Message_Receiver_Impl<ACE_SYNCH_USE>::attach (rhs.receiver_impl_)) { ACE_ASSERT (receiver_impl_ != 0); }
///---------------------------------------------------------------------------- /// <summary> /// Executes the operation. /// </summary> /// /// <exceptions> /// MgException /// </exceptions> ///---------------------------------------------------------------------------- void MgOpMoveResource::Execute() { ACE_DEBUG((LM_DEBUG, ACE_TEXT(" (%t) MgOpMoveResource::Execute()\n"))); MG_LOG_OPERATION_MESSAGE(L"MoveResource"); MG_RESOURCE_SERVICE_TRY() MG_LOG_OPERATION_MESSAGE_INIT(m_packet.m_OperationVersion, m_packet.m_NumArguments); ACE_ASSERT(m_stream != NULL); if (3 == m_packet.m_NumArguments || 4 == m_packet.m_NumArguments) { Ptr<MgResourceIdentifier> sourceResource = (MgResourceIdentifier*)m_stream->GetObject(); Ptr<MgResourceIdentifier> destResource = (MgResourceIdentifier*)m_stream->GetObject(); bool overwrite; m_stream->GetBoolean(overwrite); bool cascade = false; if(4 == m_packet.m_NumArguments) { m_stream->GetBoolean(cascade); } BeginExecution(); MG_LOG_OPERATION_MESSAGE_PARAMETERS_START(); MG_LOG_OPERATION_MESSAGE_ADD_STRING((NULL == sourceResource) ? L"MgResourceIdentifier" : sourceResource->ToString().c_str()); MG_LOG_OPERATION_MESSAGE_ADD_SEPARATOR(); MG_LOG_OPERATION_MESSAGE_ADD_STRING((NULL == destResource) ? L"MgResourceIdentifier" : destResource->ToString().c_str()); MG_LOG_OPERATION_MESSAGE_ADD_SEPARATOR(); MG_LOG_OPERATION_MESSAGE_ADD_BOOL(overwrite); MG_LOG_OPERATION_MESSAGE_ADD_SEPARATOR(); MG_LOG_OPERATION_MESSAGE_ADD_BOOL(cascade); MG_LOG_OPERATION_MESSAGE_PARAMETERS_END(); Validate(); m_service->MoveResource(sourceResource, destResource, overwrite, cascade); EndExecution(); } else { MG_LOG_OPERATION_MESSAGE_PARAMETERS_START(); MG_LOG_OPERATION_MESSAGE_PARAMETERS_END(); } if (!m_argsRead) { throw new MgOperationProcessingException(L"MgOpMoveResource.Execute", __LINE__, __WFILE__, NULL, L"", NULL); } // Successful operation MG_LOG_OPERATION_MESSAGE_ADD_STRING(MgResources::Success.c_str()); MG_RESOURCE_SERVICE_CATCH(L"MgOpMoveResource.Execute") if (mgException != NULL) { // Failed operation MG_LOG_OPERATION_MESSAGE_ADD_STRING(MgResources::Failure.c_str()); } // Add access log entry for operation MG_LOG_OPERATION_MESSAGE_ACCESS_ENTRY(); MG_RESOURCE_SERVICE_THROW() }
int ACE_TMAIN(int argc, ACE_TCHAR *argv[]) { try { // Initialize the ORB. CORBA::ORB_var orb = CORBA::ORB_init (argc, argv); // Obtain the RootPOA. CORBA::Object_var object = orb->resolve_initial_references ("RootPOA"); // Narrow to POA. PortableServer::POA_var root_poa = PortableServer::POA::_narrow (object.in ()); // Get the POAManager of the RootPOA. PortableServer::POAManager_var poa_manager = root_poa->the_POAManager (); // Policies for the new POA. CORBA::PolicyList policies (3); policies.length (3); // Request Processing Policy. policies[0] = root_poa->create_request_processing_policy (PortableServer::USE_DEFAULT_SERVANT); // Id Uniqueness Policy. policies[1] = root_poa->create_id_uniqueness_policy (PortableServer::MULTIPLE_ID); // Servant Retention Policy. policies[2] = root_poa->create_servant_retention_policy (PortableServer::NON_RETAIN); // Create POA to host default servant. ACE_CString name = "Default Servant"; PortableServer::POA_var default_servant_poa = root_poa->create_POA (name.c_str (), poa_manager.in (), policies); // Destroy policies. for (CORBA::ULong i = 0; i < policies.length (); ++i) { CORBA::Policy_ptr policy = policies[i]; policy->destroy (); } // Activate POA manager. poa_manager->activate (); test_reference_to_servant_active_object(root_poa.in ()); // Test servant. test_i test; CORBA::ULong expected_refcount = 1; (void) test_get_servant_with_no_set (default_servant_poa.in()); (void) test_get_servant_manager (default_servant_poa.in()); (void) test_set_servant_manager (default_servant_poa.in()); // Register default servant. default_servant_poa->set_servant (&test); expected_refcount++; // Create dummy id. PortableServer::ObjectId_var id = PortableServer::string_to_ObjectId ("id"); // Create dummy object. object = default_servant_poa->create_reference ("IDL:test:1.0"); // Invoke id_to_servant(). Should retrieve default servant. PortableServer::ServantBase_var servant = default_servant_poa->id_to_servant (id.in ()); expected_refcount++; // Assert correctness. ACE_ASSERT (&test == servant.in()); // Invoke reference_to_servant(). Should retrieve default servant. servant = default_servant_poa->reference_to_servant (object.in ()); expected_refcount++; // Assert correctness. ACE_ASSERT (&test == servant.in()); // Report success. ACE_DEBUG ((LM_DEBUG, "Default_Servant test successful\n")); CORBA::ULong refcount = test._refcount_value (); ACE_UNUSED_ARG (refcount); ACE_UNUSED_ARG (expected_refcount); ACE_ASSERT (expected_refcount == refcount); // Destroy the ORB. orb->destroy (); } catch (const CORBA::Exception& ex) { ex._tao_print_exception ("Exception caught"); return -1; } return 0; }
int ACE_TMAIN(int argc, ACE_TCHAR *argv[]) { try { CORBA::ORB_var orb = CORBA::ORB_init (argc, argv); int result = parse_args (argc, argv); if (result != 0) return result; // Thread Manager for managing task. ACE_Thread_Manager thread_manager; // Create task. Task task (thread_manager, orb.in ()); // Task activation flags. long flags = THR_NEW_LWP | THR_JOINABLE | orb->orb_core ()->orb_params ()->thread_creation_flags (); // Activate task. result = task.activate (flags); if (result == -1) { if (errno == EPERM) { ACE_ERROR_RETURN ((LM_ERROR, "Cannot create thread with scheduling policy %s\n" "because the user does not have the appropriate privileges, terminating program....\n" "Check svc.conf options and/or run as root\n", sched_policy_name (orb->orb_core ()->orb_params ()->ace_sched_policy ())), 2); } else // Unexpected error. ACE_ASSERT (0); } // Wait for task to exit. result = thread_manager.wait (); ACE_ASSERT (result != -1); if (decreased == false) { ACE_ERROR_RETURN ((LM_ERROR, "ERROR: Number of threads didn't decrease\n"), -1); } } catch (const CORBA::Exception& ex) { ex._tao_print_exception ("Exception caught"); return -1; } return 0; }
ACE_CORBA_Ref<CORBA_REF>::operator CORBA_REF * (void) const { ACE_TRACE ("ACE_CORBA_Ref<CORBA_REF>::operator CORBA_REF *"); ACE_ASSERT (ref_ != 0); return ref_; }
/////////////////////////////////////////////////////////////////////////////// /// \brief /// Packages the specified resource. /// void MgLibraryResourceContentManager::PackageResource(MgResourceIdentifier& resource, MgResourcePackageMaker& packageMaker) { ACE_ASSERT(resource.IsFolder()); MG_RESOURCE_SERVICE_TRY() string resourcePathname; MgUtil::WideCharToMultiByte(resource.ToString(), resourcePathname); // Set up an XQuery. XmlManager& xmlMan = m_container.getManager(); XmlQueryContext queryContext = xmlMan.createQueryContext(); string query; if (m_repositoryMan.m_currUserIsAdmin) { queryContext.setEvaluationType(XmlQueryContext::Lazy); query = "collection('"; } else { queryContext.setEvaluationType(XmlQueryContext::Eager); query = "for $i in collection('"; } query += m_container.getName(); query += "')"; query += "/*[starts-with(dbxml:metadata('dbxml:name'),'"; query += resourcePathname; if (m_repositoryMan.m_currUserIsAdmin) { query += "')]"; } else { query += "')] order by dbxml:metadata('dbxml:name', $i) return $i"; } // Execute the XQuery. XmlResults results = IsTransacted() ? xmlMan.query(GetXmlTxn(), query, queryContext, 0) : xmlMan.query(query, queryContext, 0); MgLibraryRepositoryManager& libraryRepositoryMan = (MgLibraryRepositoryManager&)m_repositoryMan; MgResourceDataFileManager* dataFileMan = libraryRepositoryMan.GetResourceDataFileManager(); ACE_ASSERT(NULL != dataFileMan); MgResourceDataStreamManager* dataStreamMan = libraryRepositoryMan.GetResourceDataStreamManager(); ACE_ASSERT(NULL != dataStreamMan); // Get the resources MgResourceIdentifier currResource; XmlValue xmlValue; while (results.next(xmlValue)) { // Note that the permission checks were already done at the time we // packaged the resource headers. const XmlDocument& xmlDoc = xmlValue.asDocument(); currResource.SetResource(MgUtil::MultiByteToWideChar(xmlDoc.getName())); // Package the resource content. if (!packageMaker.PackageResourceContent(currResource, xmlDoc)) { // The current user has no read permission to this resource. continue; } // Skip packaging resource data if there is no resource tag. XmlValue tagValue; if (!xmlDoc.getMetaData(MgResourceInfo::sm_metadataUri, MgResourceInfo::sm_metadataNames[MgResourceInfo::Tags], tagValue)) { continue; } STRING resourceTags; MgUtil::MultiByteToWideChar(tagValue.asString(), resourceTags); // Get the file path if it exists. MgTagManager tagMan(resourceTags); STRING filePath; MgTagInfo filePathTag; if (tagMan.GetTag(MgResourceTag::DataFilePath, filePathTag, false)) { filePath = dataFileMan->GetResourceDataFilePath(); filePath += filePathTag.GetAttribute(MgTagInfo::TokenValue); filePath += L"/"; } // Enumerate the resource data. MgTagMap& tagMap = tagMan.GetTagMap(); for (MgTagMap::const_iterator i = tagMap.begin(); i != tagMap.end(); ++i) { CREFSTRING dataName = (*i).first; // Skip the reserved tags. if (tagMan.IsReservedTag(dataName)) { continue; } // Get the resource data. const MgTagInfo& tagInfo = (*i).second; CREFSTRING mimeType = tagInfo.GetAttribute(MgTagInfo::MimeType); CREFSTRING dataType = tagInfo.GetAttribute(MgTagInfo::StorageType); Ptr<MgByteReader> byteReader; if (MgResourceDataType::File == dataType) { ACE_ASSERT(!filePath.empty()); STRING pathname = filePath; pathname += dataName; byteReader = dataFileMan->GetResourceData(pathname, mimeType); } else if (MgResourceDataType::Stream == dataType) { string dataKey; MgUtil::WideCharToMultiByte( tagInfo.GetAttribute(MgTagInfo::TokenValue), dataKey); byteReader = dataStreamMan->GetResourceData(dataKey, dataName, mimeType); } else if (MgResourceDataType::String == dataType) { string data; MgUtil::WideCharToMultiByte( tagInfo.GetAttribute(MgTagInfo::TokenValue), data); Ptr<MgByteSource> byteSource = new MgByteSource( (BYTE_ARRAY_IN)data.c_str(), (INT32)data.length()); byteSource->SetMimeType(mimeType); byteReader = byteSource->GetReader(); } else { throw new MgInvalidResourceDataTypeException( L"MgLibraryResourceContentManager.PackageResource", __LINE__, __WFILE__, NULL, L"", NULL); } // Package the resource data. packageMaker.PackageResourceData(currResource, byteReader, dataName, dataType); } } MG_RESOURCE_SERVICE_CATCH_AND_THROW(L"MgLibraryResourceContentManager.PackageResource") }
///---------------------------------------------------------------------------- /// <summary> /// Executes the operation. /// </summary> /// /// <exceptions> /// MgException /// </exceptions> ///---------------------------------------------------------------------------- void MgOpGetConnectionPropertyValues::Execute() { ACE_DEBUG((LM_DEBUG, ACE_TEXT(" (%t) MgOpGetConnectionPropertyValues::Execute()\n"))); MG_LOG_OPERATION_MESSAGE(L"GetConnectionPropertyValues"); MG_FEATURE_SERVICE_TRY() MG_LOG_OPERATION_MESSAGE_INIT(m_packet.m_OperationVersion, m_packet.m_NumArguments); ACE_ASSERT(m_stream != NULL); if (3 == m_packet.m_NumArguments) { // Get provider name STRING providerName; m_stream->GetString(providerName); // Get property name STRING propertyName; m_stream->GetString(propertyName); // Get partialConnString name STRING partialConnString; m_stream->GetString(partialConnString); BeginExecution(); MG_LOG_OPERATION_MESSAGE_PARAMETERS_START(); MG_LOG_OPERATION_MESSAGE_ADD_STRING(providerName.c_str()); MG_LOG_OPERATION_MESSAGE_ADD_SEPARATOR(); MG_LOG_OPERATION_MESSAGE_ADD_STRING(propertyName.c_str()); MG_LOG_OPERATION_MESSAGE_ADD_SEPARATOR(); MG_LOG_OPERATION_MESSAGE_ADD_STRING(partialConnString.c_str()); MG_LOG_OPERATION_MESSAGE_PARAMETERS_END(); Validate(); // Execute the operation Ptr<MgStringCollection> strCol = m_service->GetConnectionPropertyValues(providerName, propertyName, partialConnString); // Write the response EndExecution((MgSerializable*)((MgStringCollection*)strCol)); } else { MG_LOG_OPERATION_MESSAGE_PARAMETERS_START(); MG_LOG_OPERATION_MESSAGE_PARAMETERS_END(); } if (!m_argsRead) { throw new MgOperationProcessingException(L"MgOpGetConnectionPropertyValues.Execute", __LINE__, __WFILE__, NULL, L"", NULL); } // Successful operation MG_LOG_OPERATION_MESSAGE_ADD_STRING(MgResources::Success.c_str()); MG_FEATURE_SERVICE_CATCH(L"MgOpGetConnectionPropertyValues.Execute") if (mgException != NULL) { // Failed operation MG_LOG_OPERATION_MESSAGE_ADD_STRING(MgResources::Failure.c_str()); } // Add access log entry for operation MG_LOG_OPERATION_MESSAGE_ACCESS_ENTRY(); MG_FEATURE_SERVICE_THROW() }
///---------------------------------------------------------------------------- /// <summary> /// Executes the operation. /// </summary> /// /// <exceptions> /// MgException /// </exceptions> ///---------------------------------------------------------------------------- void MgOpGetLayer::Execute() { ACE_DEBUG((LM_DEBUG, ACE_TEXT(" (%t) MgOpGetLayer::Execute()\n"))); MG_LOG_OPERATION_MESSAGE(L"GetLayer"); MG_SERVER_DRAWING_SERVICE_TRY() MG_LOG_OPERATION_MESSAGE_INIT(m_packet.m_OperationVersion, m_packet.m_NumArguments); ACE_ASSERT(m_stream != NULL); if (3 == m_packet.m_NumArguments) { Ptr<MgResourceIdentifier> identifier = (MgResourceIdentifier*)m_stream->GetObject(); STRING sectionName; m_stream->GetString(sectionName); STRING layerName; m_stream->GetString(layerName); BeginExecution(); MG_LOG_OPERATION_MESSAGE_PARAMETERS_START(); MG_LOG_OPERATION_MESSAGE_ADD_STRING((NULL == identifier) ? L"MgResourceIdentifier" : identifier->ToString().c_str()); MG_LOG_OPERATION_MESSAGE_ADD_SEPARATOR(); MG_LOG_OPERATION_MESSAGE_ADD_STRING(sectionName.c_str()); MG_LOG_OPERATION_MESSAGE_ADD_SEPARATOR(); MG_LOG_OPERATION_MESSAGE_ADD_STRING(layerName.c_str()); MG_LOG_OPERATION_MESSAGE_PARAMETERS_END(); Validate(); Ptr<MgByteReader> byteReader = m_service->GetLayer(identifier, sectionName, layerName); EndExecution(byteReader); } else { MG_LOG_OPERATION_MESSAGE_PARAMETERS_START(); MG_LOG_OPERATION_MESSAGE_PARAMETERS_END(); } if (!m_argsRead) { throw new MgOperationProcessingException(L"MgOpGetLayer.Execute", __LINE__, __WFILE__, NULL, L"", NULL); } // Successful operation MG_LOG_OPERATION_MESSAGE_ADD_STRING(MgResources::Success.c_str()); MG_SERVER_DRAWING_SERVICE_CATCH(L"MgOpGetLayer.Execute"); if (mgException != NULL) { // Failed operation MG_LOG_OPERATION_MESSAGE_ADD_STRING(MgResources::Failure.c_str()); } // Add access log entry for operation MG_LOG_OPERATION_MESSAGE_ACCESS_ENTRY(); MG_SERVER_DRAWING_SERVICE_THROW() }
void RPG_Map_Pathfinding_Tools::findPath(const RPG_Map_Size_t& size_in, const RPG_Map_Positions_t& obstacles_in, // walls / closed doors const RPG_Map_Position_t& start_in, // start position const RPG_Map_Direction& startDirection_in, // initial direction const RPG_Map_Position_t& end_in, // end position RPG_Map_Path_t& path_out) { RPG_TRACE(ACE_TEXT("RPG_Map_Pathfinding_Tools::findPath")); // init return value(s) path_out.clear(); // sanity check if (start_in == end_in) return; // nothing to do... RPG_Map_AStar_ClosedPath_t closedPath; RPG_Map_AStar_OpenPath_t openPath; RPG_Map_AStar_NodesIterator_t position; RPG_Map_AStar_Position_t start; start.position = start_in; start.last_position = start_in; openPath.insert(std::make_pair(start, RPG_Map_Common_Tools::distance(start_in, end_in))); RPG_Map_AStar_Node_t up, right, down, left; RPG_Map_AStar_NodeList_t neighbours; bool already_visited = false; while (!openPath.empty()) { // *NOTE*: use front (--> "cheapest") node first // add current position to the closed path closedPath.push_back(*openPath.begin()); // finished ? if (closedPath.back().first.position == end_in) break; // compute neighbours neighbours.clear(); up.first = (*openPath.begin()).first; up.first.last_position = (*openPath.begin()).first.position; up.first.position.second -= ((up.first.position.second == 0) ? 0 : 1); right.first = (*openPath.begin()).first; right.first.last_position = (*openPath.begin()).first.position; right.first.position.first += ((right.first.position.first == (size_in.first - 1)) ? 0 : 1); down.first = (*openPath.begin()).first; down.first.last_position = (*openPath.begin()).first.position; down.first.position.second += ((down.first.position.second == (size_in.second - 1)) ? 0 : 1); left.first = (*openPath.begin()).first; left.first.last_position = (*openPath.begin()).first.position; left.first.position.first -= ((left.first.position.first == 0) ? 0 : 1); // ...and costs up.second = RPG_Map_Common_Tools::distance(up.first.position, end_in); right.second = RPG_Map_Common_Tools::distance(right.first.position, end_in); down.second = RPG_Map_Common_Tools::distance(down.first.position, end_in); left.second = RPG_Map_Common_Tools::distance(left.first.position, end_in); // *NOTE*: enforce the constraint of an "initial" starting direction // --> "leave" a room to find another door // start position ? if ((closedPath.back().first.position == start_in) && (startDirection_in != RPG_MAP_DIRECTION_INVALID)) { switch (startDirection_in) { case DIRECTION_UP: { neighbours.push_back(up); break; } case DIRECTION_RIGHT: { neighbours.push_back(right); break; } case DIRECTION_DOWN: { neighbours.push_back(down); break; } case DIRECTION_LEFT: { neighbours.push_back(left); break; } default: { ACE_DEBUG((LM_ERROR, ACE_TEXT("invalid direction (was \"%s\"), continuing\n"), ACE_TEXT(RPG_Map_DirectionHelper::RPG_Map_DirectionToString(startDirection_in).c_str()))); ACE_ASSERT(false); break; } } // end SWITCH } // end IF else { // reachable ? if ((obstacles_in.find(up.first.position) == obstacles_in.end()) || (up.first.position == end_in)) neighbours.push_back(up); if ((obstacles_in.find(right.first.position) == obstacles_in.end()) || (right.first.position == end_in)) neighbours.push_back(right); if ((obstacles_in.find(down.first.position) == obstacles_in.end()) || (down.first.position == end_in)) neighbours.push_back(down); if ((obstacles_in.find(left.first.position) == obstacles_in.end()) || (left.first.position == end_in)) neighbours.push_back(left); } // end ELSE for (RPG_Map_AStar_NodeListConstIterator_t iterator = neighbours.begin(); iterator != neighbours.end(); iterator++) { // already in closed path ? --> discard already_visited = false; for (RPG_Map_AStar_NodeListConstIterator_t iterator2 = closedPath.begin(); iterator2 != closedPath.end(); iterator2++) if ((*iterator).first.position == (*iterator2).first.position) { already_visited = true; break; } // end IF if (already_visited) continue; // already in open path ? --> update if necessary position = openPath.find(*iterator); if (position != openPath.end()) { if ((*iterator).second < (*position).second) { // *TODO*: can this be done without a cast ? const_cast<unsigned int&>((*position).second) = (*iterator).second; } // end IF } // end IF else { // insert node into the list of potential next steps openPath.insert(*iterator); } // end ELSE } // end FOR // finished with this node openPath.erase(closedPath.back()); // // debug info // ACE_DEBUG((LM_DEBUG, // ACE_TEXT("open path[%u node(s)]:\n"), // openPath.size())); // unsigned int index = 0; // for (RPG_Map_AStar_NodesConstIterator_t iterator = openPath.begin(); // iterator != openPath.end(); // iterator++, index++) // { // ACE_DEBUG((LM_DEBUG, // ACE_TEXT("node[#%u]: (%u,%u), last(%u,%u), cost:%u\n"), // index, // (*iterator).first.position.first, // (*iterator).first.position.second, // (*iterator).first.last_position.first, // (*iterator).first.last_position.second, // (*iterator).second)); // } // end FOR // ACE_DEBUG((LM_DEBUG, // ACE_TEXT("closed path[%u node(s)]:\n"), // closedPath.size())); // index = 0; // for (RPG_Map_AStar_NodeListConstIterator_t iterator = closedPath.begin(); // iterator != closedPath.end(); // iterator++, index++) // { // ACE_DEBUG((LM_DEBUG, // ACE_TEXT("node[#%u]: (%u,%u), last(%u,%u), cost:%u\n"), // index, // (*iterator).first.position.first, // (*iterator).first.position.second, // (*iterator).first.last_position.first, // (*iterator).first.last_position.second, // (*iterator).second)); // } // end FOR } // end WHILE // compute (partial) trail if (closedPath.size() == 1) { ACE_ASSERT(closedPath.front().first.position == start_in); // --> must be locked in by obstacles, no trail // debug info ACE_DEBUG((LM_DEBUG, ACE_TEXT("could not find a path [%u,%u] --> [%u,%u], returning\n"), start_in.first, start_in.second, end_in.first, end_in.second)); return; } // end IF unsigned int index = 0; RPG_Map_Direction direction = RPG_MAP_DIRECTION_INVALID; // start at the end RPG_Map_AStar_NodeListConstIterator_t current_node = closedPath.end(); current_node--; // ACE_DEBUG((LM_DEBUG, // ACE_TEXT("step[#%u]: (%u,%u - @%u)\n"), // index, // (*current_node).first.position.first, // (*current_node).first.position.second, // (*current_node).second)); RPG_Map_AStar_NodeListConstIterator_t previous_node = closedPath.begin(); path_out.push_front(std::make_pair((*current_node).first.position, RPG_MAP_DIRECTION_INVALID)); for (; (*current_node).first.position != start_in; index++) { // find previous node for (previous_node = closedPath.begin(); previous_node != closedPath.end(); previous_node++) if ((*previous_node).first.position == (*current_node).first.last_position) break; ACE_ASSERT(previous_node != closedPath.end()); // compute direction if ((*current_node).first.position.second == (*previous_node).first.position.second) if ((*current_node).first.position.first == ((*previous_node).first.position.first + 1)) direction = DIRECTION_RIGHT; else direction = DIRECTION_LEFT; else if ((*current_node).first.position.second == ((*previous_node).first.position.second + 1)) direction = DIRECTION_DOWN; else direction = DIRECTION_UP; // ACE_DEBUG((LM_DEBUG, // ACE_TEXT("step[#%u]: (%u,%u - @%u) --> %s\n"), // index, // (*previous_node).first.position.first, // (*previous_node).first.position.second, // (*previous_node).second, // RPG_Map_Common_Tools::direction2String(direction).c_str())); path_out.push_front(std::make_pair((*previous_node).first.position, direction)); current_node = previous_node; } // end FOR // path_out.push_front(std::make_pair((*current_node).first.position, direction)); //// debug info //if (closedPath.back().first.position != end_in) // ACE_DEBUG((LM_DEBUG, // ACE_TEXT("could not find a path [%u,%u] --> [%u,%u], continuing\n"), // start_in.first, // start_in.second, // end_in.first, // end_in.second)); }
void RPG_Graphics_Cursor_Manager::updateHighlightBG(const RPG_Graphics_Position_t& viewPort_in, SDL_Rect& dirtyRegion_out, const SDL_Rect* clipRectangle_in, const bool& lockedAccess_in, const bool& debug_in) { RPG_TRACE(ACE_TEXT("RPG_Graphics_Cursor_Manager::updateHighlightBG")); // sanity check(s) ACE_ASSERT(myHighlightWindow); SDL_Surface* target_surface = myHighlightWindow->getScreen(); ACE_ASSERT(target_surface); // init return value(s) ACE_OS::memset(&dirtyRegion_out, 0, sizeof(dirtyRegion_out)); SDL_Rect window_area, clip_area, clip_rectangle, source_clip_rectangle; myHighlightWindow->getArea(window_area, true); myHighlightWindow->getArea(clip_area, false); if (clipRectangle_in) clip_area = *clipRectangle_in; RPG_Graphics_Position_t screen_position; SDL_Surface* new_background = NULL; if (myScreenLock && lockedAccess_in && debug_in) myScreenLock->lock(); for (RPG_Graphics_TileCacheIterator_t iterator = myHighlightBGCache.begin(); iterator != myHighlightBGCache.end(); iterator++) { screen_position = RPG_Graphics_Common_Tools::map2Screen((*iterator).first, std::make_pair(window_area.w, window_area.h), viewPort_in); source_clip_rectangle.x = screen_position.first; source_clip_rectangle.y = screen_position.second; source_clip_rectangle.w = (*iterator).second->w; source_clip_rectangle.h = (*iterator).second->h; clip_rectangle = RPG_Graphics_SDL_Tools::intersect(clip_area, source_clip_rectangle); if (!clip_rectangle.w || !clip_rectangle.h) continue; // nothing to do... if ((clip_rectangle.w == (*iterator).second->w) && (clip_rectangle.h == (*iterator).second->h)) { // cached highlight bg completely "dirty" // --> just get a fresh copy RPG_Graphics_Surface::get(screen_position, true, // use (fast) blitting method *target_surface, *(*iterator).second); // debug info if (debug_in) { // show bg surface in left upper corner ACE_ASSERT(target_surface->w >= (*iterator).second->w); ACE_ASSERT(target_surface->h >= (*iterator).second->h); // compute bounding box SDL_Rect dirty_region; dirty_region.x = target_surface->w - (*iterator).second->w; dirty_region.y = target_surface->h - (*iterator).second->h; dirty_region.w = (*iterator).second->w; dirty_region.h = (*iterator).second->h; RPG_Graphics_Surface::put(std::make_pair(dirty_region.x, dirty_region.y), *(*iterator).second, target_surface, dirty_region); dirtyRegion_out = RPG_Graphics_SDL_Tools::boundingBox(dirty_region, dirtyRegion_out); } // end IF continue; } // end IF // get a fresh copy from that part of the map new_background = RPG_Graphics_Surface::create(static_cast<unsigned int>((*iterator).second->w), static_cast<unsigned int>((*iterator).second->h)); if (!new_background) { ACE_DEBUG((LM_ERROR, ACE_TEXT("failed to RPG_Graphics_Surface::create(%u,%u), continuing\n"), (*iterator).second->w, (*iterator).second->h)); continue; } // end IF RPG_Graphics_Surface::get(screen_position, true, // use (fast) blitting method *target_surface, *new_background); // mask the "dirty" bit of the cached bg // --> adjust intersection coordinates (relative to cached bg surface) clip_rectangle.x -= screen_position.first; clip_rectangle.y -= screen_position.second; if (SDL_FillRect((*iterator).second, &clip_rectangle, RPG_Graphics_SDL_Tools::getColor(COLOR_BLACK_A0, // transparent *(*iterator).second))) { ACE_DEBUG((LM_ERROR, ACE_TEXT("failed to SDL_FillRect(): \"%s\", continuing\n"), ACE_TEXT(SDL_GetError()))); // clean up SDL_FreeSurface(new_background); continue; } // end IF // blit the cached/masked bg onto the fresh copy if (SDL_BlitSurface((*iterator).second, // source NULL, // aspect (--> everything) new_background, // target NULL)) // aspect (--> everything) { ACE_DEBUG((LM_ERROR, ACE_TEXT("failed to SDL_BlitSurface(): %s, continuing\n"), ACE_TEXT(SDL_GetError()))); // clean up SDL_FreeSurface(new_background); continue; } // end IF // clean up SDL_FreeSurface((*iterator).second); (*iterator).second = new_background; // debug info if (debug_in) { // show bg surface in left upper corner ACE_ASSERT(target_surface->w >= (*iterator).second->w); ACE_ASSERT(target_surface->h >= (*iterator).second->h); // compute bounding box SDL_Rect dirty_region; dirty_region.x = 0; dirty_region.y = 0; dirty_region.w = (*iterator).second->w; dirty_region.h = (*iterator).second->h; RPG_Graphics_Surface::put(std::make_pair(dirty_region.x, dirty_region.y), *(*iterator).second, target_surface, dirty_region); dirtyRegion_out = RPG_Graphics_SDL_Tools::boundingBox(dirty_region, dirtyRegion_out); } // end IF } // end FOR if (myScreenLock && lockedAccess_in && debug_in) myScreenLock->unlock(); }
int WorldSocket::handle_input_missing_data (void) { char buf [1024]; ACE_Data_Block db ( sizeof (buf), ACE_Message_Block::MB_DATA, buf, 0, 0, ACE_Message_Block::DONT_DELETE, 0); ACE_Message_Block message_block(&db, ACE_Message_Block::DONT_DELETE, 0); const size_t recv_size = message_block.space (); const ssize_t n = peer ().recv (message_block.wr_ptr (), recv_size); if (n <= 0) return n; message_block.wr_ptr (n); while (message_block.length () > 0) { if (m_Header.space () > 0) { //need to receive the header const size_t to_header = (message_block.length () > m_Header.space () ? m_Header.space () : message_block.length ()); m_Header.copy (message_block.rd_ptr (), to_header); message_block.rd_ptr (to_header); if (m_Header.space () > 0) { // Couldn't receive the whole header this time. ACE_ASSERT (message_block.length () == 0); errno = EWOULDBLOCK; return -1; } // We just received nice new header if (handle_input_header () == -1) { ACE_ASSERT ((errno != EWOULDBLOCK) && (errno != EAGAIN)); return -1; } } // Its possible on some error situations that this happens // for example on closing when epoll receives more chunked data and stuff // hope this is not hack ,as proper m_RecvWPct is asserted around if (!m_RecvWPct) { sLog.outError ("Forcing close on input m_RecvWPct = NULL"); errno = EINVAL; return -1; } // We have full read header, now check the data payload if (m_RecvPct.space () > 0) { //need more data in the payload const size_t to_data = (message_block.length () > m_RecvPct.space () ? m_RecvPct.space () : message_block.length ()); m_RecvPct.copy (message_block.rd_ptr (), to_data); message_block.rd_ptr (to_data); if (m_RecvPct.space () > 0) { // Couldn't receive the whole data this time. ACE_ASSERT (message_block.length () == 0); errno = EWOULDBLOCK; return -1; } } //just received fresh new payload if (handle_input_payload () == -1) { ACE_ASSERT ((errno != EWOULDBLOCK) && (errno != EAGAIN)); return -1; } } return n == recv_size ? 1 : 2; }
void RPG_Graphics_Cursor_Manager::putCursor(const RPG_Graphics_Offset_t& offset_in, SDL_Rect& dirtyRegion_out, const bool& lockedAccess_in, const bool& debug_in) { RPG_TRACE(ACE_TEXT("RPG_Graphics_Cursor_Manager::putCursor")); // step0: init return value(s) ACE_OS::memset(&dirtyRegion_out, 0, sizeof(dirtyRegion_out)); // sanity check(s) ACE_ASSERT(myHighlightWindow); SDL_Surface* target_surface = myHighlightWindow->getScreen(); ACE_ASSERT(target_surface); if ((offset_in.first >= target_surface->w) || (offset_in.second >= target_surface->h)) return; // nothing to do ACE_ASSERT(myCurrentGraphic); // step1: restore old background if (myScreenLock && lockedAccess_in) myScreenLock->lock(); restoreBG(dirtyRegion_out, NULL, false); if (myScreenLock && lockedAccess_in) myScreenLock->unlock(); // step2: get new background RPG_Graphics_Surface::get(offset_in, true, // use (fast) blitting method *target_surface, *myBG); myBGPosition = offset_in; SDL_Rect dirty_region; if (debug_in) { // step1: show coordinates in top border std::ostringstream converter; std::string text = ACE_TEXT("["); converter << offset_in.first; text += converter.str(); text += ACE_TEXT(","); converter.str(ACE_TEXT("")); converter.clear(); converter << offset_in.second; text += converter.str(); text += ACE_TEXT("]"); RPG_Graphics_TextSize_t text_size = RPG_Graphics_Common_Tools::textSize(FONT_MAIN_SMALL, text); RPG_Graphics_IWindowBase* parent = myHighlightWindow->getParent(); unsigned int border_top, dummy; parent->getBorders(border_top, dummy, dummy, dummy); SDL_Rect window_area; myHighlightWindow->getArea(window_area, true); static RPG_Graphics_TextSize_t text_size_bg = std::make_pair(0, 0); static SDL_Surface* coordinates_bg = NULL; if (!coordinates_bg) { text_size_bg = RPG_Graphics_Common_Tools::textSize(FONT_MAIN_SMALL, std::string(ACE_TEXT_ALWAYS_CHAR("[0000,0000]"))); coordinates_bg = RPG_Graphics_Surface::create(text_size_bg.first, text_size_bg.second); RPG_Graphics_Surface::get(std::make_pair((((window_area.w / 2) - text_size_bg.first) / 2), ((border_top - text_size_bg.second) / 2)), true, *target_surface, *coordinates_bg); } // end IF else { RPG_Graphics_Surface::put(std::make_pair((((window_area.w / 2) - text_size_bg.first) / 2), ((border_top - text_size_bg.second) / 2)), *coordinates_bg, target_surface, dirty_region); dirtyRegion_out = RPG_Graphics_SDL_Tools::boundingBox(dirty_region, dirtyRegion_out); } // end ELSE // RPG_Graphics_Surface::unclip(); if (myScreenLock && lockedAccess_in) myScreenLock->lock(); RPG_Graphics_Surface::putText(FONT_MAIN_SMALL, text, RPG_Graphics_SDL_Tools::colorToSDLColor(RPG_Graphics_SDL_Tools::getColor(RPG_GRAPHICS_FONT_DEF_COLOR, *target_surface), *target_surface), true, // add shade RPG_Graphics_SDL_Tools::colorToSDLColor(RPG_Graphics_SDL_Tools::getColor(RPG_GRAPHICS_FONT_DEF_SHADECOLOR, *target_surface), *target_surface), std::make_pair((((window_area.w / 2) - text_size.first) / 2), ((border_top - text_size.second) / 2)), target_surface, dirty_region); // step2: show bg surface in left upper corner ACE_ASSERT(target_surface->w >= myBG->w); ACE_ASSERT(target_surface->h >= myBG->h); // compute bounding box dirty_region.x = 0; dirty_region.y = 0; dirty_region.w = myBG->w; dirty_region.h = myBG->h; RPG_Graphics_Surface::put(std::make_pair(dirty_region.x, dirty_region.y), *myBG, target_surface, dirty_region); if (myScreenLock && lockedAccess_in) myScreenLock->unlock(); // RPG_Graphics_Surface::clip(); dirtyRegion_out = RPG_Graphics_SDL_Tools::boundingBox(dirtyRegion_out, dirty_region); } // end IF // step3: place cursor // RPG_Graphics_Surface::unclip(); if (myScreenLock && lockedAccess_in) myScreenLock->lock(); RPG_Graphics_Surface::put(offset_in, *myCurrentGraphic, target_surface, dirty_region); if (myScreenLock && lockedAccess_in) myScreenLock->unlock(); // RPG_Graphics_Surface::clip(); dirtyRegion_out = RPG_Graphics_SDL_Tools::boundingBox(dirtyRegion_out, dirty_region); }
int WorldSocket::ProcessIncoming (WorldPacket* new_pct) { ACE_ASSERT (new_pct); // manage memory ;) ACE_Auto_Ptr<WorldPacket> aptr (new_pct); const ACE_UINT16 opcode = new_pct->GetOpcode (); if (closing_) return -1; // Dump received packet. if (sWorldLog.LogWorld ()) { sWorldLog.Log ("CLIENT:\nSOCKET: %u\nLENGTH: %u\nOPCODE: %s (0x%.4X)\nDATA:\n", (uint32) get_handle (), new_pct->size (), LookupOpcodeName (new_pct->GetOpcode ()), new_pct->GetOpcode ()); uint32 p = 0; while (p < new_pct->size ()) { for (uint32 j = 0; j < 16 && p < new_pct->size (); j++) sWorldLog.Log ("%.2X ", (*new_pct)[p++]); sWorldLog.Log ("\n"); } sWorldLog.Log ("\n\n"); } // like one switch ;) if (opcode == CMSG_PING) { return HandlePing (*new_pct); } else if (opcode == CMSG_AUTH_SESSION) { if (m_Session) { sLog.outError ("WorldSocket::ProcessIncoming: Player send CMSG_AUTH_SESSION again"); return -1; } return HandleAuthSession (*new_pct); } else if (opcode == CMSG_KEEP_ALIVE) { DEBUG_LOG ("CMSG_KEEP_ALIVE ,size: %d", new_pct->size ()); return 0; } else { ACE_GUARD_RETURN (LockType, Guard, m_SessionLock, -1); if (m_Session != NULL) { // OK ,give the packet to WorldSession aptr.release (); // WARNINIG here we call it with locks held. // Its possible to cause deadlock if QueuePacket calls back m_Session->QueuePacket (new_pct); return 0; } else { sLog.outError ("WorldSocket::ProcessIncoming: Client not authed opcode = ", opcode); return -1; } } ACE_NOTREACHED (return 0); }
void RPG_Graphics_Cursor_Manager::putHighlights(const RPG_Map_PositionList_t& mapPositions_in, const RPG_Graphics_Offsets_t& graphicsPositions_in, const RPG_Graphics_Position_t& viewPort_in, SDL_Rect& dirtyRegion_out, const bool& lockedAccess_in, const bool& debug_in) { RPG_TRACE(ACE_TEXT("RPG_Graphics_Cursor_Manager::putHighlights")); // step0: init return value(s) ACE_OS::memset(&dirtyRegion_out, 0, sizeof(dirtyRegion_out)); // sanity check ACE_ASSERT(myHighlightTile); ACE_ASSERT(myHighlightWindow); SDL_Surface* target_surface = myHighlightWindow->getScreen(); ACE_ASSERT(target_surface); // step1: restore old backgrounds if (myScreenLock && lockedAccess_in) myScreenLock->lock(); restoreHighlightBG(viewPort_in, dirtyRegion_out, NULL, false, debug_in); // step2: get new backgrounds SDL_Rect dirty_region; storeHighlightBG(mapPositions_in, graphicsPositions_in, dirty_region, false); dirtyRegion_out = RPG_Graphics_SDL_Tools::boundingBox(dirty_region, dirtyRegion_out); // step3: place highlights std::vector<SDL_Rect> clip_rectangles; SDL_Rect clip_rectangle = {static_cast<Sint16>(myBGPosition.first), static_cast<Sint16>(myBGPosition.second), static_cast<Uint16>(myBG->w), static_cast<Uint16>(myBG->h)}, temp_rectangle; myHighlightWindow->clip(); for (RPG_Graphics_OffsetsConstIterator_t iterator = graphicsPositions_in.begin(); iterator != graphicsPositions_in.end(); iterator++) { RPG_Graphics_Surface::put(*iterator, *myHighlightTile, target_surface, dirty_region); dirtyRegion_out = RPG_Graphics_SDL_Tools::boundingBox(dirty_region, dirtyRegion_out); temp_rectangle = RPG_Graphics_SDL_Tools::intersect(clip_rectangle, dirty_region); if (temp_rectangle.w || temp_rectangle.h) clip_rectangles.push_back(temp_rectangle); } // end FOR if (debug_in) { RPG_Graphics_Offset_t screen_position = graphicsPositions_in.front(); // step1: show coordinates in top border std::ostringstream converter; std::string text = ACE_TEXT("["); converter << screen_position.first; text += converter.str(); text += ACE_TEXT(","); converter.str(ACE_TEXT("")); converter.clear(); converter << screen_position.second; text += converter.str(); text += ACE_TEXT("]"); RPG_Graphics_TextSize_t text_size = RPG_Graphics_Common_Tools::textSize(FONT_MAIN_SMALL, text); RPG_Graphics_IWindowBase* parent = myHighlightWindow->getParent(); unsigned int border_top, dummy; parent->getBorders(border_top, dummy, dummy, dummy); SDL_Rect window_area; myHighlightWindow->getArea(window_area, true); static RPG_Graphics_TextSize_t highlight_text_size_bg = std::make_pair(0, 0); static SDL_Surface* highlight_coordinates_bg = NULL; if (!highlight_coordinates_bg) { highlight_text_size_bg = RPG_Graphics_Common_Tools::textSize(FONT_MAIN_SMALL, std::string(ACE_TEXT_ALWAYS_CHAR("[0000,0000]"))); highlight_coordinates_bg = RPG_Graphics_Surface::create(highlight_text_size_bg.first, highlight_text_size_bg.second); RPG_Graphics_Surface::get(std::make_pair((((window_area.w * 3) / 4) - (highlight_text_size_bg.first / 2)), ((border_top - highlight_text_size_bg.second) / 2)), true, *target_surface, *highlight_coordinates_bg); } // end IF else { RPG_Graphics_Surface::put(std::make_pair((((window_area.w * 3) / 4) - (highlight_text_size_bg.first / 2)), ((border_top - highlight_text_size_bg.second) / 2)), *highlight_coordinates_bg, target_surface, dirty_region); dirtyRegion_out = RPG_Graphics_SDL_Tools::boundingBox(dirty_region, dirtyRegion_out); } // end ELSE RPG_Graphics_Surface::putText(FONT_MAIN_SMALL, text, RPG_Graphics_SDL_Tools::colorToSDLColor(RPG_Graphics_SDL_Tools::getColor(RPG_GRAPHICS_FONT_DEF_COLOR, *target_surface), *target_surface), true, // add shade RPG_Graphics_SDL_Tools::colorToSDLColor(RPG_Graphics_SDL_Tools::getColor(RPG_GRAPHICS_FONT_DEF_SHADECOLOR, *target_surface), *target_surface), std::make_pair((((window_area.w * 3) / 4) - (text_size.first / 2)), ((border_top - text_size.second) / 2)), target_surface, dirty_region); dirtyRegion_out = RPG_Graphics_SDL_Tools::boundingBox(dirty_region, dirtyRegion_out); // step2: show highlight bg in top right corner SDL_Surface* highlight_bg = myHighlightBGCache.front().second; ACE_ASSERT(target_surface->w >= highlight_bg->w); ACE_ASSERT(target_surface->h >= highlight_bg->h); RPG_Graphics_Surface::unclip(); RPG_Graphics_Surface::put(std::make_pair((target_surface->w - highlight_bg->w), 0), *highlight_bg, target_surface, dirty_region); RPG_Graphics_Surface::clip(); dirtyRegion_out = RPG_Graphics_SDL_Tools::boundingBox(dirty_region, dirtyRegion_out); } // end IF // step4: update (part(s) of) cursor bg for (std::vector<SDL_Rect>::const_iterator iterator = clip_rectangles.begin(); iterator != clip_rectangles.end(); iterator++) { updateBG(dirty_region, &(*iterator), false, debug_in); dirtyRegion_out = RPG_Graphics_SDL_Tools::boundingBox(dirty_region, dirtyRegion_out); } // end FOR if (myScreenLock && lockedAccess_in) myScreenLock->unlock(); myHighlightWindow->unclip(); }
int ACE_XtReactor::register_handler_i (ACE_HANDLE handle, ACE_Event_Handler *handler, ACE_Reactor_Mask mask) { ACE_TRACE ("ACE_XtReactor::register_handler_i"); // Make sure we have a valid context ACE_ASSERT (this->context_ != 0); int result = ACE_Select_Reactor::register_handler_i (handle, handler, mask); if (result == -1) return -1; int condition = 0; #if !defined ACE_WIN32 if (ACE_BIT_ENABLED (mask, ACE_Event_Handler::READ_MASK)) ACE_SET_BITS (condition, XtInputReadMask); if (ACE_BIT_ENABLED (mask, ACE_Event_Handler::WRITE_MASK)) ACE_SET_BITS (condition, XtInputWriteMask); if (ACE_BIT_ENABLED (mask, ACE_Event_Handler::EXCEPT_MASK)) ACE_SET_BITS (condition, XtInputExceptMask); if (ACE_BIT_ENABLED (mask, ACE_Event_Handler::ACCEPT_MASK)) ACE_SET_BITS (condition, XtInputReadMask); if (ACE_BIT_ENABLED (mask, ACE_Event_Handler::CONNECT_MASK)){ ACE_SET_BITS (condition, XtInputWriteMask); // connected, you may write ACE_SET_BITS (condition, XtInputReadMask); // connected, you have data/err } #else if (ACE_BIT_ENABLED (mask, ACE_Event_Handler::READ_MASK)) ACE_SET_BITS (condition, XtInputReadWinsock); if (ACE_BIT_ENABLED (mask, ACE_Event_Handler::WRITE_MASK)) ACE_SET_BITS (condition, XtInputWriteWinsock); if (ACE_BIT_ENABLED (mask, ACE_Event_Handler::EXCEPT_MASK)) ACE_NOTSUP_RETURN(-1); if (ACE_BIT_ENABLED (mask, ACE_Event_Handler::ACCEPT_MASK)) ACE_SET_BITS (condition, XtInputReadWinsock); if (ACE_BIT_ENABLED (mask, ACE_Event_Handler::CONNECT_MASK)){ ACE_SET_BITS (condition, XtInputWriteWinsock); // connected, you may write ACE_SET_BITS (condition, XtInputReadWinsock); // connected, you have data/err } #endif /* !ACE_WIN32 */ if (condition != 0) { ACE_XtReactorID *XtID = this->ids_; while(XtID) { if (XtID->handle_ == handle) { ::XtRemoveInput (XtID->id_); XtID->id_ = ::XtAppAddInput (this->context_, (int) handle, (XtPointer) condition, InputCallbackProc, (XtPointer) this); return 0; } else XtID = XtID->next_; } ACE_NEW_RETURN (XtID, ACE_XtReactorID, -1); XtID->next_ = this->ids_; XtID->handle_ = handle; XtID->id_ = ::XtAppAddInput (this->context_, (int) handle, (XtPointer) condition, InputCallbackProc, (XtPointer) this); this->ids_ = XtID; } return 0; }
int ACE_TMAIN (int,ACE_TCHAR**) { Kokyu::DSRT_ConfigInfo config_info; // config_info.scheduler_type_ = Kokyu::SCHED_MIF; config_info.impl_type_ = Kokyu::DSRT_OS_BASED; ACE_Barrier bar (3); ACE_DEBUG ((LM_DEBUG, "before create_dispatcher\n" )); config_info.sched_strategy_ = Kokyu::DSRT_MIF; Kokyu::DSRT_Dispatcher_Factory<mif_scheduler_traits>::DSRT_Dispatcher_Auto_Ptr disp (Kokyu::DSRT_Dispatcher_Factory<mif_scheduler_traits>:: create_DSRT_dispatcher (config_info)); ACE_DEBUG ((LM_DEBUG, "after create_dispatcher\n" )); ACE_ASSERT (disp.get () != 0); mif_scheduler_traits::QoSDescriptor_t qos1, qos2, qos3; qos1.importance_ = 1; qos2.importance_ = 2; qos3.importance_ = 3; MyTask mytask1 (bar, disp.get (), qos1, 15); MyTask mytask2 (bar, disp.get (), qos2, 6); MyTask mytask3 (bar, disp.get (), qos3, 4); long flags = THR_BOUND | THR_SCHED_FIFO; if (mytask1.activate (flags) == -1) { flags = THR_BOUND; if (mytask1.activate (flags) == -1) ACE_ERROR ((LM_ERROR, "EC (%P|%t) cannot activate task\n")); } if (mytask2.activate (flags) == -1) { flags = THR_BOUND; if (mytask2.activate (flags) == -1) ACE_ERROR ((LM_ERROR, "EC (%P|%t) cannot activate task\n")); } if (mytask3.activate (flags) == -1) { flags = THR_BOUND; if (mytask3.activate (flags) == -1) ACE_ERROR ((LM_ERROR, "EC (%P|%t) cannot activate task\n")); } disp->shutdown (); ACE_DEBUG ((LM_DEBUG, "main thread exiting\n")); return 0; }
Log_Message_Receiver_Impl<ACE_SYNCH_USE>::~Log_Message_Receiver_Impl (void) { ACE_ASSERT (count_ == 0 - 1); }