本文整理汇总了C++中Port::SetSource方法的典型用法代码示例。如果您正苦于以下问题:C++ Port::SetSource方法的具体用法?C++ Port::SetSource怎么用?C++ Port::SetSource使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Port
的用法示例。
在下文中一共展示了Port::SetSource方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: RPC
bool Frontend::RPC( const HTTPRequest &request, const std::string &cat, const std::string &action )
{
if( cat == "port" )
{
int port_id;
if( !request.GetParam( "port_id", port_id ))
return false;
LockPorts( );
std::map<int, Port *>::iterator it = ports.find( port_id );
if( it == ports.end( ))
{
LogError( "Port %d not found", port_id );
return false;
}
bool ret = it->second->RPC( request, cat, action );
UnlockPorts( );
return ret;
}
if( action == "create_port" )
{
int port_num;
if( !request.GetParam( "port_num", port_num ))
return false;
std::string name;
if( !request.GetParam( "name", name ))
return false;
int source_id;
if( !request.GetParam( "source_id", source_id ))
return false;
Port *port = AddPort( name, port_num );
if( port == NULL )
{
request.NotFound( "Port with number %d already exists", port_num );
return false;
}
Source *source = TVDaemon::Instance( )->GetSource( source_id );
if( !source )
LogError( "Source not found: %d", source_id );
else
{
source->AddPort( port );
port->SetSource( source );
}
request.Reply( HTTP_OK, port->GetKey( ));
return true;
}
if( action == "delete_port" )
{
int port_id;
if( !request.GetParam( "port_id", port_id ))
return false;
LockPorts( );
std::map<int, Port *>::iterator it = ports.find( port_id );
if( it == ports.end( ))
{
LogError( "Port not found: %d", port_id );
UnlockPorts( );
return false;
}
it->second->Delete( );
delete it->second;
ports.erase( it );
UnlockPorts( );
return true;
}
request.NotFound( "RPC unknown action: '%s'", action.c_str( ));
return false;
}