📄 property.cxx
字号:
//{{{ Banner //============================================================================//// property.cxx//// Implementation of the CdlProperty class and derived classes.////============================================================================//####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/01/29// Version: 0.02// Description: The CdlProperty class is used to hold the bulk of the// actual data in a CDL script. The CdlOption and other// higher-level classes are essentially just named containers// of properties.////####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 <cdlcore.hxx>//}}}//{{{ Statics // ----------------------------------------------------------------------------CYGDBG_DEFINE_MEMLEAK_COUNTER(CdlPropertyBody);CYGDBG_DEFINE_MEMLEAK_COUNTER(CdlProperty_MinimalBody);CYGDBG_DEFINE_MEMLEAK_COUNTER(CdlProperty_StringBody);CYGDBG_DEFINE_MEMLEAK_COUNTER(CdlProperty_TclCodeBody);CYGDBG_DEFINE_MEMLEAK_COUNTER(CdlProperty_ReferenceBody);CYGDBG_DEFINE_MEMLEAK_COUNTER(CdlProperty_StringVectorBody);CYGDBG_DEFINE_MEMLEAK_COUNTER(CdlProperty_ExpressionBody);CYGDBG_DEFINE_MEMLEAK_COUNTER(CdlProperty_ListExpressionBody);CYGDBG_DEFINE_MEMLEAK_COUNTER(CdlProperty_GoalExpressionBody);//}}}//{{{ CdlProperty base class // ----------------------------------------------------------------------------CdlPropertyBody::CdlPropertyBody(CdlNode node, std::string name_arg, int argc, char** argv_arg, std::vector<std::pair<std::string,std::string> >& options_arg){ CYG_REPORT_FUNCNAME("CdlProperty:: constructor"); CYG_REPORT_FUNCARG3XV(this, node, argc); CYG_PRECONDITIONC(argc > 0); CYG_PRECONDITION_CLASSC(node); name = name_arg; argv.push_back(CdlParse::get_tcl_cmd_name(argv_arg[0])); for (int i = 1; i < argc; i++) { argv.push_back(argv_arg[i]); } options = options_arg; node->properties.push_back(this); cdlpropertybody_cookie = CdlPropertyBody_Magic; CYGDBG_MEMLEAK_CONSTRUCTOR(); CYG_POSTCONDITION_THISC(); CYG_REPORT_RETURN();}CdlPropertyBody::~CdlPropertyBody(){ CYG_REPORT_FUNCNAME("CdlProperty:: destructor"); CYG_REPORT_FUNCARG1("this %p", this); CYG_PRECONDITION_THISC(); cdlpropertybody_cookie = CdlPropertyBody_Invalid; name = ""; argv.clear(); CYGDBG_MEMLEAK_DESTRUCTOR(); CYG_REPORT_RETURN();}std::stringCdlPropertyBody::get_property_name(void) const{ CYG_REPORT_FUNCNAME("CdlProperty::get_property_id"); CYG_REPORT_FUNCARG1("this %p", this); CYG_PRECONDITION_THISC(); CYG_REPORT_RETURN(); return name;}intCdlPropertyBody::get_argc(void) const{ CYG_REPORT_FUNCNAMETYPE("CdlProperty::get_argc", "argc %d"); CYG_REPORT_FUNCARG1("this %p", this); CYG_PRECONDITION_THISC(); int result = argv.size(); CYG_REPORT_RETVAL(result); return result;}const std::vector<std::string>&CdlPropertyBody::get_argv(void) const{ CYG_REPORT_FUNCNAME("CdlProperty::get_argv"); CYG_REPORT_FUNCARG1("this %p", this); CYG_PRECONDITION_THISC(); CYG_REPORT_RETURN(); return argv;}const std::vector<std::pair<std::string,std::string> >&CdlPropertyBody::get_options() const{ CYG_REPORT_FUNCNAME("CdlProperty::get_options"); CYG_REPORT_FUNCARG1XV(this); CYG_PRECONDITION_THISC(); CYG_REPORT_RETURN(); return options;}boolCdlPropertyBody::has_option(std::string name) const{ CYG_REPORT_FUNCNAMETYPE("CdlProperty::has_option", "result %d"); CYG_REPORT_FUNCARG1XV(this); CYG_PRECONDITION_THISC(); bool result = false; std::vector<std::pair<std::string,std::string> >::const_iterator opt_i; for (opt_i = options.begin(); opt_i != options.end(); opt_i++) { if (name == opt_i->first) { result = true; break; } } CYG_REPORT_RETVAL(result); return result;}std::stringCdlPropertyBody::get_option(std::string name) const{ CYG_REPORT_FUNCNAME("CdlProperty::get_option"); CYG_REPORT_FUNCARG1XV(this); CYG_PRECONDITION_THISC(); std::string result = ""; std::vector<std::pair<std::string,std::string> >::const_iterator opt_i; for (opt_i = options.begin(); opt_i != options.end(); opt_i++) { if (name == opt_i->first) { result = opt_i->second; break; } } CYG_REPORT_RETURN(); return result;}// ----------------------------------------------------------------------------// Handling updates. This is a virtual function. The default// implementation does nothing because not all properties contain// references to other CDL entities.voidCdlPropertyBody::update(CdlTransaction transact, CdlNode source, CdlNode dest, CdlUpdate change){ CYG_REPORT_FUNCNAME("CdlProperty::update"); CYG_REPORT_FUNCARG5XV(this, transact, source, dest, change); CYG_PRECONDITION_THISC(); CYG_UNUSED_PARAM(CdlTransaction, transact); CYG_UNUSED_PARAM(CdlNode, source); CYG_UNUSED_PARAM(CdlNode, dest); CYG_UNUSED_PARAM(CdlUpdate, change); CYG_REPORT_RETURN();}// ----------------------------------------------------------------------------boolCdlPropertyBody::check_this(cyg_assert_class_zeal zeal) const{ if (CdlPropertyBody_Magic != cdlpropertybody_cookie) { return false; } CYGDBG_MEMLEAK_CHECKTHIS(); CYG_UNUSED_PARAM(cyg_assert_class_zeal, zeal); return true;}//}}}//{{{ CdlProperty_Minimal class // ----------------------------------------------------------------------------CdlProperty_MinimalCdlProperty_MinimalBody::make(CdlNode node_arg, std::string name_arg, int argc_arg, char** argv_arg, std::vector<std::pair<std::string,std::string> >& options_arg){ return new CdlProperty_MinimalBody(node_arg, name_arg, argc_arg, argv_arg, options_arg);}CdlProperty_MinimalBody::CdlProperty_MinimalBody(CdlNode node_arg, std::string name_arg, int argc_arg, char** argv_arg, std::vector<std::pair<std::string,std::string> >& options_arg) : inherited(node_arg, name_arg, argc_arg, argv_arg, options_arg){ CYG_REPORT_FUNCNAME("CdlProperty_Minimal:: constructor"); CYG_REPORT_FUNCARG1("this %p", this); cdlproperty_minimalbody_cookie = CdlProperty_MinimalBody_Magic; CYGDBG_MEMLEAK_CONSTRUCTOR(); CYG_POSTCONDITION_THISC(); CYG_REPORT_RETURN();}CdlProperty_MinimalBody::~CdlProperty_MinimalBody(){ CYG_REPORT_FUNCNAME("CdlProperty_Minimal:: destructor"); CYG_REPORT_FUNCARG1("this %p", this); CYG_PRECONDITION_THISC(); cdlproperty_minimalbody_cookie = CdlProperty_MinimalBody_Invalid; CYGDBG_MEMLEAK_DESTRUCTOR(); CYG_REPORT_RETURN();}boolCdlProperty_MinimalBody::check_this(cyg_assert_class_zeal zeal) const{ if (CdlProperty_MinimalBody_Magic != cdlproperty_minimalbody_cookie) { return false; } CYGDBG_MEMLEAK_CHECKTHIS(); return inherited::check_this(zeal);}//}}}//{{{ CdlProperty_String class // ----------------------------------------------------------------------------CdlProperty_StringCdlProperty_StringBody::make(CdlNode node_arg, std::string name_arg, std::string value_arg, int argc_arg, char** argv_arg, std::vector<std::pair<std::string,std::string> >& options_arg){ return new CdlProperty_StringBody(node_arg, name_arg, value_arg, argc_arg, argv_arg, options_arg);}CdlProperty_StringBody::CdlProperty_StringBody(CdlNode node_arg, std::string name_arg, std::string value_arg, int argc_arg, char** argv_arg, std::vector<std::pair<std::string,std::string> >& options_arg) : inherited(node_arg, name_arg, argc_arg, argv_arg, options_arg){
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -