⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 config.cxx

📁 eCos1.31版
💻 CXX
📖 第 1 页 / 共 5 页
字号:
//{{{  Banner                                           //============================================================================////     config.cxx////     Implementation of the CdlConfiguration class////============================================================================//####COPYRIGHTBEGIN####//                                                                          // ----------------------------------------------------------------------------// Copyright (C) 1999, 2000 Red Hat, Inc.//// This file is part of the eCos host tools.//// This program is free software; you can redistribute it and/or modify it // under the terms of the GNU General Public License as published by the Free // Software Foundation; either version 2 of the License, or (at your option) // any later version.// // This program is distributed in the hope that it will be useful, but WITHOUT // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or // FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for // more details.// // You should have received a copy of the GNU General Public License along with// this program; if not, write to the Free Software Foundation, Inc., // 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.//// ----------------------------------------------------------------------------//                                                                          //####COPYRIGHTEND####//============================================================================//#####DESCRIPTIONBEGIN####//// Author(s):   bartv// Contact(s):  bartv// Date:        1999/03/06// Version:     0.02////####DESCRIPTIONEND####//============================================================================//}}}//{{{  #include's                                       // ----------------------------------------------------------------------------#include "cdlconfig.h"// Get the infrastructure types, assertions, tracing and similar// facilities.#include <cyg/infra/cyg_ass.h>#include <cyg/infra/cyg_trac.h>// <cdl.hxx> defines everything implemented in this module.// It implicitly supplies <string>, <vector> and <map> because// the class definitions rely on these headers.#include <cdl.hxx>//}}}//{{{  CdlConfiguration constants and statics           // ----------------------------------------------------------------------------CYGDBG_DEFINE_MEMLEAK_COUNTER(CdlConfigurationBody);//}}}//{{{  CdlConfiguration:: creation                      // ----------------------------------------------------------------------------// The toplevel class will take care of just about everything.CdlConfigurationBody::CdlConfigurationBody(std::string name, CdlPackagesDatabase db, CdlInterpreter interp)    : CdlNodeBody(name),      CdlToplevelBody(interp, db->get_component_repository()){    CYG_REPORT_FUNCNAME("CdlConfiguration:: constructor");    CYG_REPORT_FUNCARG1XV(this);    current_hardware    = "";    current_template    = "";    database            = db;    save_file           = "";    description         = "";        cdlconfigurationbody_cookie = CdlConfigurationBody_Magic;    CYGDBG_MEMLEAK_CONSTRUCTOR();        CYG_POSTCONDITION_THISC();    CYG_REPORT_RETURN();}// ----------------------------------------------------------------------------// The exported interfaceCdlConfigurationCdlConfigurationBody::make(std::string name, CdlPackagesDatabase db, CdlInterpreter interp){    CYG_REPORT_FUNCNAMETYPE("CdlConfiguration::make", "result %p");    CYG_REPORT_FUNCARG2XV(db, interp);    CYG_PRECONDITIONC("" != name);    CYG_PRECONDITION_CLASSC(db);    CYG_PRECONDITION_CLASSC(interp);    CdlConfiguration result = new CdlConfigurationBody(name, db, interp);    CYG_REPORT_RETVAL(result);    return result;}//}}}//{{{  CdlConfiguration:: destructor                    // ----------------------------------------------------------------------------CdlConfigurationBody::~CdlConfigurationBody(){    CYG_REPORT_FUNCNAME("CdlConfiguration:: default destructor");    CYG_REPORT_FUNCARG1("this %p", this);    CYG_PRECONDITION_THISC();    // Removing all the packages has to happen here, and in the    // context of a transaction. The main reason is the extensive    // use of dynamic casts, after this destructor returns    // any dynamic casts for this configuration will fail.    //    // Arguably some of the unloads should happen by clearing    // the hardware and template (assuming those are currently    // set). In practice that would not really gain anything.    //    // Unloading the individual packages is a bit more expensive    // than it should be, since lots of care is taken to keep    // remaining packages consistent and then those get unloaded    // as well. However it is the safe approach.    CdlLocalTransaction transaction(this);    const std::vector<CdlLoadable>& loadables = this->get_loadables();    for (int i = loadables.size() - 1; i >= 0; i--) {        CdlPackage pkg = dynamic_cast<CdlPackage>(loadables[i]);        if (0 != pkg) {            this->unload_package(transaction.get(), pkg);        }    }    transaction.propagate();    transaction.commit();        cdlconfigurationbody_cookie = CdlConfigurationBody_Invalid;    current_hardware            = "";    current_template            = "";    database                    = 0;    save_file                   = "";        CYGDBG_MEMLEAK_DESTRUCTOR();        CYG_REPORT_RETURN();}//}}}//{{{  CdlConfiguration::check_this()                   // ----------------------------------------------------------------------------// There is very little information associated with a configuration.boolCdlConfigurationBody::check_this(cyg_assert_class_zeal zeal) const{    if (CdlConfigurationBody_Magic != cdlconfigurationbody_cookie) {        return false;    }    CYGDBG_MEMLEAK_CHECKTHIS();    switch(zeal) {      case cyg_system_test      :      case cyg_extreme          :          if ((0 == database) || !database->check_this(cyg_quick)) {              return false;          }      case cyg_thorough         :          if (("" != current_hardware) && !database->is_known_target(current_hardware)) {              return false;          }          if (("" != current_template) && !database->is_known_template(current_template)) {              return false;          }      case cyg_quick            :          if (0 == database) {              return false;          }      case cyg_trivial          :      case cyg_none             :      default                   :          break;    }    return CdlNodeBody::check_this(zeal) && CdlContainerBody::check_this(zeal) && CdlToplevelBody::check_this(zeal);}//}}}//{{{  CdlConfiguration:: basic info                    // ----------------------------------------------------------------------------// Provide ready access to configuration-specific data.CdlPackagesDatabaseCdlConfigurationBody::get_database() const{    CYG_REPORT_FUNCNAMETYPE("CdlConfiguration::get_database", "result %p");    CYG_REPORT_FUNCARG1XV(this);    CYG_PRECONDITION_THISC();    CYG_REPORT_RETVAL(database);    return database;}std::stringCdlConfigurationBody::get_hardware() const{    CYG_REPORT_FUNCNAME("CdlConfiguration::get_hardware");    CYG_REPORT_FUNCARG1XV(this);    CYG_PRECONDITION_THISC();    CYG_REPORT_RETURN();    return current_hardware;}voidCdlConfigurationBody::set_hardware_name(std::string new_name){    CYG_REPORT_FUNCNAME("CdlConfiguration::set_hardware_name");    CYG_REPORT_FUNCARG1XV(this);    CYG_PRECONDITION_THISC();    current_hardware = new_name;        CYG_REPORT_RETURN();}std::stringCdlConfigurationBody::get_template() const{    CYG_REPORT_FUNCNAME("CdlConfiguration::get_template");    CYG_REPORT_FUNCARG1XV(this);    CYG_PRECONDITION_THISC();    CYG_REPORT_RETURN();    return current_template;}voidCdlConfigurationBody::set_template_name(std::string new_name){    CYG_REPORT_FUNCNAME("CdlConfiguration::set_template_name");    CYG_REPORT_FUNCARG1XV(this);    CYG_PRECONDITION_THISC();    current_template = new_name;        CYG_REPORT_RETURN();}std::stringCdlConfigurationBody::get_save_file() const{    CYG_REPORT_FUNCNAME("CdlConfiguration::get_save_file");    CYG_REPORT_FUNCARG1XV(this);    CYG_PRECONDITION_THISC();    CYG_REPORT_RETURN();    return save_file;}// ----------------------------------------------------------------------------std::stringCdlConfigurationBody::get_class_name() const{    CYG_REPORT_FUNCNAME("CdlConfiguration::get_class_name");    CYG_PRECONDITION_THISC();    CYG_REPORT_RETURN();    return "CdlConfiguration";}//}}}//{{{  Load and unload operations - wrappers            // ----------------------------------------------------------------------------// These members are basically wrappers for the functions that do the// real work. They do things like running the real functions inside// a newly created transaction.voidCdlConfigurationBody::load_package(std::string name, std::string version,                                   CdlDiagnosticFnPtr error_fn, CdlDiagnosticFnPtr warn_fn, bool limbo)    throw(CdlInputOutputException, CdlParseException, std::bad_alloc){    CYG_REPORT_FUNCNAME("CdlConfiguration::load_package");    CYG_REPORT_FUNCARG1XV(this);    CYG_PRECONDITION_THISC();    CdlLocalTransaction transaction(this);    this->load_package(transaction.get(), name, version, error_fn, warn_fn, limbo);    transaction.body();    CYG_REPORT_RETURN();}voidCdlConfigurationBody::unload_package(std::string name, bool limbo){    CYG_REPORT_FUNCNAME("CdlConfiguration::unload_package");    CYG_REPORT_FUNCARG1XV(this);    CYG_PRECONDITION_THISC();    CdlLocalTransaction transaction(this);    this->unload_package(transaction.get(), name, limbo);    transaction.body();    CYG_REPORT_RETURN();}voidCdlConfigurationBody::unload_package(CdlPackage package, bool limbo){    CYG_REPORT_FUNCNAME("CdlConfiguration::unload_package");    CYG_REPORT_FUNCARG1XV(this);    CdlLocalTransaction transaction(this);    this->unload_package(transaction.get(), package, limbo);    transaction.body();    CYG_REPORT_RETURN();}voidCdlConfigurationBody::unload_package(CdlTransaction transaction, std::string name, bool limbo){    CYG_REPORT_FUNCNAME("CdlConfiguration::unload_package");    CYG_REPORT_FUNCARG3XV(this, transaction, limbo);    CYG_INVARIANT_THISC(CdlConfigurationBody);    CYG_PRECONDITION_CLASSC(transaction);    CdlNode node = lookup(name);    CYG_ASSERTC(0 != node);    CdlPackage package  = dynamic_cast<CdlPackage>(node);    CYG_ASSERTC(0 != package);    this->unload_package(transaction, package, limbo);    CYG_REPORT_RETURN();}voidCdlConfigurationBody::change_package_version(std::string name, std::string version,

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -