本文整理汇总了C++中Address::IsValid方法的典型用法代码示例。如果您正苦于以下问题:C++ Address::IsValid方法的具体用法?C++ Address::IsValid怎么用?C++ Address::IsValid使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Address
的用法示例。
在下文中一共展示了Address::IsValid方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SendPacket
void NetworkSimulator::SendPacket( const Address & from, const Address & to, uint8_t * packetData, int packetSize )
{
assert( from.IsValid() );
assert( to.IsValid() );
assert( packetData );
assert( packetSize > 0 );
if ( random_float( 0.0f, 100.0f ) <= m_packetLoss )
{
m_allocator->Free( packetData );
return;
}
PacketEntry & packetEntry = m_packetEntries[m_currentIndex];
if ( packetEntry.packetData )
{
m_allocator->Free( packetEntry.packetData );
packetEntry = PacketEntry();
}
double delay = m_latency / 1000.0;
if ( m_jitter > 0 )
delay += random_float( -m_jitter, +m_jitter ) / 1000.0;
packetEntry.from = from;
packetEntry.to = to;
packetEntry.packetData = packetData;
packetEntry.packetSize = packetSize;
packetEntry.deliveryTime = m_time + delay;
m_currentIndex = ( m_currentIndex + 1 ) % m_numPacketEntries;
if ( random_float( 0.0f, 100.0f ) <= m_duplicates )
{
uint8_t * duplicatePacketData = (uint8_t*) m_allocator->Allocate( packetSize );
memcpy( duplicatePacketData, packetData, packetSize );
PacketEntry & nextPacketEntry = m_packetEntries[m_currentIndex];
nextPacketEntry.from = from;
nextPacketEntry.to = to;
nextPacketEntry.packetData = duplicatePacketData;
nextPacketEntry.packetSize = packetSize;
nextPacketEntry.deliveryTime = m_time + delay + random_float( -10.0, +10.0 );
m_currentIndex = ( m_currentIndex + 1 ) % m_numPacketEntries;
}
}
示例2: AddConnection
////////////////////////////////////////////////////////////////////////////////////
///
/// \brief Method to add a new connection manually to a component at an
/// IP address.
///
/// \param[in] networkIP IP Address of component.
/// \param[in] jausID JAUS ID of component.
/// \param[in] port Network port to use (default is 3794).
///
/// \return True on success, false on failure.
///
////////////////////////////////////////////////////////////////////////////////////
bool JUDP::AddConnection(const CxUtils::IP4Address& networkIP,
const Address& jausID,
const unsigned short port)
{
bool result = false;
if(jausID.IsValid() && !jausID.IsBroadcast())
{
Mutex::ScopedLock lock(&mClientsMutex);
std::map<Address, CxUtils::UdpClient*>::iterator citer;
citer = mClients.find(jausID);
if(citer == mClients.end())
{
CxUtils::UdpClient* udp = mMulticast.CreateNewDestination(networkIP, port);
if(udp)
{
mClients[jausID] = udp;
mUpdateTimes[jausID] = Time::GetUtcTimeMs();
mPermanentConnections[jausID] = true;
udp = NULL;
result = true;
}
else
{
if(mDebugMessagesFlag)
{
Mutex::ScopedLock lock(&mDebugMessagesMutex);
std::cout << "[" << GetServiceID().ToString() << "-" << mComponentID.ToString() << "] - New Connection Made to " << jausID << " at IP:" << networkIP.mString << std::endl;
}
}
}
}
return result;
}
示例3:
static void
ResolveAddress (const ExecutionContext &exe_ctx,
const Address &addr,
Address &resolved_addr)
{
if (!addr.IsSectionOffset())
{
// If we weren't passed in a section offset address range,
// try and resolve it to something
Target *target = exe_ctx.GetTargetPtr();
if (target)
{
if (target->GetSectionLoadList().IsEmpty())
{
target->GetImages().ResolveFileAddress (addr.GetOffset(), resolved_addr);
}
else
{
target->GetSectionLoadList().ResolveLoadAddress (addr.GetOffset(), resolved_addr);
}
// We weren't able to resolve the address, just treat it as a
// raw address
if (resolved_addr.IsValid())
return;
}
}
resolved_addr = addr;
}
示例4: SetControllerID
////////////////////////////////////////////////////////////////////////////////////
///
/// \return ID of the controlling component.
///
////////////////////////////////////////////////////////////////////////////////////
void AccessControl::SetControllerID(const Address& id)
{
if(id.IsValid() && !id.IsBroadcast())
{
Mutex::ScopedLock lock(&mControlMutex);
mControllerID = id;
}
}
示例5: SetControllerID
////////////////////////////////////////////////////////////////////////////////////
///
/// \brief Set the ID of controlling component.
///
/// \param[in] ID of the controlling component.
///
////////////////////////////////////////////////////////////////////////////////////
void AccessControl::SetControllerID(const Address& id)
{
if(id.IsValid() && !id.IsBroadcast())
{
WriteLock wLock(mControlMutex);
mControllerID = id;
}
}
示例6: GetRowAtIndex
bool
UnwindPlan::PlanValidAtAddress (Address addr)
{
// If this UnwindPlan has no rows, it is an invalid UnwindPlan.
if (GetRowCount() == 0)
{
Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_UNWIND));
if (log)
{
StreamString s;
if (addr.Dump (&s, nullptr, Address::DumpStyleSectionNameOffset))
{
log->Printf ("UnwindPlan is invalid -- no unwind rows for UnwindPlan '%s' at address %s",
m_source_name.GetCString(), s.GetData());
}
else
{
log->Printf ("UnwindPlan is invalid -- no unwind rows for UnwindPlan '%s'",
m_source_name.GetCString());
}
}
return false;
}
// If the 0th Row of unwind instructions is missing, or if it doesn't provide
// a register to use to find the Canonical Frame Address, this is not a valid UnwindPlan.
if (GetRowAtIndex(0).get() == nullptr ||
GetRowAtIndex(0)->GetCFAValue().GetValueType() == Row::CFAValue::unspecified)
{
Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_UNWIND));
if (log)
{
StreamString s;
if (addr.Dump (&s, nullptr, Address::DumpStyleSectionNameOffset))
{
log->Printf ("UnwindPlan is invalid -- no CFA register defined in row 0 for UnwindPlan '%s' at address %s",
m_source_name.GetCString(), s.GetData());
}
else
{
log->Printf ("UnwindPlan is invalid -- no CFA register defined in row 0 for UnwindPlan '%s'",
m_source_name.GetCString());
}
}
return false;
}
if (!m_plan_valid_address_range.GetBaseAddress().IsValid() || m_plan_valid_address_range.GetByteSize() == 0)
return true;
if (!addr.IsValid())
return true;
if (m_plan_valid_address_range.ContainsFileAddress (addr))
return true;
return false;
}
示例7: SetDestinationID
////////////////////////////////////////////////////////////////////////////////////
///
/// \brief Sets the destination ID of the message.
///
/// \param[in] dest Destination ID. Must be a valid ID.
///
/// \return OK on success, FAILURE on error.
///
////////////////////////////////////////////////////////////////////////////////////
int Message::SetDestinationID(const Address& dest)
{
if(dest.IsValid())
{
mDestinationID = dest;
return OK;
}
return FAILURE;
}
示例8: SetSourceID
////////////////////////////////////////////////////////////////////////////////////
///
/// \brief Sets the source ID of the message.
///
/// \param[in] src Source ID. Must be valid and non-broadcast.
///
/// \return OK on success, FAILURE on error.
///
////////////////////////////////////////////////////////////////////////////////////
int Message::SetSourceID(const Address& src)
{
if(src.IsValid() && !src.IsBroadcast())
{
mSourceID = src;
return OK;
}
return FAILURE;
}
示例9: GetImageInfoAddress
addr_t ProcessFreeBSD::GetImageInfoAddress() {
Target *target = &GetTarget();
ObjectFile *obj_file = target->GetExecutableModule()->GetObjectFile();
Address addr = obj_file->GetImageInfoAddress(target);
if (addr.IsValid())
return addr.GetLoadAddress(target);
return LLDB_INVALID_ADDRESS;
}
示例10: GetTarget
lldb::addr_t
ProcessElfCore::GetImageInfoAddress()
{
ObjectFile *obj_file = GetTarget().GetExecutableModule()->GetObjectFile();
Address addr = obj_file->GetImageInfoAddress(&GetTarget());
if (addr.IsValid())
return addr.GetLoadAddress(&GetTarget());
return LLDB_INVALID_ADDRESS;
}
示例11: GetTarget
lldb::addr_t
ProcessWindows::GetImageInfoAddress()
{
Target &target = GetTarget();
ObjectFile *obj_file = target.GetExecutableModule()->GetObjectFile();
Address addr = obj_file->GetImageInfoAddress(&target);
if (addr.IsValid())
return addr.GetLoadAddress(&target);
else
return LLDB_INVALID_ADDRESS;
}
示例12: SetInstruction
bool EmulateInstruction::SetInstruction(const Opcode &opcode,
const Address &inst_addr,
Target *target) {
m_opcode = opcode;
m_addr = LLDB_INVALID_ADDRESS;
if (inst_addr.IsValid()) {
if (target != nullptr)
m_addr = inst_addr.GetLoadAddress(target);
if (m_addr == LLDB_INVALID_ADDRESS)
m_addr = inst_addr.GetFileAddress();
}
return true;
}
示例13: CheckServiceSynchronization
////////////////////////////////////////////////////////////////////////////////////
///
/// \brief If synchronization is enabled, then this method is used to
/// subscribe to sensor data from the component we are synchronizing
/// with.
///
/// \param[in] timeSinceLastCheckMs Time since last update in ms.
///
////////////////////////////////////////////////////////////////////////////////////
void TimeService::CheckServiceSynchronization(const unsigned int timeSinceLastCheckMs)
{
Address syncID = GetSynchronizeID();
if(syncID.IsValid())
{
// See if we have an active subscription
if(EventsService()->HaveSubscription(REPORT_TIME, syncID) == false)
{
QueryTime query(syncID, GetComponentID());
query.SetPresenceVector(query.GetPresenceVectorMask());
EventsService()->RequestEveryChangeEvent(syncID, &query);
}
}
}
示例14:
bool
UnwindPlan::PlanValidAtAddress (Address addr)
{
if (!m_plan_valid_address_range.GetBaseAddress().IsValid() || m_plan_valid_address_range.GetByteSize() == 0)
return true;
if (!addr.IsValid())
return true;
if (m_plan_valid_address_range.ContainsFileAddress (addr))
return true;
return false;
}
示例15: data_sp
size_t
Disassembler::ParseInstructions (const ExecutionContext *exe_ctx,
const Address &start,
uint32_t num_instructions,
bool prefer_file_cache)
{
m_instruction_list.Clear();
if (exe_ctx == NULL || num_instructions == 0 || !start.IsValid())
return 0;
Target *target = exe_ctx->GetTargetPtr();
// Calculate the max buffer size we will need in order to disassemble
const addr_t byte_size = num_instructions * m_arch.GetMaximumOpcodeByteSize();
if (target == NULL || byte_size == 0)
return 0;
DataBufferHeap *heap_buffer = new DataBufferHeap (byte_size, '\0');
DataBufferSP data_sp (heap_buffer);
Error error;
lldb::addr_t load_addr = LLDB_INVALID_ADDRESS;
const size_t bytes_read = target->ReadMemory (start,
prefer_file_cache,
heap_buffer->GetBytes(),
byte_size,
error,
&load_addr);
const bool data_from_file = load_addr == LLDB_INVALID_ADDRESS;
if (bytes_read == 0)
return 0;
DataExtractor data (data_sp,
m_arch.GetByteOrder(),
m_arch.GetAddressByteSize());
const bool append_instructions = true;
DecodeInstructions (start,
data,
0,
num_instructions,
append_instructions,
data_from_file);
return m_instruction_list.GetSize();
}