本文整理汇总了C++中basic::PairStream::unref方法的典型用法代码示例。如果您正苦于以下问题:C++ PairStream::unref方法的具体用法?C++ PairStream::unref怎么用?C++ PairStream::unref使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类basic::PairStream
的用法示例。
在下文中一共展示了PairStream::unref方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: shutdownNotification
//------------------------------------------------------------------------------
// shutdownNotification() -- We're shutting down
//------------------------------------------------------------------------------
bool StoresMgr::shutdownNotification()
{
// Notify the external stores that we're shutting down
Basic::PairStream* list = getStores();
if (list != 0) {
Basic::List::Item* item = list->getFirstItem();
while (item != 0) {
Basic::Pair* pair = (Basic::Pair*)(item->getValue());
Basic::Component* p = (Basic::Component*)( pair->object() );
p->event(SHUTDOWN_EVENT);
item = item->getNext();
}
list->unref();
list = 0;
}
// Clear our stores
setSlotStores(0);
return BaseClass::shutdownNotification();
}
示例2: updateData
//------------------------------------------------------------------------------
// updateData() -- update non-time critical stuff here
//------------------------------------------------------------------------------
void Stores::updateData(const LCreal dt)
{
// Update our non-weapon, external stores, which need to act as
// active systems attached to our ownship player.
{
Basic::PairStream* list = getStores();
if (list != nullptr) {
Basic::List::Item* item = list->getFirstItem();
while (item != nullptr) {
Basic::Pair* pair = static_cast<Basic::Pair*>(item->getValue());
ExternalStore* p = dynamic_cast<ExternalStore*>( pair->object() );
if (p != nullptr) p->updateData(dt);
item = item->getNext();
}
list->unref();
list = nullptr;
}
}
BaseClass::updateData(dt);
}
示例3: copyData
//------------------------------------------------------------------------------
// copyData() -- copy member data
//------------------------------------------------------------------------------
void SymbolLoader::copyData(const SymbolLoader& org, const bool cc)
{
BaseClass::copyData(org);
if (cc) initData();
// Clear the symbols; the user will need to
// create these with the new template list.
clearLoader();
{
Basic::PairStream* copy = 0;
if (org.templates != 0) {
copy = (Basic::PairStream*) org.templates->clone();
}
setSlotTemplates(copy);
if (copy != 0) copy->unref();
}
showInRangeOnly = org.showInRangeOnly;
interconnect = org.interconnect;
}
示例4: setSlotJustification
//------------------------------------------------------------------------------
// setSlotJustification() --
//------------------------------------------------------------------------------
bool Field::setSlotJustification(const Basic::String* const sjobj)
{
bool ok = true;
if (sjobj != 0) {
// Set our justification
if ( *sjobj == "none" )
justification(Basic::String::NONE);
else if ( *sjobj == "left" )
justification(Basic::String::LEFT);
else if ( *sjobj == "center" )
justification(Basic::String::CENTER);
else if ( *sjobj == "right" )
justification(Basic::String::RIGHT);
else {
if (isMessageEnabled(MSG_ERROR)) {
std::cerr << "Field::setJustification: No proper inputs" << std::endl;
}
ok = false;
}
// Set our children's justification
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->setSlotJustification(sjobj);
item = item->getNext();
}
subcomponents->unref();
subcomponents = 0;
}
}
return ok;
}
示例5: getAllSteerpoints
//------------------------------------------------------------------------------
// getAllSteerpoints() -- Get all of the steerpoints in the route
//------------------------------------------------------------------------------
unsigned int Route::getAllSteerpoints(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) {
Basic::List::Item* item = steerpoints->getFirstItem();
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;
}
示例6: getNextMissileImp
Missile* SimpleStoresMgr::getNextMissileImp()
{
Missile* msl = 0;
Basic::PairStream* list = getWeapons();
if (list != 0) {
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) {
if (p->isInactive() || p->isReleaseHold()) {
msl = (Missile*) p->getPointer();
}
}
item = item->getNext();
}
list->unref();
}
return msl;
}
示例7: setSlotValues
// set our slot values via a pairstream
bool ColorRotary::setSlotValues(const Basic::PairStream* const newStream)
{
bool ok = false;
numVals = 0;
if (newStream != nullptr) {
Basic::PairStream* a = newStream->clone();
Basic::List::Item* item = a->getFirstItem();
while (item != nullptr) {
Basic::Pair* pair = static_cast<Basic::Pair*>(item->getValue());
if (pair != nullptr) {
Basic::Number* n = dynamic_cast<Basic::Number*>(pair->object());
if (n != nullptr) {
myValues[numVals] = n->getReal();
numVals++;
}
}
item = item->getNext();
}
ok = true;
a->unref();
}
return ok;
}
示例8: getNextDecoyImp
Decoy* SimpleStoresMgr::getNextDecoyImp()
{
Decoy* decoy = 0;
Basic::PairStream* list = getWeapons();
if (list != 0) {
Basic::List::Item* item = list->getFirstItem();
while (item != 0 && decoy == 0) {
Basic::Pair* pair = (Basic::Pair*) item->getValue();
Decoy* p = dynamic_cast<Decoy*>( pair->object() );
if (p != 0) {
if (p->isInactive() || p->isReleaseHold()) {
decoy = (Decoy*) p->getPointer();
}
}
item = item->getNext();
}
list->unref();
}
return decoy;
}
示例9: getNextFlareImp
Flare* SimpleStoresMgr::getNextFlareImp()
{
Flare* flare = 0;
Basic::PairStream* list = getWeapons();
if (list != 0) {
Basic::List::Item* item = list->getFirstItem();
while (item != 0 && flare == 0) {
Basic::Pair* pair = (Basic::Pair*) item->getValue();
Flare* p = dynamic_cast<Flare*>( pair->object() );
if (p != 0) {
if (p->isInactive() || p->isReleaseHold()) {
flare = (Flare*) p->getPointer();
}
}
item = item->getNext();
}
list->unref();
}
return flare;
}
示例10: getNextChaffImp
Chaff* SimpleStoresMgr::getNextChaffImp()
{
Chaff* chaff = 0;
Basic::PairStream* list = getWeapons();
if (list != 0) {
Basic::List::Item* item = list->getFirstItem();
while (item != 0 && chaff == 0) {
Basic::Pair* pair = (Basic::Pair*) item->getValue();
Chaff* p = dynamic_cast<Chaff*>( pair->object() );
if (p != 0) {
if (p->isInactive() || p->isReleaseHold()) {
chaff = (Chaff*) p->getPointer();
}
}
item = item->getNext();
}
list->unref();
}
return chaff;
}
示例11: getNextBombImp
Bomb* SimpleStoresMgr::getNextBombImp()
{
Bomb* bomb = 0;
Basic::PairStream* list = getWeapons();
if (list != 0) {
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) {
if (p->isInactive() || p->isReleaseHold()) {
bomb = (Bomb*) p->getPointer();
}
}
item = item->getNext();
}
list->unref();
}
return bomb;
}
示例12: position
void TableRow::position()
{
// position the fields in this table item
Basic::PairStream* subcomponents = getComponents();
if (subcomponents != 0) {
int ln = line();
int cp = column();
Basic::List::Item* item = subcomponents->getFirstItem();
while (item != 0) {
Basic::Pair* pair = static_cast<Basic::Pair*>(item->getValue());
BasicGL::Field* ti = static_cast<BasicGL::Field*>(pair->object());
ti->line(ln);
ti->column(cp);
cp += static_cast<int>(ti->width());
item = item->getNext();
}
subcomponents->unref();
subcomponents = 0;
}
}
示例13: look
void LifeForm::look(const LCreal up, const LCreal sdws)
{
if (getDamage() < 1) {
if (lockMode != LOCKED) {
lockMode = SEARCHING;
// our up and sideways come in as -5 to 5, which is a rate to adjust heading
const osg::Vec3 old = getEulerAngles();
LCreal hdg = old.z();
LCreal ptc = lookAngle;
LCreal tempSdws = sdws;
LCreal tempUp = up;
if (lcAbs(tempSdws) < 0.00005) tempSdws = 0;
if (lcAbs(tempUp) < 0.05) tempUp = 0;
hdg += tempSdws;
hdg = lcAepcRad(hdg);
// we don't change our pitch when we look up and down, we only change our look angle, so we have to keep
// that separate. WE do, however, change our heading based on where we are looking, so that is correct
ptc += tempUp;
if (ptc > 90) ptc = 90;
else if (ptc < -90) ptc = -90;
//std::cout << "HEADING = " << hdg << std::endl;
setLookAngle(ptc);
osg::Vec3 eul(0, 0, hdg);
setEulerAngles(eul);
// now based on this we need to know if we have a target in our crosshairs...
tgtAquired = false;
if (tgtPlayer != nullptr) tgtPlayer->unref();
tgtPlayer = nullptr;
const osg::Vec3 myPos = getPosition();
osg::Vec3 tgtPos;
osg::Vec3 vecPos;
LCreal az = 0.0, el = 0.0, range = 0.0, diffAz = 0.0, diffEl = 0.0;
const LCreal maxAz = (0.7f * static_cast<LCreal>(Basic::Angle::D2RCC));
const LCreal maxEl = (0.7f * static_cast<LCreal>(Basic::Angle::D2RCC));
//LCreal maxRange = 1500.0f; // long range right now
const LCreal la = lookAngle * static_cast<LCreal>(Basic::Angle::D2RCC);
Simulation* sim = getSimulation();
if (sim != nullptr) {
Basic::PairStream* players = sim->getPlayers();
if (players != nullptr) {
Basic::List::Item* item = players->getFirstItem();
while (item != nullptr && !tgtAquired) {
Basic::Pair* pair = static_cast<Basic::Pair*>(item->getValue());
if (pair != nullptr) {
Player* player = dynamic_cast<Player*>(pair->object());
if (player != nullptr && player != this && !player->isMajorType(WEAPON) && !player->isDestroyed()) {
// ok, calculate our position from this guy
tgtPos = player->getPosition();
vecPos = tgtPos - myPos;
az = lcAtan2(vecPos.y(), vecPos.x());
range = (vecPos.x() * vecPos.x() + vecPos.y() * vecPos.y());
range = std::sqrt(range);
// now get our elevation
el = lcAtan2(-vecPos.z(), range);
diffAz = lcAbs(lcAepcRad(az - static_cast<LCreal>(getHeadingR())));
diffEl = lcAbs(lcAepcRad(la - el));
if ((diffAz <= maxAz) && (diffEl <= maxEl)) {
lockMode = TGT_IN_SIGHT;
tgtAquired = true;
if (tgtPlayer != player) {
if (tgtPlayer != nullptr) tgtPlayer->unref();
tgtPlayer = player;
tgtPlayer->ref();
}
}
}
}
item = item->getNext();
}
players->unref();
players = nullptr;
}
}
}
// else we are locking on target, and need to follow our target player
else {
if (tgtPlayer == nullptr) lockMode = SEARCHING;
else {
const osg::Vec3 vecPos = tgtPlayer->getPosition() - getPosition();
const LCreal az = lcAtan2(vecPos.y(), vecPos.x());
LCreal range = (vecPos.x() * vecPos.x() + vecPos.y() * vecPos.y());
range = std::sqrt(range);
// now get our elevation
const LCreal el = lcAtan2(-vecPos.z(), range);
// now force that on us
setLookAngle(el * static_cast<LCreal>(Basic::Angle::R2DCC));
setEulerAngles(0, 0, az);
}
}
}
}
示例14: put
void TableRow::put(Basic::Pair* pp)
{
Basic::PairStream* subcomponents = getComponents();
BaseClass::processComponents(subcomponents, typeid(BasicGL::Field), pp);
if (subcomponents != 0) subcomponents->unref();
}
示例15: findDataFiles
//------------------------------------------------------------------------------
// Initializes the channel array
//------------------------------------------------------------------------------
void QuadMap::findDataFiles()
{
// Clear out the old ones
clearData();
// Find the DataFile objects
{
Basic::PairStream* subcomponents = getComponents();
if (subcomponents != nullptr) {
unsigned int count = 0;
Basic::List::Item* item = subcomponents->getFirstItem();
while (item != nullptr && count < MAX_DATA_FILES) {
Basic::Pair* pair = static_cast<Basic::Pair*>( item->getValue() );
Basic::Terrain* dataFile = dynamic_cast<Basic::Terrain*>( pair->object() );
if (dataFile != nullptr && dataFile->isDataLoaded()) {
dataFile->ref();
dataFiles[count] = dataFile;
count++;
}
item = item->getNext();
}
numDataFiles = count;
subcomponents->unref();
subcomponents = nullptr;
}
}
// Find the max/min elevations and the corner points
if (numDataFiles > 0) {
LCreal elevMin = 999999.0;
LCreal elevMax = -999999.0;
double lowerLat = 90.0;
double lowerLon = 180.0;
double upperLat = -90.0;
double upperLon = -180.0;
for (unsigned int i = 0; i < numDataFiles; i++) {
if (dataFiles[i]->getMinElevation() < elevMin)
elevMin = dataFiles[i]->getMinElevation();
if (dataFiles[i]->getMaxElevation() > elevMax)
elevMax = dataFiles[i]->getMaxElevation();
if (dataFiles[i]->getLatitudeSW() < lowerLat)
lowerLat = dataFiles[i]->getLatitudeSW();
if (dataFiles[i]->getLongitudeSW() < lowerLon)
lowerLon = dataFiles[i]->getLongitudeSW();
if (dataFiles[i]->getLatitudeNE() > upperLat)
upperLat = dataFiles[i]->getLatitudeNE();
if (dataFiles[i]->getLongitudeNE() > upperLon)
upperLon = dataFiles[i]->getLongitudeNE();
}
setMinElevation(elevMin);
setMaxElevation(elevMax);
setLatitudeSW(lowerLat);
setLongitudeSW(lowerLon);
setLatitudeNE(upperLat);
setLongitudeNE(upperLon);
}
else {
setMinElevation(0);
setMaxElevation(0);
setLatitudeSW(0);
setLongitudeSW(0);
setLatitudeNE(0);
setLongitudeNE(0);
}
}