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


C++ PairStream::put方法代码示例

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


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

示例1: setSlotOutTheWindow

//-----------------------------------------------------------------------------
// setSlotOutTheWindow() -- Sets a list of Out-The-Window subsystems
//-----------------------------------------------------------------------------
bool Station::setSlotOutTheWindow(Otw* const p)
{
    Basic::PairStream* list = new Basic::PairStream();
    list->put( new Basic::Pair("1",p) );
    bool ok = setSlotOutTheWindow(list);
    list->unref();
    return ok;
}
开发者ID:,项目名称:,代码行数:11,代码来源:

示例2: build

//------------------------------------------------------------------------------
// build() -- build the table in our components list
//------------------------------------------------------------------------------
void Table::build()
{
   Basic::PairStream* newList = 0;

   if (rows > 0 && columns != 0) {

      newList = new Basic::PairStream();

      // For each row: create a TableRow containing all the items in 'columns'
      for (unsigned int i = 1; i <= rows; i++) {

         // new row
         TableRow* row = new TableRow(); 
         row->container(this);

         const Basic::List::Item* item = columns->getFirstItem();
         while (item != 0) {
            const Basic::Pair* pair = static_cast<const Basic::Pair*>(item->getValue());
            const Basic::Object* obj = pair->object();
            if (obj->isClassType(typeid(BasicGL::Graphic))) {
               Basic::Pair* pp = pair->clone();
               BasicGL::Graphic* gobj = static_cast<BasicGL::Graphic*>(pp->object());
               gobj->container(row);
               row->put(pp);
               pp->unref();
            }

            item = item->getNext();
         }

         // put the row on our components list with a slotname equal to its row number
         {
            char cbuf[8];
            sprintf(cbuf,"%d",i);
            Basic::Pair* pp = new Basic::Pair(cbuf,row);
            newList->put(pp);
            pp->unref();
         }

         row->unref();
      }

      // Position our subcomponents
      position();
   }

   // These are new our subcomponents ...
   processComponents(newList,typeid(Basic::Component));
   if (newList != 0) newList->unref();
}
开发者ID:dfileccia,项目名称:OpenEaaglesExamples,代码行数:53,代码来源:Table.cpp

示例3: setSlotColumns

bool Table::setSlotColumns(Basic::PairStream* const msg)
{
   if (columns != 0) { columns->unref(); columns = 0; }
   if (msg != 0) {
      // Make a copy of the list and Make sure we have only Field objexts
      Basic::PairStream* newColumns = new Basic::PairStream();
      Basic::List::Item* item = msg->getFirstItem();
      while (item != 0) {
          Basic::Pair* pair = static_cast<Basic::Pair*>(item->getValue());
          BasicGL::Field* g = dynamic_cast<BasicGL::Field*>(pair->object());
          if (g != 0) {
              // We have a Field object, so add it to the new columns list
              newColumns->put(pair);
          }
          item = item->getNext();
      }
      columns = newColumns;
   }
   build();
   return true;
}
开发者ID:dfileccia,项目名称:OpenEaaglesExamples,代码行数:21,代码来源:Table.cpp

示例4: insertSteerpoint

