本文整理汇总了C++中basic::PairStream::getFirstItem方法的典型用法代码示例。如果您正苦于以下问题:C++ PairStream::getFirstItem方法的具体用法?C++ PairStream::getFirstItem怎么用?C++ PairStream::getFirstItem使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类basic::PairStream
的用法示例。
在下文中一共展示了PairStream::getFirstItem方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getSpecificBomb
// Get the next free bomb of type 'bombType'
Bomb* SimpleStoresMgr::getSpecificBomb(const Basic::String* const bombType)
{
Bomb* bomb = 0;
if (bombType != 0) {
Basic::PairStream* list = getWeapons();
if (list != 0) {
// Find the first free (inactive) bomb
Basic::List::Item* item = list->getFirstItem();
while (item != 0 && bomb == 0) {
Basic::Pair* pair = (Basic::Pair*)(item->getValue());
Bomb* p = dynamic_cast<Bomb*>( pair->object() );
if (p != 0 && p->isInactive()) {
// Ok, we have a bomb, but is it the type we want?
if (*p->getType() == *bombType) {
p->ref();
bomb = p;
}
}
item = item->getNext();
}
list->unref();
}
}
return bomb;
}
示例2: onJettisonEvent
// Default external equipment jettison event handler
bool Stores::onJettisonEvent(ExternalStore* const sys)
{
bool ok = false;
if (sys != 0) {
Basic::PairStream* list = getStores();
if (list != 0) {
// First, make sure it's one of ours!
bool found = false;
Basic::List::Item* item = list->getFirstItem();
while (item != 0 && !found) {
Basic::Pair* pair = static_cast<Basic::Pair*>(item->getValue());
found = (sys == pair->object()); // is it a match?
item = item->getNext();
}
if (found) {
// Send a jettison event to the system
ok = sys->event(JETTISON_EVENT);
}
list->unref();
list = 0;
}
}
return ok;
}
示例3: getSpecificWeapon
// Get the next free weapon of this 'type'
Weapon* SimpleStoresMgr::getSpecificWeapon(const std::type_info& type)
{
Weapon* wpn = 0;
if (&type != 0) {
Basic::PairStream* list = getWeapons();
if (list != 0) {
// Find the first free (inactive) bomb
Basic::List::Item* item = list->getFirstItem();
while (item != 0 && wpn == 0) {
Basic::Pair* pair = (Basic::Pair*)(item->getValue());
Weapon* p = dynamic_cast<Weapon*>( pair->object() );
if (p != 0 && p->isInactive() && p->isClassType(type)) {
p->ref();
wpn = p;
}
item = item->getNext();
}
list->unref();
}
}
return wpn;
}
示例4: setSlotReversed
//------------------------------------------------------------------------------
// setSlotReversed() --
//------------------------------------------------------------------------------
bool Field::setSlotReversed(const Basic::Number* const srobj)
{
if (srobj != 0) {
// Set our mode
if (srobj->getBoolean()) {
setDisplayMode(reversed);
setDisplayMode(reversed1);
}
else {
clearDisplayMode(reversed);
clearDisplayMode(reversed1);
}
// Set our children's mode
Basic::PairStream* subcomponents = getComponents();
if (subcomponents != 0) {
const Basic::List::Item* item = subcomponents->getFirstItem();
while (item != 0) {
Basic::Pair* p = (Basic::Pair*) item->getValue();
Field* child = dynamic_cast<Field*>(p->object());
if (child != 0) child->setSlotReversed(srobj);
item = item->getNext();
}
subcomponents->unref();
subcomponents = 0;
}
}
return true;
}
示例5: getSpecificMissile
// Get the next free missile of type 'missileType'
Missile* SimpleStoresMgr::getSpecificMissile(const Basic::String* const missileType)
{
Missile* msl = 0;
if (missileType != 0) {
Basic::PairStream* list = getWeapons();
if (list != 0) {
// Find the first free (inactive) missile of type weaponType
Basic::List::Item* item = list->getFirstItem();
while (item != 0 && msl == 0) {
Basic::Pair* pair = (Basic::Pair*)(item->getValue());
Missile* p = dynamic_cast<Missile*>( pair->object() );
if (p != 0 && p->isInactive()) {
// Ok, we have a missile, but is it the type we want?
if (*p->getType() == *missileType) {
p->ref();
msl = p;
}
}
item = item->getNext();
}
list->unref();
}
}
return msl;
}
示例6: setSlotHighlight
//------------------------------------------------------------------------------
// setSlotHighlight() --
//------------------------------------------------------------------------------
bool Field::setSlotHighlight(const Basic::Number* const shobj)
{
if (shobj != 0) {
// Set our mode
if (shobj->getBoolean()) {
setDisplayMode(highlight);
setDisplayMode(highlight1);
}
else {
setDisplayMode(highlight);
setDisplayMode(highlight1);
}
Basic::PairStream* subcomponents = getComponents();
if (subcomponents != 0) {
const Basic::List::Item* item = subcomponents->getFirstItem();
while (item != 0) {
Basic::Pair* p = (Basic::Pair*) item->getValue();
Field* child = dynamic_cast<Field*>(p->object());
if (child != 0) child->setSlotHighlight(shobj); //changed from obj
item = item->getNext();
}
subcomponents->unref();
subcomponents = 0;
}
}
return true;
}
示例7: stepOwnshipPlayer
//------------------------------------------------------------------------------
// stepOwnshipPlayer() -- Step to the next local player
//------------------------------------------------------------------------------
void SimStation::stepOwnshipPlayer()
{
Basic::PairStream* pl = getSimulation()->getPlayers();
if (pl != nullptr) {
Simulation::Player* f = nullptr;
Simulation::Player* n = nullptr;
bool found = false;
// Find the next player
Basic::List::Item* item = pl->getFirstItem();
while (item != nullptr) {
Basic::Pair* pair = static_cast<Basic::Pair*>(item->getValue());
if (pair != nullptr) {
Simulation::Player* ip = static_cast<Simulation::Player*>(pair->object());
if ( ip->isMode(Simulation::Player::ACTIVE) &&
ip->isLocalPlayer() &&
ip->isClassType(typeid(Simulation::AirVehicle))
) {
if (f == nullptr) { f = ip; } // Remember the first
if (found) { n = ip; ; break; }
if (ip == getOwnship()) found = true;
}
}
item = item->getNext();
}
if (found && n == nullptr) n = f;
if (n != nullptr) setOwnshipPlayer(n);
pl->unref();
}
}
示例8: updateData
//------------------------------------------------------------------------------
// updateData()
//------------------------------------------------------------------------------
void Instrument::updateData(const LCreal dt)
{
// update our base class
BaseClass::updateData(dt);
// check for a color rotary, just in case we need one
BasicGL::ColorRotary* cr = dynamic_cast<BasicGL::ColorRotary*>(getColor());
if (cr != 0) cr->determineColor(preScaleInstVal);
// only tell the rest of our instruments our value if we want them to know it
if (allowPassing) {
// sort out the instruments from our components
Basic::PairStream* ps = getComponents();
if (ps != 0) {
Basic::List::Item* item = ps->getFirstItem();
while(item != 0) {
Basic::Pair* pair = (Basic::Pair*) item->getValue();
if (pair != 0) {
// send the value down to all of our instrument components
Instrument* myInst = dynamic_cast<Instrument*>(pair->object());
Basic::Number n = preScaleInstVal;
if (myInst != 0) myInst->event(UPDATE_INSTRUMENTS, &n);
}
item = item->getNext();
}
ps->unref();
ps = 0;
}
}
}
示例9: computeSteerpointData
//------------------------------------------------------------------------------
// Compute nav steering data for each steerpoint.
//------------------------------------------------------------------------------
void Route::computeSteerpointData(const LCreal, const Navigation* const nav)
{
if (nav != nullptr) {
Basic::PairStream* steerpoints = getComponents();
if (steerpoints != nullptr) {
// Until we pass the 'to' steerpoint, the 'from' pointer will be
// null(0) and the steerpoint's compute() function will compute
// direct-to the steerpoint. After the 'to' steerpoint, the 'from'
// pointer will help compute each from-to leg of the route.
Steerpoint* from = nullptr;
Basic::List::Item* item = steerpoints->getFirstItem();
while (item != nullptr) {
Basic::Pair* pair = static_cast<Basic::Pair*>(item->getValue());
Steerpoint* stpt = static_cast<Steerpoint*>(pair->object());
stpt->compute(nav,from);
if (pair == to || from != nullptr) from = stpt;
item = item->getNext();
}
steerpoints->unref();
steerpoints = nullptr;
}
}
}
示例10: setSlotStores
//------------------------------------------------------------------------------
// Set slot functions
//------------------------------------------------------------------------------
bool StoresMgr::setSlotStores(const Basic::PairStream* const msg)
{
// First let our base class do everything that it needs to.
BaseClass::setSlotStores(msg);
// ---
// Clear all previous stores and assigned weapons
// ---
weaponsList = 0;
externalList = 0;
fuelList = 0;
gunPtr = 0;
// ---
// Use the stores list that the Stores class just processed.
Basic::PairStream* stores = getStores();
if (stores != 0){
// Create the new weapons list that contains all weapons
{
Basic::PairStream* newWeapons = new Basic::PairStream();
searchAndAdd(stores, typeid(Weapon), newWeapons);
if (newWeapons->entries() > 0) weaponsList = newWeapons;
newWeapons->unref();
}
// Create the new external stores list that contains all
// non-weapon, external stores (e.g., fuel tanks, pods, guns)
{
Basic::PairStream* newExternal = new Basic::PairStream();
searchAndAdd(stores, typeid(ExternalStore), newExternal);
if (newExternal->entries() > 0) externalList = newExternal;
newExternal->unref();
}
// Create the new fuel tank list that contains all fuel tanks
{
Basic::PairStream* newFuel = new Basic::PairStream();
searchAndAdd(stores, typeid(FuelTank), newFuel);
if (newFuel->entries() > 0) fuelList = newFuel;
newFuel->unref();
}
// Find the primary gun; i.e., the first gun found on our stores
Basic::List::Item* item = stores->getFirstItem();
while (item != 0 && gunPtr == 0) {
Basic::Pair* pair = (Basic::Pair*)(item->getValue());
Gun* p = dynamic_cast<Gun*>( pair->object() );
if (p != 0) gunPtr = p;
item = item->getNext();
}
stores->unref();
stores = 0;
}
return true;
}
示例11: getSteerpoints
//------------------------------------------------------------------------------
// getSteerpoints() -- Get the route we're flying to (starting at 'to')
//------------------------------------------------------------------------------
unsigned int Route::getSteerpoints(Basic::safe_ptr<Steerpoint>* const stptList, const unsigned int max)
{
unsigned int i = 0;
Basic::PairStream* steerpoints = getComponents();
if (stptList != nullptr && max > 0 && steerpoints != nullptr) {
// Find our 'to' steerpoint
bool found = false;
Basic::List::Item* item = steerpoints->getFirstItem();
while (item != nullptr && !found) {
Basic::Pair* pair = static_cast<Basic::Pair*>(item->getValue());
found = (pair == to);
if (!found) {
item = item->getNext();
}
}
// Get the route we're flying 'to'
while (item != nullptr && i < max) {
Basic::Pair* pair = static_cast<Basic::Pair*>(item->getValue());
Steerpoint* p = dynamic_cast<Steerpoint*>(pair->object());
if (p != nullptr) {
stptList[i++] = p;
}
item = item->getNext();
}
}
if (steerpoints != nullptr) {
steerpoints->unref();
steerpoints = nullptr;
}
return i;
}
示例12: onJettisonEvent
// Default weapon jettison event handler
bool Stores::onJettisonEvent(Weapon* const wpn)
{
bool ok = false;
if (wpn != nullptr) {
Basic::PairStream* list = getStores();
if (list != nullptr) {
// First, make sure it's one of ours!
bool found = false;
Basic::List::Item* item = list->getFirstItem();
while (item != nullptr && !found) {
Basic::Pair* pair = static_cast<Basic::Pair*>(item->getValue());
found = (wpn == pair->object()); // is it a match?
item = item->getNext();
}
if (found) {
// Send a jettison event to the weapon
ok = wpn->event(JETTISON_EVENT);
}
list->unref();
list = nullptr;
}
}
return ok;
}
示例13: setOwnshipPlayer
//------------------------------------------------------------------------------
// setOwnshipPlayer() -- set this player as our ownship
//------------------------------------------------------------------------------
bool Station::setOwnshipPlayer(Player* const newOS)
{
// Is it already own ownship? Yes, then nothing else to do.
if (newOS == ownship) return true;
// When we're just setting a null(0) ownship ...
if (newOS == 0) {
// Unref the old player
if (ownshipName != 0) { ownshipName->unref(); ownshipName = 0; }
if (ownship != 0) {
ownship->event(ON_OWNSHIP_DISCONNECT);
ownship->unref();
ownship = 0;
}
return true;
}
// Look for this ownship in our list of players
bool set = false;
Basic::PairStream* pl = sim->getPlayers();
if (pl != 0) {
Basic::List::Item* item = pl->getFirstItem();
while (item != 0 && !set) {
Basic::Pair* pair = dynamic_cast<Basic::Pair*>(item->getValue());
if (pair != 0) {
Player* ip = dynamic_cast<Player*>( pair->object() );
if (ip == newOS && ip->isLocalPlayer()) {
// Unref the old stuff
if (ownshipName != 0) { ownshipName->unref(); ownshipName = 0; }
if (ownship != 0) {
ownship->event(ON_OWNSHIP_DISCONNECT);
ownship->unref();
ownship = 0;
}
// Ok, we found the player -- make it our ownship
ownship = newOS;
ownship->ref();
ownshipName = pair->slot();
ownshipName->ref();
ownship->event(ON_OWNSHIP_CONNECT);
set = true;
}
}
item = item->getNext();
}
pl->unref();
pl = 0;
}
return set;
}
示例14: killedNotification
//------------------------------------------------------------------------------
// killedNotification() -- Default killed notification handler
//------------------------------------------------------------------------------
bool System::killedNotification(Player* const p)
{
// Just let all of our subcomponents know that we were just killed
Basic::PairStream* subcomponents = getComponents();
if(subcomponents != 0) {
for (Basic::List::Item* item = subcomponents->getFirstItem(); item != 0; item = item->getNext()) {
Basic::Pair* pair = (Basic::Pair*)(item->getValue());
Basic::Component* sc = (Basic::Component*) pair->object();
sc->event(KILL_EVENT, p);
}
subcomponents->unref();
subcomponents = 0;
}
return true;
}
示例15: onDatalinkMessageEvent
// DATALINK_MESSAGE event handler
bool Datalink::onDatalinkMessageEvent(Basic::Object* const msg)
{
// Just pass it down to all of our subcomponents
Basic::PairStream* subcomponents = getComponents();
if (subcomponents != 0) {
for (Basic::List::Item* item = subcomponents->getFirstItem(); item != 0; item = item->getNext()) {
Basic::Pair* pair = static_cast<Basic::Pair*>(item->getValue());
Basic::Component* sc = static_cast<Basic::Component*>(pair->object());
sc->event(DATALINK_MESSAGE, msg);
}
subcomponents->unref();
subcomponents = 0;
}
return true;
}