CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
FWPartialConfigSaveGUI Class Reference

#include <FWPartialConfig.h>

Inheritance diagram for FWPartialConfigSaveGUI:
FWPartialConfigGUI

Public Member Functions

 FWPartialConfigSaveGUI (const char *path_out, const char *path_in, FWConfigurationManager *)
 
void WriteConfig ()
 
 ~FWPartialConfigSaveGUI () override
 
- Public Member Functions inherited from FWPartialConfigGUI
void Cancel ()
 
 FWPartialConfigGUI (const char *path, FWConfigurationManager *)
 
 ~FWPartialConfigGUI () override
 

Private Member Functions

 ClassDefOverride (FWPartialConfigSaveGUI, 0)
 

Private Attributes

std::string m_currFileName
 
std::string m_outFileName
 

Additional Inherited Members

- Protected Member Functions inherited from FWPartialConfigGUI
 ClassDefOverride (FWPartialConfigGUI, 0)
 
- Protected Attributes inherited from FWPartialConfigGUI
FWConfigurationManagerm_cfgMng
 
std::vector< TGCheckButton * > m_entries
 
FWConfiguration m_origConfig
 

Detailed Description

Definition at line 45 of file FWPartialConfig.h.

Constructor & Destructor Documentation

FWPartialConfigSaveGUI::FWPartialConfigSaveGUI ( const char *  path_out,
const char *  path_in,
FWConfigurationManager iCfg 
)

Definition at line 156 of file FWPartialConfig.cc.

References photonIsolationHIProducer_cfi::hf, and TriggerAnalyzer::write().

156  :
157  FWPartialConfigGUI(nullptr, iCfg), m_outFileName(path_out), m_currFileName(path_in)
158 {
159  TGHorizontalFrame* hf = new TGHorizontalFrame(this);
160  AddFrame(hf, new TGLayoutHints( kLHintsRight| kLHintsBottom, 1, 1, 2, 4));
161 
162  TGTextButton* write = new TGTextButton(hf, " Write ");
163  write->Connect("Clicked()", "FWPartialConfigSaveGUI", this, "WriteConfig()");
164  hf->AddFrame(write, new TGLayoutHints(kLHintsExpandX, 2, 2, 0, 0));
165 
166  TGTextButton* cancel = new TGTextButton(hf, " Cancel ");
167  cancel->Connect("Clicked()", "FWPartialConfigGUI", this, "Cancel()");
168  hf->AddFrame(cancel, new TGLayoutHints(kLHintsExpandX, 2, 2, 0, 0));
169 
170  AddFrame(new TGLabel(this, Form("Output file: %s", gSystem->BaseName(path_out))), new TGLayoutHints(kLHintsLeft, 8,2,3,3));
171 
172  SetWindowName("Save Config");
173 
174  MapSubwindows();
175  Layout();
176  MapWindow();
177 }
FWPartialConfigGUI(const char *path, FWConfigurationManager *)
def write(self, setup)
FWPartialConfigSaveGUI::~FWPartialConfigSaveGUI ( )
inlineoverride

Definition at line 49 of file FWPartialConfig.h.

49 {}

Member Function Documentation

FWPartialConfigSaveGUI::ClassDefOverride ( FWPartialConfigSaveGUI  ,
 
)
private
void FWPartialConfigSaveGUI::WriteConfig ( )

Definition at line 181 of file FWPartialConfig.cc.

References FWConfiguration::addKeyValue(), FWXMLConfigParser::config(), cmsStageWithFailover::destination, FrontierConditions_GlobalTag_cff::file, fwLog, g, mps_fire::i, createfilelist::int, fwlog::kError, crabWrapper::key, FWConfiguration::keyValues(), fwlog::kInfo, FWPartialConfigGUI::m_cfgMng, m_currFileName, FWPartialConfigGUI::m_entries, FWPartialConfigGUI::m_origConfig, m_outFileName, SimpleSAXParser::parse(), createfilelist::parser, python.rootplot.root2matplotlib::replace(), FWConfiguration::streamTo(), AlCaHLTBitMon_QueryRunRegistry::string, FWConfiguration::swap(), and FWConfigurationManager::to().

182 {
184  {
185  m_currFileName = gSystem->Which(TROOT::GetMacroPath(), m_currFileName.c_str(), kReadPermission);
186  // printf("going to parse m_currFileName %s\n", m_currFileName.c_str());
187  std::ifstream g(m_currFileName.c_str());
188  if (g.peek() == (int) '<') {
190  parser.parse();
191  parser.config()->swap(destination);
192  // printf("parsed %s ......... \n",m_currFileName.c_str() );
193  }
194  }
195 
196  FWConfiguration curr;
197  m_cfgMng->to(curr);
198 
201 
202  for (auto i = m_entries.begin(); i != m_entries.end(); i++) {
203  if ((*i)->IsOn()) {
204  std::string key = nmm.realName((*i)->GetText()->GetString());
205  // printf("ON check key %s\n", key.c_str());
206  for(FWConfiguration::KeyValues::iterator it = cur_kv->begin(); it != cur_kv->end(); ++it)
207  {
208  if ( key == it->first) {
209  bool replace = false;
210  if (old_kv) {
211  for(FWConfiguration::KeyValues::iterator oldit = old_kv->begin(); oldit != old_kv->end(); ++oldit) {
212  if ( key == oldit->first) {
213  replace = true;
214  oldit->second.swap(it->second);
215  break;
216  }
217  }
218  }
219 
220  if (!replace)
221  destination.addKeyValue(it->first, it->second);
222 
223  break;
224  }
225  }
226  }
227  }
228 
229  // Dump content in the file
230  std::ofstream file(m_outFileName.c_str());
231  if(not file) {
232  fwLog(fwlog::kError) << "FWPartialConfigSaveGUI::Write, can't open output file.!\n";
233  return;
234  }
235  fwLog(fwlog::kInfo) << "Writing configuration to " << m_outFileName << std::endl;
236  FWConfiguration::streamTo(file, destination, "top");
237  UnmapWindow();
238 }
std::vector< std::pair< std::string, FWConfiguration > > KeyValues
void to(FWConfiguration &) const
const KeyValues * keyValues() const
FWConfigurationManager * m_cfgMng
def replace(string, replacements)
std::vector< TGCheckButton * > m_entries
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e g
Definition: Activities.doc:4
FWConfiguration & addKeyValue(const std::string &, const FWConfiguration &)
#define fwLog(_level_)
Definition: fwLog.h:50
FWConfiguration m_origConfig
static void streamTo(std::ostream &oTo, const FWConfiguration &iConfig, const std::string &name)

Member Data Documentation

std::string FWPartialConfigSaveGUI::m_currFileName
private

Definition at line 55 of file FWPartialConfig.h.

Referenced by WriteConfig().

std::string FWPartialConfigSaveGUI::m_outFileName
private

Definition at line 54 of file FWPartialConfig.h.

Referenced by WriteConfig().