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


C++ KVNameValueList::GetParameter方法代码示例

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


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

示例1: Merge

void KVNameValueList::Merge(const KVNameValueList& other)
{
   // Merge other list into this one.
   // Any parameters in 'other' which do not exist in this one are added.
   // Any parameters which exist in both have their values summed.

   for (int i = 0; i < other.GetNpar(); ++i) {
      KVNamedParameter* np_other = other.GetParameter(i);
      AddValue(*np_other);
   }
}
开发者ID:FableQuentin,项目名称:kaliveda,代码行数:11,代码来源:KVNameValueList.cpp

示例2: AddGetSetMethods

void KVClassFactory::AddGetSetMethods(const KVNameValueList& nvl)
{
   // For each named parameter in the list, we add protected member variables and
   // public Get/Set methods with the name and type of the parameter.
   // Example: given a list containing NAME="some string" NUMBER=3 [integer]
   // PI=3.141592 [double], we generate the methods
   //   void SetNAME(const TString&);
   //   const TString& GetNAME() const;
   //   void SetNUMBER(Int_t);
   //   Int_t GetNUMBER() const;
   //   void SetPI(Double_t);
   //   Double_t GetPI() const;

   int npars = nvl.GetNpar();
   for(int i=0; i<npars; i++){
      KVNamedParameter* par = nvl.GetParameter(i);
      if(par->IsString()){
         KVClassMember* v = AddMember(par->GetName(),"TString","member automatically generated by KVClassFactory::AddGetSetMethods");
         KVClassMethod* m = AddMethod(Form("Set%s",par->GetName()), "void");
         m->AddArgument("const TString&");
         m->SetMethodBody(
Form("    // Method automatically generated by KVClassFactory::AddGetSetMethods\n"
"\n"
"    %s=arg1;", v->GetName())
         );
         m = AddMethod(Form("Get%s",par->GetName()), "const TString&", "public", kFALSE, kTRUE);
         m->SetMethodBody(
Form("    // Method automatically generated by KVClassFactory::AddGetSetMethods\n"
"\n"
"    return %s;", v->GetName())
                  );
         // make sure #include "TString.h" appears in header file
         if( ! fHeadInc.FindObject("TString.h") ) AddHeaderIncludeFile("TString.h");
      }
      else if(par->IsInt()){
         KVClassMember* v = AddMember(par->GetName(),"Int_t","member automatically generated by KVClassFactory::AddGetSetMethods");
         KVClassMethod* m = AddMethod(Form("Set%s",par->GetName()), "void");
         m->AddArgument("Int_t");
         m->SetMethodBody(
Form("    // Method automatically generated by KVClassFactory::AddGetSetMethods\n"
"\n"
"    %s=arg1;", v->GetName())
         );
         m = AddMethod(Form("Get%s",par->GetName()), "Int_t", "public", kFALSE, kTRUE);
         m->SetMethodBody(
Form("    // Method automatically generated by KVClassFactory::AddGetSetMethods\n"
"\n"
"    return %s;", v->GetName())
                  );
      }
      else if(par->IsDouble()){
         KVClassMember* v = AddMember(par->GetName(),"Double_t","member automatically generated by KVClassFactory::AddGetSetMethods");
         KVClassMethod* m = AddMethod(Form("Set%s",par->GetName()), "void");
         m->AddArgument("Double_t");
         m->SetMethodBody(
Form("    // Method automatically generated by KVClassFactory::AddGetSetMethods\n"
"\n"
"    %s=arg1;", v->GetName())
         );
         m = AddMethod(Form("Get%s",par->GetName()), "Double_t", "public", kFALSE, kTRUE);
         m->SetMethodBody(
Form("    // Method automatically generated by KVClassFactory::AddGetSetMethods\n"
"\n"
"    return %s;", v->GetName())
                  );
      }
   }
}
开发者ID:pwigg,项目名称:kaliveda,代码行数:68,代码来源:KVClassFactory.cpp


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