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


C++ PtrVector类代码示例

本文整理汇总了C++中PtrVector的典型用法代码示例。如果您正苦于以下问题:C++ PtrVector类的具体用法?C++ PtrVector怎么用?C++ PtrVector使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: main

int main(int argc, const char *argv[])
{
    PtrVector<Test> vec;  //vector<Test*>   
    for (int i = 0; i < 5; i++) {
        vec.push_back(new Test);
    }
    return 0;
}
开发者ID:Andrew-liu,项目名称:learn_cplusplus,代码行数:8,代码来源:test_ptrvector.cpp

示例2: buildTrackList

/** Rebuild the list of tracks and GPs. This need to be recomputed e.g. to
 *  take unlocked tracks into account.
 */
void TracksScreen::buildTrackList()
{
    DynamicRibbonWidget* tracks_widget = this->getWidget<DynamicRibbonWidget>("tracks");
    RibbonWidget* tabs = this->getWidget<RibbonWidget>("trackgroups");

    // Reset track list everytime (accounts for locking changes, etc.)
    tracks_widget->clearItems();
    m_random_track_list.clear();

    const std::string& curr_group_name = tabs->getSelectionIDString(0);

    const int track_amount = (int)track_manager->getNumberOfTracks();

    // First build a list of all tracks to be displayed
    // (e.g. exclude arenas, ...)
    PtrVector<Track, REF> tracks;
    for (int n = 0; n < track_amount; n++)
    {
        Track* curr = track_manager->getTrack(n);
        if (race_manager->getMinorMode() == RaceManager::MINOR_MODE_EASTER_EGG
            && !curr->hasEasterEggs())
            continue;
        if (curr->isArena() || curr->isSoccer()||curr->isInternal()) continue;
        if (curr_group_name != ALL_TRACK_GROUPS_ID &&
            !curr->isInGroup(curr_group_name)) continue;

        tracks.push_back(curr);
    }   // for n<track_amount

    tracks.insertionSort();
    for (unsigned int i = 0; i < tracks.size(); i++)
    {
        Track *curr = tracks.get(i);
        if (PlayerManager::getCurrentPlayer()->isLocked(curr->getIdent()))
        {
            tracks_widget->addItem(
                _("Locked : solve active challenges to gain access to more!"),
                "locked", curr->getScreenshotFile(), LOCKED_BADGE,
                IconButtonWidget::ICON_PATH_TYPE_ABSOLUTE);
        }
        else
        {
            tracks_widget->addItem(translations->fribidize(curr->getName()),
                curr->getIdent(),
                curr->getScreenshotFile(), 0,
                IconButtonWidget::ICON_PATH_TYPE_ABSOLUTE);
            m_random_track_list.push_back(curr->getIdent());
        }
    }

    tracks_widget->addItem(_("Random Track"), "random_track",
                           "/gui/track_random.png", 0 /* no badge */,
                           IconButtonWidget::ICON_PATH_TYPE_RELATIVE);

    tracks_widget->updateItemDisplay();
    std::random_shuffle( m_random_track_list.begin(), m_random_track_list.end() );
}   // buildTrackList
开发者ID:AkshayGupta94,项目名称:stk-code,代码行数:60,代码来源:tracks_screen.cpp

示例3: addWidgetsRecursively

/** This function adds a list of widgets recursively, effectively creating the hierarchy
 *  of widgets.
 *  \param widgets The vector of widgets to add
 *  \param parent The parent widget of the vector of widgets */
void AbstractTopLevelContainer::addWidgetsRecursively(
                                                    PtrVector<Widget>& widgets,
                                                    Widget* parent)
{
    const unsigned short widgets_amount = widgets.size();

    // ------- add widgets
    for (int n=0; n<widgets_amount; n++)
    {
        if (widgets[n].getType() == WTYPE_DIV)
        {
            widgets[n].add(); // Will do nothing, but will maybe reserve an ID
            addWidgetsRecursively(widgets[n].m_children, &widgets[n]);
        }
        else
        {
            // warn if widget has no dimensions (except for ribbons and icons,
            // where it is normal since it adjusts to its contents)
            if ((widgets[n].m_w < 1 || widgets[n].m_h < 1) &&
                widgets[n].getType() != WTYPE_RIBBON &&
                widgets[n].getType() != WTYPE_ICON_BUTTON &&
                widgets[n].getType() != WTYPE_SPACER)
            {
                Log::warn("AbstractTopLevelContainer::addWidgetsRecursively",
                    "Widget %s of type %d has no dimensions",
                    widgets[n].m_properties[PROP_ID].c_str(), widgets[n].getType());
            }

            if (widgets[n].m_x == -1 || widgets[n].m_y == -1)
            {
                Log::warn("AbstractTopLevelContainer::addWidgetsRecursively",
                    "Widget %s of type %d has no position",
                    widgets[n].m_properties[PROP_ID].c_str(), widgets[n].getType());
            }

            widgets[n].add();
        }

    } // for n in all widgets

}   // addWidgetsRecursively
开发者ID:Cav098,项目名称:stk-code-fix_1797,代码行数:45,代码来源:abstract_top_level_container.cpp

示例4: assert

void KartSelectionScreen::setKartsFromCurrentGroup()
{
    RibbonWidget* tabs = getWidget<RibbonWidget>("kartgroups");
    assert(tabs != NULL);

    std::string selected_kart_group =
        tabs->getSelectionIDString(PLAYER_ID_GAME_MASTER);

    UserConfigParams::m_last_used_kart_group = selected_kart_group;

    // This can happen if addons are removed so that also the previously
    // selected kart group is removed. In this case, select the
    // 'standard' group
    if (selected_kart_group != ALL_KART_GROUPS_ID &&
        !kart_properties_manager->getKartsInGroup(selected_kart_group).size())
    {
        selected_kart_group = DEFAULT_GROUP_NAME;
    }

    DynamicRibbonWidget* w = getWidget<DynamicRibbonWidget>("karts");
    w->clearItems();

    int usable_kart_count = 0;
    PtrVector<const KartProperties, REF> karts;

    for(unsigned int i=0; i<kart_properties_manager->getNumberOfKarts(); i++)
    {
        const KartProperties* prop = kart_properties_manager->getKartById(i);
        // Ignore karts that are not in the selected group
        if(selected_kart_group != ALL_KART_GROUPS_ID &&
            !prop->isInGroup(selected_kart_group))
            continue;
        karts.push_back(prop);
    }
    karts.insertionSort();

    for(unsigned int i=0; i<karts.size(); i++)
    {
        const KartProperties* prop = karts.get(i);
        if (PlayerManager::getCurrentPlayer()->isLocked(prop->getIdent()) &&
            !m_multiplayer)
        {
            w->addItem(_("Locked : solve active challenges to gain access to more!"),
                       ID_LOCKED + prop->getIdent(),
                       prop->getAbsoluteIconFile(), LOCKED_BADGE,
                       IconButtonWidget::ICON_PATH_TYPE_ABSOLUTE);
        }
        else
        {
            w->addItem(translations->fribidize(prop->getName()),
                       prop->getIdent(),
                       prop->getAbsoluteIconFile(), 0,
                       IconButtonWidget::ICON_PATH_TYPE_ABSOLUTE);
            usable_kart_count++;
        }
    }

    // add random
    if (usable_kart_count > 1)
    {
        w->addItem(_("Random Kart"), RANDOM_KART_ID, "/gui/random_kart.png");
    }

    w->updateItemDisplay();
}
开发者ID:Elderme,项目名称:stk-code,代码行数:65,代码来源:kart_selection.cpp

示例5:

// ============================================================================
GroupUserConfigParam::GroupUserConfigParam(const char* group_name,
                                           const char* comment)
{
    m_param_name = group_name;
    all_params.push_back(this);
    if(comment != NULL) m_comment = comment;
}   // GroupUserConfigParam
开发者ID:shantanusingh10,项目名称:stk-code,代码行数:8,代码来源:user_config.cpp

示例6: saveConfig

/** Write settings to config file. */
void UserConfig::saveConfig()
{
    const std::string filename = file_manager->getUserConfigFile(m_filename);

    try
    {
        std::ofstream configfile (filename.c_str(), std::ofstream::out);

        configfile << "<?xml version=\"1.0\"?>\n";
        configfile << "<stkconfig version=\"" << m_current_config_version
                   << "\" >\n\n";

        const int paramAmount = all_params.size();
        for(int i=0; i<paramAmount; i++)
        {
            //Log::info("UserConfig", "Saving parameter %d to file", i);
            all_params[i].write(configfile);
        }

        configfile << "</stkconfig>\n";
        configfile.close();
    }
    catch (std::runtime_error& e)
    {
        Log::error("UserConfig::saveConfig", "Failed to write config to %s, because %s",
                   filename.c_str(), e.what());
    }

}   // saveConfig
开发者ID:shiv05,项目名称:stk-code,代码行数:30,代码来源:user_config.cpp

示例7: saveConfig

/** Write settings to config file. */
void UserConfig::saveConfig()
{
    const std::string filename = file_manager->getUserConfigFile(m_filename);

    try
    {
        std::ofstream configfile (filename.c_str(), std::ofstream::out);

        configfile << "<?xml version=\"1.0\"?>\n";
        configfile << "<stkconfig version=\"" << m_current_config_version
                   << "\" >\n\n";

        const int paramAmount = all_params.size();
        for(int i=0; i<paramAmount; i++)
        {
            //std::cout << "saving parameter " << i << " to file\n";
            all_params[i].write(configfile);
        }

        configfile << "</stkconfig>\n";
        configfile.close();
    }
    catch (std::runtime_error& e)
    {
        std::cerr << "[UserConfig::saveConfig] ERROR: Failed to write config to " << filename.c_str()
                  << "; cause : " << e.what() << "\n";
    }

}   // saveConfig
开发者ID:shantanusingh10,项目名称:stk-code,代码行数:30,代码来源:user_config.cpp

示例8: OnEvent

    virtual bool OnEvent(const SEvent& event)
    {
        bool out = CGUIEditBox::OnEvent(event);

        if (event.EventType == EET_KEY_INPUT_EVENT && event.KeyInput.PressedDown)
        {
            for (unsigned int n=0; n<m_listeners.size(); n++)
            {
                m_listeners[n].onTextUpdated();
            }
        }

        return out;
    }
开发者ID:Cav098,项目名称:stk-code-fix_1797,代码行数:14,代码来源:text_box_widget.cpp

示例9: getTotalKarts

 /** Returns the total number of karts of this GP. */
 int getTotalKarts() const { return m_karts.size(); }
开发者ID:jeremiejig,项目名称:paf-autostereoscopie-2014,代码行数:2,代码来源:saved_grand_prix.hpp

示例10: getNumPlayers

 /** Returns the number of players in the config file.*/
 unsigned int getNumPlayers() const { return m_all_players.size(); }
开发者ID:PalashBansal,项目名称:stk-code,代码行数:2,代码来源:player_manager.hpp

示例11: getKeyboardConfig

 KeyboardConfig*     getKeyboardConfig(const int i)      { return m_keyboard_configs.get(i); }
开发者ID:langresser,项目名称:stk,代码行数:1,代码来源:device_manager.hpp

示例12: getKeyboard

 KeyboardDevice*     getKeyboard(const int i)            { return m_keyboards.get(i); }
开发者ID:langresser,项目名称:stk,代码行数:1,代码来源:device_manager.hpp

示例13: getKeyboardConfigAmount

 int                 getKeyboardConfigAmount() const     { return m_keyboard_configs.size(); }
开发者ID:langresser,项目名称:stk,代码行数:1,代码来源:device_manager.hpp

示例14: clearListeners

 void clearListeners()
 {
     m_listeners.clearWithoutDeleting();
 }
开发者ID:Cav098,项目名称:stk-code-fix_1797,代码行数:4,代码来源:text_box_widget.cpp

示例15: getGamepadConfig

 GamepadConfig*      getGamepadConfig(const int i)       { return m_gamepad_configs.get(i); }
开发者ID:langresser,项目名称:stk,代码行数:1,代码来源:device_manager.hpp


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