当前位置: 首页>>代码示例>>C++>>正文


C++ Pair::object方法代码示例

本文整理汇总了C++中basic::Pair::object方法的典型用法代码示例。如果您正苦于以下问题:C++ Pair::object方法的具体用法?C++ Pair::object怎么用?C++ Pair::object使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在basic::Pair的用法示例。


在下文中一共展示了Pair::object方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: setSlotBehaviors

bool Arbiter::setSlotBehaviors(Basic::PairStream* const x)
{
   bool ok = true;

   // First, make sure they are all behaviors
   {
      Basic::List::Item* item = x->getFirstItem();
      while (item != nullptr && ok) {
         Basic::Pair* pair = static_cast<Basic::Pair*>(item->getValue());
         item = item->getNext();
         Behavior* b = dynamic_cast<Behavior*>( pair->object() );
         if (b == nullptr) {
            // Item is NOT a behavior
            std::cerr << "setSlotBehaviors: slot: " << *pair->slot() << " is NOT of a Behavior type!" << std::endl;
            ok = false;
         }
      }
   }

   // next, add behaviors to our list
   if (ok) {
      Basic::List::Item* item = x->getFirstItem();
      while (item != nullptr) {
         Basic::Pair* pair = static_cast<Basic::Pair*>(item->getValue());
         item = item->getNext();
         Behavior* b = static_cast<Behavior*>(pair->object());
         addBehavior(b);
      }
   }

   return ok;
}
开发者ID:derekworth,项目名称:afit-swarm-simulation,代码行数:32,代码来源:Arbiter.cpp

示例2: addSymbol

//------------------------------------------------------------------------------
// addSymbol() - adds a symbol to our array list;
// -- return the symbol's index; range [ 1 .. getMaxSymbols() ]
//    or zero if not added.
//------------------------------------------------------------------------------
int SymbolLoader::addSymbol(const int nType, const char* const id, int specName)
{
    int idx = 0;

    if (templates != 0) {

        // Find the graphic template for this type symbol, and make
        // sure that the template is a BasicGL::Graphic, since it
        // will be use as the symbol's graphical component.
        Basic::Pair* tpair = templates->getPosition(nType);
        if (tpair != 0) {
            BasicGL::Graphic* tg = dynamic_cast<BasicGL::Graphic*>(tpair->object());
            if (tg != 0) {

                // Find an empty symbol slot in our master symbol table
                for (int i = 0; i < MAX_SYMBOLS && idx == 0; i++) {
                    if ( symbols[i] == 0 ) {

                        // Create a new SlSymbol object to manage this symbol.
                        symbols[i] = symbolFactory();

                        // Clone the graphic template and set it as the
                        // symbol's graphical component.
                        Basic::Pair* newPair = tpair->clone();
                        BasicGL::Graphic* newGraph = (BasicGL::Graphic*)(newPair->object());

                        // Set the new graphical component's select name
                        GLuint mySelName = 0;
                        if (specName > 0) mySelName = specName;
                        else mySelName = BasicGL::Graphic::getNewSelectName();
                        newGraph->setSelectName(mySelName);

                        // Add the symbol's graphical component to our component list.
                        {
                            Basic::PairStream* comp = getComponents();
                            Basic::Component::processComponents(comp, typeid(BasicGL::Graphic), newPair);
                            if (comp != 0) comp->unref();
                        }

                        // Set the symbol's graphical component pointer
                        symbols[i]->setSymbolPair( newPair );
                        newPair->unref(); // symbol[i] now owns it.

                        // Set the symbol's type and ID.
                        symbols[i]->setType( nType );
                        symbols[i]->setId( id );

                        // And this is the new symbol's index
                        idx = (i + 1);
                    }
                }
            }
        }
    }

    return idx;
}
开发者ID:azcbuell,项目名称:OpenEaagles,代码行数:62,代码来源:SymbolLoader.cpp

示例3: setSymbolType