//------------------------------------------------------------------------------
// insertSteerpoint() -
//------------------------------------------------------------------------------
bool Route::insertSteerpoint(Steerpoint* const newStpt, const int pos)
{
    bool ok = false;
    unsigned int num = getNumberOfSteerpoints();
    // make a new character string
    char numString[10];

    // this tells us the number of the next steerpoint to be created in the slot list
    std::sprintf(numString,"%i",(num+1));

    // now we have the slot name, which is the next number in the steerpoint list
    // now create a new pair, and if we have a component list, add it to it, if
    // not, then create a new component list
    Basic::Pair* p = new Basic::Pair(numString, newStpt);
    if (p != nullptr) {

        // We're its container
        newStpt->container(this);

        // Get our steerpoints
        Basic::PairStream* steerpoints = getComponents();

        // now we have to add it to our component list
        if (steerpoints != nullptr && num != 0) {

            // Copy the current steerpoint list
            Basic::PairStream* tempList = new Basic::PairStream();
            {
               Basic::List::Item* item = steerpoints->getFirstItem();
               while (item != nullptr) {
                  Basic::Pair* pair = (Basic::Pair*) item->getValue();
                  tempList->put(pair);
                  item = item->getNext();
               }
            }

            if (pos == -1) {
               tempList->addHead(p);
               ok = true;
            }

            else if (pos == 0 || pos > num) {
               tempList->addTail(p);
               ok = true;
            }

            else if (pos > 0 && pos <= static_cast<int>(num)) {

                // count to our position, then insert it
                int counter = 1;
                Basic::List::Item* item = tempList->getFirstItem();
                while (counter < pos && item != nullptr) {
                    item = item->getNext();
                    counter++;
                }

                // now we should have the reference pair at the 'pos' position
                if (item != nullptr) {
                    Basic::List::Item* newItem = new Basic::List::Item;
                    newItem->value = p;
                    p->ref();
                    // insert 'newItem' just before 'item'
                    ok = tempList->insert(newItem, item);
                }
            }

            // swap our current steerpoint (components) list for this new one
            if (ok) {
               Basic::Component::processComponents(tempList,typeid(Steerpoint));
            }

            tempList->unref();
            tempList = nullptr;

        }

        // if we have no components, we need to start a new component list
        else {
            Basic::Component::processComponents(nullptr, typeid(Steerpoint), p);
            ok = true;
        }

        // Unref the original steerpoint list
        if (steerpoints != nullptr) {
            steerpoints->unref();
            steerpoints = nullptr;
        }

        p->unref();  // Our component list has it now.
    }

    // ---
    // Call directTo() to reset the steerpoint index, or if we were going nowhere
    // then go direct-to steerpoint one.
    // ---
    if (ok) {
       if (to != nullptr) {
//.........这里部分代码省略.........
开发者ID:derekworth,项目名称:afit-swarm-simulation,代码行数:101,代码来源:Route.cpp

示例5: setSlotStores

// Set the stores
bool Stores::setSlotStores(const Basic::PairStream* const msg)
{
   // ---
   // Quick out if the number of stations hasn't been set.
   // ---
   if (ns == 0 && msg != 0) {
      std::cerr << "Stores::setSlotStation() Number of stations is not set!" << std::endl;
      return false;
   }

   // ---
   // Clear the previous stores and assigned weapons
   // ---
   storesList = 0;
   for (unsigned int s = 1; s <= ns; s++) {
      assignWeaponToStation(s,0);
      assignExtStoreToStation(s,0);
   }
   numWpn = 0;
   numEs = 0;

   // ---
   // Quick out if 'msg' is zero 
   // ---
   if (msg == 0) return true;

   bool ok = true;

   // ---
   // Create the new external stores list
   //
   // For all items in the 'msg' list ...
   //   -- Make sure that it's a weapon or other type of external store, and
   //      that it has a valid station number.
   //   -- Clone the store and if it's a weapon then assign it to the station.
   // ---
   Basic::PairStream* newStores = new Basic::PairStream();

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

      const Basic::Pair* pair = static_cast<const Basic::Pair*>(item->getValue());
      const Basic::Component* p = static_cast<const Basic::Component*>(pair->object());
      if (p != 0) {

         // get the station number from the stores' slot name
         int stationNumber = 0;
         const Basic::Identifier* stationName = pair->slot();
         if (stationName->isInteger()) {
            stationNumber = stationName->getInteger();
         }

         if (stationNumber > 0 && stationNumber <= static_cast<int>(ns)) {

            // check the type of component
            bool isWpn = p->isClassType(typeid(Weapon));
            bool isEE  = p->isClassType(typeid(ExternalStore));

            if ( isWpn || isEE ) {
               // Clone the weapon pair and set us as its container
               Basic::Pair* cpair = pair->clone();
               Component* cp = static_cast<Component*>(cpair->object());
               cp->container(this);

               if ( isWpn ) {
                  // Weapon types ...

                  // Assign the weapon to the station
                  Weapon* cwpn = static_cast<Weapon*>( cpair->object() );
                  assignWeaponToStation(stationNumber, cwpn);

               }

               if ( isEE ) {
                  // External stores types ...

                  // Assign the external store to the station
                  ExternalStore* cwpn = static_cast<ExternalStore*>( cpair->object() );
                  assignExtStoreToStation(stationNumber, cwpn);
               }

               if (cpair != 0) {
                  // Add to the new stores list
                  newStores->put(cpair);
                  cpair->unref(); // the new list has it.
               }
            }
            else {
               std::cerr << "Stores::setSlotStores(): invalid external stores type; use Weapon or Stores classes" << std::endl;
               ok = false;
            }

         }
         else {
            std::cerr << "Stores::setSlotStores(): invalid station number from the store's slot name." << std::endl;
            ok = false;
         }
      }

//.........这里部分代码省略.........
开发者ID:AFIT-Hodson,项目名称:OpenEaagles,代码行数:101,代码来源:Stores.cpp

示例6: setSlotIoHandler

//-----------------------------------------------------------------------------
// setSlotIoHandler() -- Sets a list of I/O handlers
//-----------------------------------------------------------------------------
bool Station::setSlotIoHandler(Basic::IoHandler* const p)
{
    Basic::PairStream* list = new Basic::PairStream();
    list->put( new Basic::Pair("1",p) );
    return setSlotIoHandler(list);
}
开发者ID:,项目名称:,代码行数:9,代码来源:


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