[complement-svn] SF.net SVN: complement: [1315] trunk/explore
Status: Pre-Alpha
Brought to you by:
complement
From: <com...@us...> - 2006-10-12 11:25:19
|
Revision: 1315 http://svn.sourceforge.net/complement/?rev=1315&view=rev Author: complement Date: 2006-10-12 04:25:06 -0700 (Thu, 12 Oct 2006) Log Message: ----------- allow change announce of object's info; return string object instead of const reference from annotate by safety reasons Modified Paths: -------------- trunk/explore/include/stem/EvManager.h trunk/explore/include/stem/EventHandler.h trunk/explore/lib/stem/ChangeLog trunk/explore/lib/stem/_EventHandler.cc trunk/explore/test/libstem/unit/Echo.cc trunk/explore/test/libstem/unit/unit_test.cc Modified: trunk/explore/include/stem/EvManager.h =================================================================== --- trunk/explore/include/stem/EvManager.h 2006-10-12 11:24:15 UTC (rev 1314) +++ trunk/explore/include/stem/EvManager.h 2006-10-12 11:25:06 UTC (rev 1315) @@ -1,4 +1,4 @@ -// -*- C++ -*- Time-stamp: <06/10/10 18:11:49 ptr> +// -*- C++ -*- Time-stamp: <06/10/12 15:10:18 ptr> /* * Copyright (c) 1995-1999, 2002, 2003, 2005, 2006 @@ -122,18 +122,30 @@ return unsafe_is_avail(id); } - const string& who_is( addr_type id ) const + const std::string who_is( addr_type id ) const { MT_REENTRANT( _lock_heap, _x1 ); return unsafe_who_is( id ); } - const string& annotate( addr_type id ) const + const std::string annotate( addr_type id ) const { MT_REENTRANT( _lock_heap, _x1 ); return unsafe_annotate( id ); } + void change_announce( addr_type id, const std::string& info ) + { + MT_REENTRANT( _lock_heap, _x1 ); + unsafe_change_announce( id, info ); + } + + void change_announce( addr_type id, const char *info ) + { + MT_REENTRANT( _lock_heap, _x1 ); + unsafe_change_announce( id, info ); + } + __FIT_DECLSPEC NetTransport_base *transport( addr_type object_id ) const; void push( const Event& e ) @@ -149,17 +161,33 @@ bool unsafe_is_avail( addr_type id ) const { return heap.find( id ) != heap.end(); } - const string& unsafe_who_is( addr_type id ) const + const std::string& unsafe_who_is( addr_type id ) const { heap_type::const_iterator i = heap.find( id ); return i == heap.end() ? inv_key_str : (*i).second.info; } - const string& unsafe_annotate( addr_type id ) const + const std::string& unsafe_annotate( addr_type id ) const { heap_type::const_iterator i = heap.find( id ); return i == heap.end() ? inv_key_str : (*i).second.info; } + void unsafe_change_announce( addr_type id, const std::string& info ) + { + heap_type::iterator i = heap.find( id ); + if ( i != heap.end() ) { + i->second.info = info; + } + } + + void unsafe_change_announce( addr_type id, const char *info ) + { + heap_type::iterator i = heap.find( id ); + if ( i != heap.end() ) { + i->second.info = info; + } + } + private: void Send( const Event& e ); __FIT_DECLSPEC void unsafe_Remove( NetTransport_base * ); Modified: trunk/explore/include/stem/EventHandler.h =================================================================== --- trunk/explore/include/stem/EventHandler.h 2006-10-12 11:24:15 UTC (rev 1314) +++ trunk/explore/include/stem/EventHandler.h 2006-10-12 11:25:06 UTC (rev 1315) @@ -1,4 +1,4 @@ -// -*- C++ -*- Time-stamp: <06/10/10 18:12:54 ptr> +// -*- C++ -*- Time-stamp: <06/10/12 14:12:15 ptr> /* * Copyright (c) 1995-1999, 2002, 2003, 2005, 2006 @@ -7,16 +7,8 @@ * Copyright (c) 1999-2001 * ParallelGraphics Ltd. * - * Licensed under the Academic Free License version 2.1 + * Licensed under the Academic Free License version 3.0 * - * This material is provided "as is", with absolutely no warranty expressed - * or implied. Any use is at your own risk. - * - * Permission to use, copy, modify, distribute and sell this software - * and its documentation for any purpose is hereby granted without fee, - * provided that the above copyright notice appear in all copies and - * that both that copyright notice and this permission notice appear - * in supporting documentation. */ #ifndef __EventHandler_h @@ -535,19 +527,8 @@ } typedef std::list<state_type> HistoryContainer; -// #ifndef __FIT_TEMPLATE_TYPEDEF_BUG typedef HistoryContainer::iterator h_iterator; typedef HistoryContainer::const_iterator const_h_iterator; -// #else // __FIT_TEMPLATE_TYPEDEF_BUG -// be careful: list implementation dependence -// # ifndef __STL_DEBUG -// typedef _List_iterator<state_type, _Nonconst_traits<state_type> > h_iterator; -// typedef _List_iterator<state_type, _Const_traits<state_type> > const_h_iterator; -// # else // HP's aCC A.03.13 nevertheless fail here (or near). -// typedef _DBG_iter<__list<state_type,__STL_DEFAULT_ALLOCATOR(state_type) >, _Nonconst_traits<state_type> > h_iterator; -// typedef _DBG_iter<__list<state_type,__STL_DEFAULT_ALLOCATOR(state_type) >, _Const_traits<state_type> > const_h_iterator; -// # endif -// #endif // __FIT_TEMPLATE_TYPEDEF_BUG _STLP_TEMPLATE_NULL class __EvHandler<EventHandler,h_iterator > @@ -581,7 +562,7 @@ // See comment near EventHandler::EventHandler() implementation // HistoryContainer& theHistory; HistoryContainer theHistory; - __impl::MutexRS _theHistory_lock; + xmt::MutexRS _theHistory_lock; public: @@ -599,7 +580,7 @@ explicit __FIT_DECLSPEC EventHandler( addr_type id, const char *info = 0 ); virtual __FIT_DECLSPEC ~EventHandler(); - __FIT_DECLSPEC const string& who_is( addr_type k ) const; + __FIT_DECLSPEC const std::string who_is( addr_type k ) const; __FIT_DECLSPEC bool is_avail( addr_type id ) const; static EvManager *manager() { return _mgr; } Modified: trunk/explore/lib/stem/ChangeLog =================================================================== --- trunk/explore/lib/stem/ChangeLog 2006-10-12 11:24:15 UTC (rev 1314) +++ trunk/explore/lib/stem/ChangeLog 2006-10-12 11:25:06 UTC (rev 1315) @@ -1,3 +1,13 @@ +2006-10-12 Petr Ovtchenkov <pt...@is...> + + * NetTransport.h, NetTransport.cc: remove make_map, + it useless and even dangerous in practice. + + * EvManager.h, EventHandler.h, _EventHandler.cc: + allow change announce of object's info; return + string object instead of const reference from + annotate by safety reasons. + 2006-10-10 Petr Ovtchenkov <pt...@is...> * NetTransport.h, EventHandler.h, EvManager.h: remove Modified: trunk/explore/lib/stem/_EventHandler.cc =================================================================== --- trunk/explore/lib/stem/_EventHandler.cc 2006-10-12 11:24:15 UTC (rev 1314) +++ trunk/explore/lib/stem/_EventHandler.cc 2006-10-12 11:25:06 UTC (rev 1315) @@ -1,4 +1,4 @@ -// -*- C++ -*- Time-stamp: <06/10/10 18:12:26 ptr> +// -*- C++ -*- Time-stamp: <06/10/12 14:09:20 ptr> /* * Copyright (c) 1995-1999, 2002, 2003, 2005, 2006 @@ -59,7 +59,7 @@ } __FIT_DECLSPEC -const string& EventHandler::who_is( addr_type k ) const +const string EventHandler::who_is( addr_type k ) const { return _mgr->who_is( k ); } Modified: trunk/explore/test/libstem/unit/Echo.cc =================================================================== --- trunk/explore/test/libstem/unit/Echo.cc 2006-10-12 11:24:15 UTC (rev 1314) +++ trunk/explore/test/libstem/unit/Echo.cc 2006-10-12 11:25:06 UTC (rev 1315) @@ -1,4 +1,4 @@ -// -*- C++ -*- Time-stamp: <06/10/11 14:54:52 ptr> +// -*- C++ -*- Time-stamp: <06/10/12 15:12:19 ptr> /* * Copyright (c) 2006 @@ -45,12 +45,8 @@ void StEMecho::regme( const stem::Event& ev ) { + manager()->change_announce( ev.src(), ev.value() ); cnd.set( true ); - stem::NetTransport_base *b = manager()->transport( ev.src() ); - BOOST_CHECK( b != 0 ); - if ( b != 0 ) { - b->make_map( ev.src(), (ev.value() /* + who_is( ev.src() ) */ ).c_str() ); - } } DEFINE_RESPONSE_TABLE( StEMecho ) Modified: trunk/explore/test/libstem/unit/unit_test.cc =================================================================== --- trunk/explore/test/libstem/unit/unit_test.cc 2006-10-12 11:24:15 UTC (rev 1314) +++ trunk/explore/test/libstem/unit/unit_test.cc 2006-10-12 11:25:06 UTC (rev 1315) @@ -1,4 +1,4 @@ -// -*- C++ -*- Time-stamp: <06/10/11 15:36:32 ptr> +// -*- C++ -*- Time-stamp: <06/10/12 15:15:13 ptr> /* * Copyright (c) 2002, 2003, 2006 @@ -390,7 +390,7 @@ stem::Event ev( NODE_EV_REGME ); ev.dest( zero ); - ev.value() = "c1"; + ev.value() = "c1@here"; c1.Send( ev ); // 'register' c1 client on 'echo' server echo.cnd.try_wait(); @@ -398,7 +398,7 @@ PeerClient c2( "c2 local" ); // c2 client - ev.value() = "c2"; + ev.value() = "c2@here"; c2.Send( ev ); // 'register' c2 client on 'echo' server echo.cnd.try_wait(); @@ -423,9 +423,7 @@ BOOST_CHECK( i->first & stem::extbit ); // "external" if ( i->second.find( "c2@" ) == 0 ) { // make pair: address on side of c1 -> address on side of 'echo' - // note: on side of 'echo' server there are mapping too, - // address on side of 'echo' -> address on side of c2 - peer_addr = tr->make_map( i->first, "c2@foreign" ); + peer_addr = c1.manager()->SubscribeRemote( tr, i->first, "c2@foreign" ); } // cerr << hex << i->first << dec << " => " << i->second << endl; // cerr << hex << tr->make_map( i->first, "map" ) << dec << endl; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |