本文整理汇总了C++中Ptr::Close方法的典型用法代码示例。如果您正苦于以下问题:C++ Ptr::Close方法的具体用法?C++ Ptr::Close怎么用?C++ Ptr::Close使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Ptr
的用法示例。
在下文中一共展示了Ptr::Close方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SendPacketEncoder
void SendPacketEncoder (Ptr<Socket> socket, Time pktInterval)
{
if (!m_recoder->is_complete() ||
(!m_recoding_flag && !m_decoder->is_complete()))
{
uint32_t bytes_used = m_encoder->encode(&m_payload_buffer[0]);
auto packet = Create<Packet> (&m_payload_buffer[0], bytes_used);
std::cout << "+----------------------------------+" << std::endl;
std::cout << "|Sending a combination from ENCODER|" << std::endl;
std::cout << "+----------------------------------+\n" << std::endl;
socket->Send (packet);
m_encoder_transmission_count++;
if (kodo::has_trace<rlnc_encoder>::value)
{
std::cout << "Trace encoder:" << std::endl;
kodo::trace(m_encoder, std::cout);
}
Simulator::Schedule (pktInterval, &KodoSimulation::SendPacketEncoder,
this, socket, pktInterval);
}
else
{
socket->Close ();
}
}
示例2: GenerateTraffic
void GenerateTraffic (Ptr<Socket> socket, Time pktInterval )
{
if (!m_decoder_1->is_complete() || !m_decoder_2->is_complete())
{
std::cout << "Sending a combination" << std::endl;
uint32_t bytes_used = m_encoder->encode(&m_payload_buffer[0]);
auto packet = Create<Packet> (&m_payload_buffer[0], bytes_used);
socket->Send (packet);
m_transmission_count++;
if (kodo::has_trace<rlnc_encoder>::value)
{
std::cout << "Trace encoder:" << std::endl;
kodo::trace(m_encoder, std::cout);
}
Simulator::Schedule (pktInterval, &KodoSimulation::GenerateTraffic,
this, socket, pktInterval);
}
else
{
std::cout << "Decoding completed! Total transmissions: "
<< m_transmission_count << std::endl;
socket->Close ();
}
}
示例3: StopApplication
void MyApp::StopApplication (void)
{
m_running = false;
if (m_sendEvent.IsRunning ())
Simulator::Cancel (m_sendEvent);
if (m_socket)
m_socket->Close ();
}
示例4: SendPacketRecoder
void SendPacketRecoder (Ptr<Socket> socket, Time pktInterval)
{
if (!m_decoder->is_complete())
{
if (m_recoding_flag)
{
// Recode a new packet and send
uint32_t bytes_used = m_recoder->recode(&m_payload_buffer[0]);
auto packet = Create<Packet> (&m_payload_buffer[0], bytes_used);
std::cout << "+----------------------------------+" << std::endl;
std::cout << "|Sending a combination from RECODER|" << std::endl;
std::cout << "+----------------------------------+\n" << std::endl;
socket->Send (packet);
m_recoder_transmission_count++;
}
else
{
if(!m_recoder->rank ())
{
std::cout << "No packet from ENCODER to forward!" << std::endl;
}
else
{
auto packet = m_previous_packet;
// Remove all packet tags in order to the callback retag them to avoid
// ~/ns-3-dev/src/common/packet-tag-list.cc, line=139 assert failure.
// Tag removal is shown in ~/ns-3-dev/src/applications/udp-echo/
// udp-echo-server.cc for packet forwarding
packet->RemoveAllPacketTags ();
socket->Send (packet);
m_recoder_transmission_count++;
std::cout << "Forwarding a previous packet from RECODER...\n"
<< std::endl;
}
}
Simulator::Schedule (pktInterval, &KodoSimulation::SendPacketRecoder,
this, socket, pktInterval);
}
else
{
socket->Close ();
std::cout << "*** Decoding completed! ***" << std::endl;
std::cout << "Encoder transmissions: " << m_encoder_transmission_count
<< std::endl;
std::cout << "Recoder transmissions: " << m_recoder_transmission_count
<< std::endl;
std::cout << "Total transmissions: "
<< m_encoder_transmission_count + m_recoder_transmission_count
<< std::endl;
}
}
示例5: GenerateTraffic
static void GenerateTraffic (Ptr<Socket> socket, uint32_t pktSize,
uint32_t pktCount, Time pktInterval )
{
if (pktCount > 0)
{
socket->Send (Create<Packet> (pktSize));
Simulator::Schedule (pktInterval, &GenerateTraffic,
socket, pktSize,pktCount-1, pktInterval);
}
else
{
socket->Close ();
}
}
示例6: PrepareHttpData
//.........这里部分代码省略.........
{
if( restreader.p )
{
c_FeatureReaderToXML::ToSitemapXml(restreader.p,RestRequest,RestRequest->GetBaseUri(),stringval_utf8,result->m_FeatureReader_StartIndex,result->m_FeatureReader_Count);
}
}
if( RestRequest->m_CfgRepresentation && RestRequest->m_CfgRepresentation->GetType() == c_CfgRepresentation::e_FeaturesJSON)
{
if( restreader.p )
{
c_FeatureReaderToGeoJson::ToGeoJson(restreader.p,stringval_utf8,result->m_FeatureReader_StartIndex,result->m_FeatureReader_Count);
}
}
if( RestRequest->m_CfgRepresentation && RestRequest->m_CfgRepresentation->GetType() == c_CfgRepresentation::e_Custom)
{
if( restreader.p )
{
//std::stringstream strs;
c_CfgRepresentation_Custom *customrep = (c_CfgRepresentation_Custom *)RestRequest->m_CfgRepresentation;
Ptr<c_StreamResponse_FReader2Custom> streamout = new c_StreamResponse_FReader2Custom(restreader.p,customrep);
m_HttpData.SetContent(streamout);
return &m_HttpData; // need to go out here - bellow is closing featuer reader - setting hhtp header for content length etc..
///(*(customrep->m_CustomRenderer->m_FuncContent2Stream))(restreader.p,&strs);
//stringval_utf8 = strs.str();
//c_FeatureReaderToGeoJson::ToGeoJson(restreader.p,stringval_utf8,result->m_FeatureReader_StartIndex,result->m_FeatureReader_Count);
}
}
if( restreader.p )
{
restreader->Close();
}
if (NULL != dynamic_cast<c_RestPrimitiveValue*>(pResultObj))
{
stringval_utf8 = ((c_RestPrimitiveValue*)pResultObj)->ToStringUTF8();;
}
else if (NULL != dynamic_cast<MgByteReader*>(pResultObj))
{
outputReader = (MgByteReader*) SAFE_ADDREF(pResultObj);
}
else if (NULL != dynamic_cast<MgStringCollection*>(pResultObj))
{
outputReader = ((MgStringCollection*)pResultObj)->ToXml();
}
else if (NULL != dynamic_cast<MgSqlDataReader*>(pResultObj))
{
outputReader = ((MgSqlDataReader*)pResultObj)->ToXml();
}
else if (NULL != dynamic_cast<MgDataReader*>(pResultObj))
{
outputReader = ((MgDataReader*)pResultObj)->ToXml();
}
if (stringval_utf8.length() > 0)
{
示例7: FetchImage
MgByteReader* c_RestFetchImage::FetchImage(c_RestUri* HttpRequest,c_CfgDataSource_MapGuide* MapGuideSource
, const std::wstring& MapDefId,MgEnvelope* ZoomTo, const std::wstring& ZoomFactor
, const std::wstring& MapSelectionLayer, const std::wstring& FeatureSource, const std::wstring& FdoClassName
, MgFeatureQueryOptions *QueryOptions
)
{
Ptr<c_RestUriRequestParam> query_params = HttpRequest-> GetRequestParam();
//Ptr<c_RestUriPathParam> path_params = HttpRequest-> GetUriPathParameters();
//STRING filter = path_params->GetParameterValue(D_REST_URI_SEGMENT_MAP_IMAGE_PNG);
//Ptr<c_RestRequestParam> filterparams = new c_RestRequestParam();
//RestUriFilterParser::Parse(filter, filterparams);
Ptr<c_RestMgSiteConnection> mgsiteconn = c_RestMgSiteConnection::Open(MapGuideSource->GetUsername(),MapGuideSource->GetPassword(),MapGuideSource->GetServerIP(),MapGuideSource->GetServerPort());
//MgHtmlController controller(mgsiteconn);
// Get the map view commands
//Ptr<c_RestRequestParam> params = m_hRequest->GetRequestParam();
//Ptr<MgPropertyCollection> mapViewCommands = params->GetParameters()->GetPropertyCollection();
//Ptr<MgPropertyCollection> mapViewCommands = filterparams->GetParameters()->GetPropertyCollection();
STRING map_resid;
STRING mapname;
Ptr<MgMap> map;
Ptr<MgSelection> selection;
Ptr<MgPropertyCollection> mapviewcommands = new MgPropertyCollection();
{
STRING sessionid;
Ptr<MgSite> mgSite = mgsiteconn->GetSite();
sessionid = mgSite->CreateSession();
//-------------------------------------------------------
// Create a new Map from MapDefinition in a Session
//-------------------------------------------------------
map = new MgMap();
Ptr<MgResourceIdentifier> resid_mapdef = new MgResourceIdentifier(MapDefId);
mapname = L"KINGREST";
Ptr<MgResourceService> resourceService = dynamic_cast<MgResourceService*>(mgsiteconn->CreateService(MgServiceType::ResourceService));
map->Create(resourceService, resid_mapdef, mapname );
// Save the MgMap state
map_resid = L"Session:" + sessionid + L"//" + mapname + L"." + MgResourceType::Map;
Ptr<MgResourceIdentifier> resid_map = new MgResourceIdentifier(map_resid);
map->Save(resourceService,resid_map);
selection = new MgSelection(map);
if( MapSelectionLayer.length()>0 )
{
MgResourceIdentifier resId(FeatureSource);
Ptr<MgFeatureService> service = (MgFeatureService*)(mgsiteconn->CreateService(MgServiceType::FeatureService));
Ptr<MgFeatureReader> featureReader = service->SelectFeatures(&resId, FdoClassName, QueryOptions);
//Ptr<MgResourceIdentifier> layerresidid = new MgResourceIdentifier(HttpRequest->m_DataLayerConfig->m_MapSelectionLayer);
//Ptr<MgLayer> layerdef = new MgLayer(layerid,resourceService);
Ptr<MgLayerBase> layer;
Ptr<MgLayerCollection> layers = map->GetLayers();
int layerid =layers->IndexOf(MapSelectionLayer);
if( layerid >= 0 )
{
layer = layers->GetItem(layerid);
}
//auto_ptr<MdfModel::LayerDefinition> layerdef( MgLayerBase::GetLayerDefinition(resourceService, layerid));
selection->AddFeatures(layer,featureReader,0);
featureReader->Close();
}
selection->Save(resourceService, mapname);
Ptr<MgReadOnlyLayerCollection> selLayers = selection->GetLayers();
int sel_layercount = selLayers ? selLayers->GetCount() : 0;
MgStringPropertyCollection* coll_params = query_params->GetParameters();
int dwidth=260;
int dheight=260;
int dpi = 96;
STRING strval;
Ptr<MgStringProperty> prop;
if( coll_params->Contains(L"SETDISPLAYWIDTH" ) )
{
STRING val = coll_params->GetValue(L"SETDISPLAYWIDTH");
dwidth = MgUtil::StringToDouble(val);
if( dwidth <= 0 ) dwidth=260;
//.........这里部分代码省略.........
示例8: DoTests
bool DoTests() override
{
//only test GetInstance and Update here. Do Thread methods at SubThread.
Ptr<IApplication> app = IApplication::GetInstance();
if(!app) return Fail("IApplication::GetInstance() returned nullptr.");
{
Ptr<IApplication> app2 = IApplication::GetInstance();
if(app != app2) return Fail("IApplication::GetInstance() returned different values.");
}
Ptr<IConfigFile> cfg = IConfigFile::GetInstance(PREFIX"ctest.cfg");
if(!cfg) return Fail("IConfigFile::GetInstance() returned nullptr.");
if(!cfg->IsValid()) return Fail("Config file is invalid.");
Ptr<WECTWindow> win = new WECTWindow(cfg->GetObject("wectWin"), this);
//at this point, all ConfigFile methods have been tested.
if(!win) return Fail("WECTWindow creation failed.");
if(!win->GetExtended()) return Fail("WECTWindow::GetExtended() returned nullptr.");
{
//Rectangle testing not done here; need to test setters, but GetRect returns a const*.
Ptr<const TRectangle<s16,u16>> winrect = win->GetRect();
if(!winrect) return Fail("win->GetRect() returned nullptr.");
}
win->Move(30,30);
win->Resize(640,480);
win->Show(false);
win->Show(true);
//synthesize the many combinations of Mouse
win->Mouse(EMouseButton::Left, EMouseButtonState::Down, 0, 0);
win->Mouse(EMouseButton::Left, EMouseButtonState::Up, 0, 0);
win->Mouse(EMouseButton::Left, EMouseButtonState::DoubleClick, 0, 0);
win->Mouse(EMouseButton::Right, EMouseButtonState::Down, 0, 0);
win->Mouse(EMouseButton::Right, EMouseButtonState::Up, 0, 0);
win->Mouse(EMouseButton::Right, EMouseButtonState::DoubleClick, 0, 0);
win->Mouse(EMouseButton::Middle, EMouseButtonState::Down, 0, 0);
win->Mouse(EMouseButton::Middle, EMouseButtonState::Up, 0, 0);
win->Mouse(EMouseButton::Middle, EMouseButtonState::DoubleClick, 0, 0);
win->Mouse(EMouseButton::X1, EMouseButtonState::Down, 0, 0);
win->Mouse(EMouseButton::X1, EMouseButtonState::Up, 0, 0);
win->Mouse(EMouseButton::X1, EMouseButtonState::DoubleClick, 0, 0);
win->Mouse(EMouseButton::X2, EMouseButtonState::Down, 0, 0);
win->Mouse(EMouseButton::X2, EMouseButtonState::Up, 0, 0);
win->Mouse(EMouseButton::X2, EMouseButtonState::DoubleClick, 0, 0);
win->Mouse(EMouseButton::Null, EMouseButtonState::Null, 30, 30);
win->Key(EKeyMap::A, EKeyState::Down);
win->Key(EKeyMap::A, EKeyState::Up);
win->Scroll(EMouseScrollDirection::Down, 1);
win->Scroll(EMouseScrollDirection::Up, 1);
//For some reason, X11 processes the close message when debugging, but not when just running.
win->Close();
//if no equivalent to SendMessage (Win32) / NSApplication -sendEvent: (Cocoa) on X11,
// event synthesizers will always go to event queue
// using PostMessage (Win32) / NSApplication -postEvent:atStart: (Cocoa) / XSendEvent (X11)
// In that case, GetHandlerState should report 0 before the application loop.
if(win->GetHandlerState() != 0) return Fail("Handlers called before mainloop. (Event queue short-circuit?)");
//should process all events in order, and immediately break.
while(app->Update())
{
//app->Update should return false, and not enter this block.
return Fail("app->Update() did not return false.");
}
if(win->GetHandlerState() != 0x1ffffff) return Fail("Not all handlers called on WECTWindow.");
return Success();
}