本文整理汇总了C++中IsType函数的典型用法代码示例。如果您正苦于以下问题:C++ IsType函数的具体用法?C++ IsType怎么用?C++ IsType使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了IsType函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Size_Target_Array
//
// Setting the targets that this grunt will access.
//
BOOL Grunt::Set_Targets( int count, Target_Spec *target_specs )
{
// Remove previous completion queue if it was created by the Grunt.
if ( !IsType( type, GenericVIType ) && io_cq )
{
delete io_cq;
}
io_cq = NULL;
// If no targets are being set, simply clear the target list.
if ( !count )
{
cout << " clearing target list." << endl;
return Size_Target_Array( 0 );
}
// Allocate enough targets
if ( !Size_Target_Array( count, target_specs ) )
return FALSE;
worker_performance.target_results.count = count;
// Create appropriate completion queue object based on targets.
// If the Grunt will manage VI targets, the targets will provide a
// pointer to the completion queue to use.
#if defined(IOMTR_SETTING_VI_SUPPORT)
if ( IsType( type, GenericVIType ) )
{
// VI targets must know where the data buffer is and its size before
// being initialized.
((TargetVI*)targets[0])->data_buffer = (char*) read_data;
((TargetVI*)targets[0])->data_buffer_size = access_spec.max_transfer;
io_cq = &((TargetVI*)targets[0])->vi.vi_cq;
}
else
#endif // IOMTR_SETTING_VI_SUPPORT
{
// Create completion queue and verify its creation.
if ( !(io_cq = new CQAIO) )
{
cout << "*** Unable to create completion queue while setting "
<< "targets." << endl;
return FALSE;
}
}
// Initialize the specific targets.
for ( int i = 0; i < count; i++ )
{
if ( !targets[i]->Initialize( &target_specs[i], io_cq ) )
return FALSE;
}
// Seed the random number generator. Grunts transferring data over a
// network will use the same seed to produce the same sequence of random
// numbers. This will keep them in synch.
Srand( target_specs[0].random );
return Resize_Transaction_Arrays();
}
示例2: ADDTOCALLSTACK
void CItemSpawn::OnTick(bool fExec)
{
ADDTOCALLSTACK("CitemSpawn:OnTick");
INT64 iMinutes;
if ( m_itSpawnChar.m_TimeHiMin <= 0 )
iMinutes = Calc_GetRandLLVal(30) + 1;
else
iMinutes = minimum(m_itSpawnChar.m_TimeHiMin, m_itSpawnChar.m_TimeLoMin) + Calc_GetRandLLVal(abs(m_itSpawnChar.m_TimeHiMin - m_itSpawnChar.m_TimeLoMin));
if ( iMinutes <= 0 )
iMinutes = 1;
if ( !fExec || IsTimerExpired() )
SetTimeout(iMinutes * 60 * TICK_PER_SEC); // set time to check again.
if ( !fExec || m_currentSpawned >= GetAmount() )
return;
CResourceDef *pDef = FixDef();
if ( !pDef )
{
RESOURCE_ID_BASE rid = IsType(IT_SPAWN_ITEM) ? m_itSpawnItem.m_ItemID : m_itSpawnChar.m_CharID;
DEBUG_ERR(("Bad Spawn point uid=0%lx, id=%s\n", (DWORD)GetUID(), g_Cfg.ResourceGetName(rid)));
return;
}
if ( IsType(IT_SPAWN_ITEM) )
GenerateItem(pDef);
else
GenerateChar(pDef);
}
示例3: GetManager
//
// Adding the specified worker to the display.
//
void CWorkerView::AddWorker(Worker * worker)
{
HTREEITEM hmanager, hworker;
int icon;
// Get the handle to the tree view entry of the worker's manager.
hmanager = GetManager(worker->manager);
if (IsType(worker->Type(), GenericDiskType))
icon = WORKER_ICON_DISKWORKER;
else if (IsType(worker->Type(), GenericServerType))
icon = WORKER_ICON_NETSERVER;
else if (IsType(worker->Type(), GenericClientType))
icon = WORKER_ICON_NETCLIENT;
else
icon = WORKER_ICON_MANAGER;
// Add the worker to the manager in the tree view.
hworker = m_TWorkers.InsertItem(worker->name, icon, icon, hmanager, TVI_LAST);
m_TWorkers.SetItemData(hworker, (DWORD_PTR) worker);
m_TWorkers.RedrawWindow();
// Update the Assigned Access Specs listbox.
theApp.pView->m_pPageAccess->ShowAssignedAccess();
}
示例4: ManagerCount
//
// Returns TRUE if all of the workers (on all managers) have
// the same access specification list.
//
BOOL ManagerList::AreAccessSpecsIdentical()
{
int m, w, s, wkr_count, mgr_count, spec_count;
Worker *compare_worker, *current_worker;
Manager *mgr;
// Get the first non-client worker for any manager.
mgr_count = ManagerCount();
for (m = 0; m < mgr_count; m++) {
mgr = GetManager(m);
wkr_count = mgr->WorkerCount();
// Find the first non-client worker for this manager.
for (w = 0; w < wkr_count; w++) {
compare_worker = mgr->GetWorker(w);
if (!IsType(compare_worker->Type(), GenericClientType)) {
spec_count = compare_worker->AccessSpecCount();
break;
}
}
// See if we found a valid worker for this manager
if (w < wkr_count)
break;
}
// Did we find a worker to compare against?
if (m == mgr_count)
return TRUE;
// Compare the first worker's Test_Spec to each other worker's Test_Spec.
// Include the manager with the worker being compared with in our testing.
for (m; m < mgr_count; m++) {
mgr = GetManager(m);
wkr_count = mgr->WorkerCount();
// Only compare against non-client workers.
for (w = 0; w < wkr_count; w++) {
current_worker = mgr->GetWorker(w);
// Skip network clients.
if (IsType(current_worker->Type(), GenericClientType))
continue;
// If this worker doesn't have the same number of access specs, return FALSE.
if (current_worker->AccessSpecCount() != spec_count)
return FALSE;
// Check to make sure each returned Test_Spec pointer is identical to (and in the
// same order as) the pointer in the first_worker.
for (s = 0; s < spec_count; s++) {
if (current_worker->GetAccessSpec(s) != compare_worker->GetAccessSpec(s))
return FALSE;
}
}
}
return TRUE;
}
示例5: Item_GetDef
bool CItem::Ship_Plank( bool fOpen )
{
// IT_SHIP_PLANK to IT_SHIP_SIDE and IT_SHIP_SIDE_LOCKED
// This item is the ships plank.
CItemBase * pItemDef = Item_GetDef();
ITEMID_TYPE idState = (ITEMID_TYPE) RES_GET_INDEX( pItemDef->m_ttShipPlank.m_idState );
if ( ! idState )
{
// Broken ?
return( false );
}
if ( IsType(IT_SHIP_PLANK))
{
if ( fOpen )
return( true );
}
else
{
DEBUG_CHECK( IsType(IT_SHIP_SIDE) || IsType(IT_SHIP_SIDE_LOCKED));
if ( ! fOpen )
return( true );
}
SetID( idState );
Update();
return( true );
}
示例6: return
bool FundamentalValue::GetAsInteger(int* out_value) const
{
if(out_value && IsType(TYPE_INTEGER))
{
*out_value = integer_value_;
}
return (IsType(TYPE_INTEGER));
}
示例7: ADDTOCALLSTACK
CResourceDef * CItemSpawn::FixDef()
{
ADDTOCALLSTACK("CitemSpawn:FixDef");
// Get a proper RESOURCE_ID from the id provided.
// RETURN: true = ok.
RESOURCE_ID_BASE rid = ( IsType(IT_SPAWN_ITEM) ? m_itSpawnItem.m_ItemID : m_itSpawnChar.m_CharID );
if ( rid.GetResType() != RES_UNKNOWN )
{
return STATIC_CAST <CResourceDef *>(g_Cfg.ResourceGetDef(rid));
}
// No type info here !?
if ( IsType(IT_SPAWN_ITEM))
{
ITEMID_TYPE id = static_cast<ITEMID_TYPE>(rid.GetResIndex());
if ( id < ITEMID_TEMPLATE )
{
return( TryItem( id ) );
}
else
{
// try a template.
rid = RESOURCE_ID( RES_TEMPLATE, id );
CResourceDef * pDef = g_Cfg.ResourceGetDef(rid);
if ( pDef )
{
m_itSpawnItem.m_ItemID = rid;
return( STATIC_CAST <CResourceDef *>( pDef ));
} //if fails
return( TryItem( id ) );
}
}
else
{
CREID_TYPE id = static_cast<CREID_TYPE>(rid.GetResIndex());
if ( id < SPAWNTYPE_START )
{
return( TryChar( id ));
}
else
{
// try a spawn group.
rid = RESOURCE_ID( RES_SPAWN, id );
CResourceDef * pDef = g_Cfg.ResourceGetDef(rid);
if ( pDef )
{
m_itSpawnChar.m_CharID = rid;
return( STATIC_CAST <CResourceDef *>( pDef ));
} //if fails
return( TryChar( id ));
}
}
}
示例8: GetAssociation
void CMVPeriod::read_body(wistream& s)
{
CMString str,token,token2;
str = GetAssociation(L"yearend");
int yearend = str.length() ? CMTime::Month(str.c_str()) : 12;
if (IsType(L"trace"))
traceno = 1;
else {
str = GetAssociation(L"trace");
traceno = str.length() ? _wtoi(str.c_str()) : 0;
}
if (IsType(L"alwaysdraw") || IsType(L"monthly")) // LEGACY
periodstate |= forceEvaluation;
periodformat = -1;
array.ResetAndDestroy(1);
while(!s.eof()) {
str.read_line(s);
if (str.is_null() || str[0] == L'*')
continue;
if (str(0,wcslen(vardef_end)) == vardef_end)
break;
CMTokenizer next(str);
token = next();
token2 = next(L"\r\n");
switch (token.length()) {
case 1:
case 2:
SetExpression(CMTime(2000,_wtoi(token.c_str())),token2.c_str());
if (periodformat<0) periodformat = CMTime::MM;
break;
case 4:
{
int yr = _wtoi(token.c_str());
CMTime t((yearend<12)?(yr-1):yr,yearend%12+1);
SetExpression(t,token2.c_str());
if (periodformat<0) periodformat = CMTime::YYYY;
}
break;
case 6:
if (periodformat<0) periodformat = CMTime::YYYYMM;
case 8:
if (periodformat<0) periodformat = CMTime::YYYYMMDD;
case 10:
if (periodformat<0) periodformat = CMTime::YYYYMMDDHH;
case 12:
if (periodformat<0) periodformat = CMTime::YYYYMMDDHHMM;
default:
if (periodformat<0) periodformat = CMTime::YYYYMMDDHHMMSS;
SetExpression(CMTime(token),token2.c_str());
break;
}
}
array.Resize(array.Count());
}
示例9: DEBUG_CHECK
bool CItemMulti::MultiRealizeRegion()
{
// Add/move a region for the multi so we know when we are in it.
// RETURN: ignored.
DEBUG_CHECK( IsType(IT_MULTI) || IsType(IT_SHIP) );
ASSERT( IsTopLevel());
const CItemBaseMulti * pMultiDef = Multi_GetDef();
if ( pMultiDef == NULL )
{
DEBUG_ERR(( "Bad Multi type 0%x, uid=0%x\n", GetID(), (DWORD) GetUID()));
return false;
}
if ( m_pRegion == NULL )
{
RESOURCE_ID rid;
rid.SetPrivateUID( GetUID());
m_pRegion = new CRegionWorld( rid );
}
// Get Background region.
CPointMap pt = GetTopPoint();
const CRegionWorld * pRegionBack = dynamic_cast <CRegionWorld*> (pt.GetRegion( REGION_TYPE_AREA ));
ASSERT( pRegionBack );
ASSERT( pRegionBack != m_pRegion );
// Create the new region rectangle.
CRectMap rect;
reinterpret_cast<CGRect&>(rect) = pMultiDef->m_rect;
rect.OffsetRect( pt.m_x, pt.m_y );
m_pRegion->SetRegionRect( rect );
m_pRegion->m_pt = pt;
DWORD dwFlags;
if ( IsType(IT_SHIP))
{
dwFlags = REGION_FLAG_SHIP;
}
else
{
// Houses get some of the attribs of the land around it.
dwFlags = pRegionBack->GetRegionFlags();
}
dwFlags |= pMultiDef->m_dwRegionFlags;
m_pRegion->SetRegionFlags( dwFlags );
TCHAR *pszTemp = Str_GetTemp();
sprintf(pszTemp, "%s (%s)", (LPCTSTR) pRegionBack->GetName(), (LPCTSTR) GetName());
m_pRegion->SetName(pszTemp);
return m_pRegion->RealizeRegion();
}
示例10: if
bool FundamentalValue::GetAsDouble(double* out_value) const
{
if(out_value && IsType(TYPE_DOUBLE))
{
*out_value = double_value_;
}
else if(out_value && IsType(TYPE_INTEGER))
{
*out_value = integer_value_;
}
return (IsType(TYPE_DOUBLE) || IsType(TYPE_INTEGER));
}
示例11: assert
/*
================
idClass::ProcessEventArgPtr
================
*/
bool idClass::ProcessEventArgPtr( const idEventDef *ev, int *data )
{
idTypeInfo *c;
int num;
eventCallback_t callback;
assert( ev );
assert( idEvent::initialized );
#ifdef _D3XP
SetTimeState ts;
if( IsType( idEntity::Type ) )
{
idEntity *ent = ( idEntity * )this;
ts.PushState( ent->timeGroup );
}
#endif
if( g_debugTriggers.GetBool() && ( ev == &EV_Activate ) && IsType( idEntity::Type ) )
{
const idEntity *ent = *reinterpret_cast<idEntity **>( data );
gameLocal.Printf( "%d: '%s' activated by '%s'\n", gameLocal.framenum, static_cast<idEntity *>( this )->GetName(), ent ? ent->GetName() : "NULL" );
}
c = GetType();
num = ev->GetEventNum();
if( !c->eventMap[ num ] )
{
// we don't respond to this event, so ignore it
return false;
}
callback = c->eventMap[ num ];
switch( ev->GetFormatspecIndex() )
{
case 1 << D_EVENT_MAXARGS :
( this->*callback )();
break;
// generated file - see CREATE_EVENT_CODE
#include "Callbacks.cpp"
default:
gameLocal.DWarning( "Invalid formatspec on event '%s'", ev->GetName() );
break;
}
return true;
}
示例12: free
//
// Setting the size of the target array to hold the number and type of
// targets specified. If the requested number of targets is 0, the
// array will be freed.
//
BOOL Grunt::Size_Target_Array( int count, const Target_Spec *target_specs )
{
int i;
// Free all current targets. This is needed in case the newer targets
// are of a different type, even if we have the same number of targets.
for ( i = 0; i < target_count; i++ )
delete targets[i];
target_count = 0;
// Reset the grunt's target type.
type = InvalidType;
// Release the memory if everything is being freed.
if ( !count || !target_specs )
{
free(targets);
targets = NULL;
return TRUE;
}
// Allocate enough pointers to refer to all targets.
targets = (Target**)realloc( targets, sizeof(Target*) * count );
if ( !targets )
return FALSE;
// Create the requested number of targets.
for ( i = 0; i < count; i++ )
{
type = (TargetType)(type | target_specs[i].type);
if ( IsType( target_specs[i].type, GenericDiskType ) )
targets[i] = new TargetDisk;
else if ( IsType( target_specs[i].type, GenericTCPType ) )
targets[i] = new TargetTCP;
#if defined(NO_DYNAMO_VI)
// nop
#else
else if ( IsType( target_specs[i].type, GenericVIType ) )
targets[i] = new TargetVI;
#endif // NO_DYNAMO_VI
if ( !targets[i] )
return FALSE;
}
target_count = count;
return TRUE;
}
示例13: Calc_GetRandVal
void CItem::Spawn_OnTick( bool fExec )
{
int iMinutes;
if ( m_itSpawnChar.m_TimeHiMin <= 0 )
{
iMinutes = Calc_GetRandVal(30) + 1;
}
else
{
iMinutes = min( m_itSpawnChar.m_TimeHiMin, m_itSpawnChar.m_TimeLoMin ) + Calc_GetRandVal( abs( m_itSpawnChar.m_TimeHiMin - m_itSpawnChar.m_TimeLoMin ));
}
if ( iMinutes <= 0 )
iMinutes = 1;
if ( !fExec || IsTimerExpired() )
{
SetTimeout( iMinutes * 60 * TICK_PER_SEC ); // set time to check again.
}
if ( ! fExec )
return;
CResourceDef * pDef = Spawn_FixDef();
if ( pDef == NULL )
{
RESOURCE_ID_BASE rid;
if ( IsType(IT_SPAWN_ITEM))
{
rid = m_itSpawnItem.m_ItemID;
}
else
{
rid = m_itSpawnChar.m_CharID;
}
DEBUG_ERR(( "Bad Spawn point uid=0%lx, id=%s\n", (DWORD) GetUID(), g_Cfg.ResourceGetName(rid) ));
return;
}
if ( IsType(IT_SPAWN_ITEM))
{
Spawn_GenerateItem(pDef);
}
else
{
Spawn_GenerateChar(pDef);
}
}
示例14: Transpose
//-------------------------------------------------------------------
bool cpp_xloper::Transpose(void)
{
if(!IsType(xltypeMulti))
return false;
WORD r, c, rows, columns;
GetArraySize(rows, columns);
xloper *new_array = (xloper *)malloc(sizeof(xloper) * rows * columns);
xloper *p_source = m_Op.val.array.lparray;
int new_index;
for(r = 0; r < rows; r++)
{
new_index = r;
for(c = 0; c < columns; c++, new_index += rows)
{
new_array[new_index] = *p_source++;
}
}
r = m_Op.val.array.columns;
m_Op.val.array.columns = m_Op.val.array.rows;
m_Op.val.array.rows = r;
memcpy(m_Op.val.array.lparray, new_array, sizeof(xloper) * rows * columns);
free(new_array);
return true;
}
示例15: assert
/*
================
idClass::PostEventArgs
================
*/
bool idClass::PostEventArgs( const idEventDef *ev, int time, int numargs, ... ) {
idTypeInfo *c;
idEvent *event;
va_list args;
assert( ev );
if ( !idEvent::initialized ) {
return false;
}
c = GetType();
if ( !c->eventMap[ ev->GetEventNum() ] ) {
// we don't respond to this event, so ignore it
return false;
}
// we service events on the client to avoid any bad code filling up the event pool
// we don't want them processed usually, unless when the map is (re)loading.
// we allow threads to run fine, though.
if ( gameLocal.isClient && ( gameLocal.GameState() != GAMESTATE_STARTUP ) && !IsType( idThread::Type ) ) {
return true;
}
va_start( args, numargs );
event = idEvent::Alloc( ev, numargs, args );
va_end( args );
event->Schedule( this, c, time );
return true;
}