//------------------------------------------------------------------------------
// setSymbolType() - change an existing symbol type to another type
//------------------------------------------------------------------------------
bool SymbolLoader::setSymbolType(const int idx, const int nType)
{
    bool ok = false;

    // Find the symbol
    if (idx >= 1 && idx <= MAX_SYMBOLS) {
        const int i = (idx - 1);
        if (symbols[i] != 0) {

            // Find the graphic template for this type symbol, and make
            // sure that the template is a BasicGL::Graphic, since it
            // will be use as the symbol's graphical component.
            if (templates != 0) {
                Basic::Pair* tpair = templates->getPosition(nType);
                if (tpair != 0) {
                    BasicGL::Graphic* tg = dynamic_cast<BasicGL::Graphic*>(tpair->object());
                    if (tg != 0) {

                        // Get the symbol's old graphical component
                        Basic::Pair* oldPair = (Basic::Pair*) symbols[i]->getSymbolPair();
                        BasicGL::Graphic* oldG = (BasicGL::Graphic*) (oldPair->object());

                        // Clone the new graphical component from the template
                        Basic::Pair* newPair = tpair->clone();

                        // Set the new graphical component's select name using the old's
                        BasicGL::Graphic* newGraph = (BasicGL::Graphic*) newPair->object();
                        GLuint mySelName = oldG->getSelectName();
                        newGraph->setSelectName(mySelName);

                        // Add the new and remove the old components from our subcomponent list
                        {
                            Basic::PairStream* comp = getComponents();
                            Basic::Component::processComponents(comp, typeid(BasicGL::Graphic), newPair, oldG);
                            if (comp != 0) comp->unref();
                        }

                        // Set the symbol's graphical component pointer
                        symbols[i]->setSymbolPair( newPair );
                        newPair->unref(); // symbol[i] now owns it.

                        // Set new type
                        symbols[i]->setType( nType );

                        ok = true;
                    }

                }
            }
        }

    }
    return ok;
}
开发者ID:azcbuell,项目名称:OpenEaagles,代码行数:57,代码来源:SymbolLoader.cpp

示例4: determineColor

//------------------------------------------------------------------------------
// determineColors() - take our value, and look for a corresponding color
// and breakpoint
//------------------------------------------------------------------------------
bool ColorRotary::determineColor(const LCreal value)
{
    bool ok = false;
    int breakPoint = 0;

    // find out where we are in the break table
    unsigned int i = 0;
    // do an endpoint check while we are at it
    if (value >= myValues[numVals-1]) breakPoint = numVals;
    while (!ok && i < numVals) {
        if (value >= myValues[i] && value < myValues[i+1]){
            breakPoint = (i + 1);
            ok = true;
        }
        else i++;
    }

    // now set the proper color (using the breakpoint index)
    if (myColors != nullptr) {
        Basic::Pair* pair = myColors->getPosition(breakPoint);
        if (pair != nullptr) {
            Basic::Color* listcolor = dynamic_cast<Basic::Color*>(pair->object());
            if (listcolor != nullptr) {
               const osg::Vec4* vec = static_cast<const osg::Vec4*>(listcolor->getRGBA());
               color = *vec;
               ok = true;
            }
        }
    }
    return ok;
}
开发者ID:jmc734,项目名称:OpenEaagles,代码行数:35,代码来源:ColorRotary.cpp

示例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;
}
开发者ID:azcbuell,项目名称:OpenEaagles,代码行数:30,代码来源:StoresMgr.cpp

示例6: reshapeIt

//-----------------------------------------------------------------------------
// reshape it function, for reshaping our subdisplays
//-----------------------------------------------------------------------------
void GlutDisplay::reshapeIt(int w, int h)
{
   //std::cout << "reshapeIt() winID = " << winId;
   //std::cout << "; size(" << w << ", " << h << ")";
   //std::cout << std::endl;
   // make sure we have a min height and width or our displays will get destroyed
   if (w > 10 && h > 10) {
      BaseClass::reshapeIt(w, h);

      if (subDisplays() != nullptr && okToResize) {

         // go through and put our new numbers in
         Basic::List::Item* item = subDisplays()->getFirstItem();
         while (item != nullptr) {
            Basic::Pair* pair = static_cast<Basic::Pair*>(item->getValue());
            if (pair != nullptr) {
               GlutDisplay* gd = dynamic_cast<GlutDisplay*>(pair->object());
               if (gd != nullptr) gd->reshapeSubWindow();
            }
            item = item->getNext();
         }

         // Restore our window ID
         glutSetWindow(this->getWindowId());
      }
   }
}
开发者ID:derekworth,项目名称:afit-swarm-simulation,代码行数:30,代码来源:GlutDisplay.cpp

示例7: 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;
      }
   }
}
开发者ID:derekworth,项目名称:afit-swarm-simulation,代码行数:29,代码来源:Route.cpp

示例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;
      }
   }
}
开发者ID:jmc734,项目名称:OpenEaagles,代码行数:33,代码来源:Instrument.cpp

示例9: searchAndAdd

//------------------------------------------------------------------------------
// Search all of the objects in the main list for objects of 'type' and add
// them to the sublist.  Also check all Stores type objects for any 'type' objects.
//------------------------------------------------------------------------------
void StoresMgr::searchAndAdd(Basic::PairStream* const mainList, const std::type_info& type, Basic::PairStream* sublist)
{
   if (mainList != 0 && sublist != 0) {

      const Basic::List::Item* item = mainList->getFirstItem();
      while (item != 0) {

         Basic::Pair* pair = (Basic::Pair*)(item->getValue());
         Basic::Component* p = (Basic::Component*)( pair->object() );

         // Check the type and add to the list
         bool isType = p->isClassType(type);
         if (isType) sublist->put(pair);

         // If this is a Stores object then check its stores for 'type' objects as well
         Stores* sp = dynamic_cast<Stores*>(p);
         if ( sp != 0 ) {
            Basic::PairStream* pstores = sp->getStores();
            searchAndAdd(pstores, type, sublist);
            pstores->unref();
         }

         item = item->getNext();
      }
   }  
}
开发者ID:azcbuell,项目名称:OpenEaagles,代码行数:30,代码来源:StoresMgr.cpp

示例10: 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();
    }
}
开发者ID:jaegerbomb,项目名称:OpenEaaglesExamples,代码行数:35,代码来源:SimStation.cpp

示例11: builder

		//-----------------------------------------------------------------------------
		// Eaagles::Swarms::builder() -- builds simulation tree
		//-----------------------------------------------------------------------------
		static void builder()
		{
			cout << "Reading file : " << configFile << endl;

			// Read the description file
			int errors = 0;
			Basic::Object* q1 = Basic::lcParser(configFile, Factory::createObj, &errors);
			if (errors > 0) {
				cerr << "File: " << configFile << ", errors: " << errors << endl;
				exit(1);
			}

			station = 0;
			if (q1 != 0) {
				// When we were given a Basic::Pair, get the pointer to its object.
				Basic::Pair* pp = dynamic_cast<Basic::Pair*>(q1);
				if (pp != 0) {
					q1 = pp->object();
				}

				// What we should have here is the Station object
				station = dynamic_cast<Simulation::Station*>(q1);
			}

			// Make sure we did get a valid Station object (we must have one!)
			if (station == 0) {
				cout << "Invalid description file!" << endl;
				exit(EXIT_FAILURE);
			}
		}
开发者ID:derekworth,项目名称:afit-swarm-simulation,代码行数:33,代码来源:main.cpp

示例12: 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;
}
开发者ID:azcbuell,项目名称:OpenEaagles,代码行数:27,代码来源:StoresMgr.cpp

示例13: 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;
}
开发者ID:azcbuell,项目名称:OpenEaagles,代码行数:30,代码来源:StoresMgr.cpp

示例14: 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;
}   
开发者ID:azcbuell,项目名称:OpenEaagles,代码行数:33,代码来源:Field.cpp

示例15: 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;
}
开发者ID:derekworth,项目名称:afit-swarm-simulation,代码行数:29,代码来源:Stores.cpp


注:本文中的basic::Pair::object方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。