OpenASIP  2.0
Public Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
Texts::TextGenerator Class Reference

#include <TextGenerator.hh>

Inheritance diagram for Texts::TextGenerator:
Inheritance graph
Collaboration diagram for Texts::TextGenerator:
Collaboration graph

Public Member Functions

 TextGenerator ()
 
virtual ~TextGenerator ()
 
virtual boost::format text (int textId)
 
virtual void addText (int textId, const std::string &templateString)
 
virtual void replaceText (int textId, const std::string &newString)
 

Private Types

typedef std::map< int, const std::string * >::value_type ValType
 value_type for map. More...
 
typedef std::map< int, const std::string * >::iterator MapIter
 Iterator for map. More...
 

Private Member Functions

 TextGenerator (const TextGenerator &)
 Copying not allowed. More...
 
TextGeneratoroperator= (const TextGenerator &)
 Assignment not allowed. More...
 

Private Attributes

std::map< int, const std::string * > dataBase_
 Database that contains all template strings. More...
 

Detailed Description

The class that holds template strings and formats them.

Template strings are added with addText function by giving the text id and the template string. Formatted string are achieved by calling text() with text id and parameters. For example text(TXT_HELLO_WORLD, "all") returns "Hello all world".

Definition at line 79 of file TextGenerator.hh.

Member Typedef Documentation

◆ MapIter

typedef std::map<int, const std::string*>::iterator Texts::TextGenerator::MapIter
private

Iterator for map.

Definition at line 93 of file TextGenerator.hh.

◆ ValType

typedef std::map<int, const std::string*>::value_type Texts::TextGenerator::ValType
private

value_type for map.

Definition at line 91 of file TextGenerator.hh.

Constructor & Destructor Documentation

◆ TextGenerator() [1/2]

Texts::TextGenerator::TextGenerator ( )

Constructor.

Definition at line 55 of file TextGenerator.cc.

55  {
56  addText(Texts::TXT_HELLO_WORLD, "Hello %s world!");
57  addText(Texts::TXT_FILE_NOT_FOUND, "File not found.");
58  addText(Texts::TXT_FILE_X_NOT_FOUND, "File %s not found.");
59  addText(Texts::TXT_FILE_NOT_READABLE, "File not readable.");
60  addText(Texts::TXT_ILLEGAL_INPUT_FILE, "Illegal input file.");
61  addText(Texts::TXT_NO_FILENAME_DEFINED, "No filename defined.");
62  addText(
64  "Only one filename expected.");
65  addText(Texts::TXT_NO_SUCH_SETTING, "No such setting.");
66  addText(Texts::TXT_UNKNOWN_COMMAND, "Unknown command.");
67  addText(Texts::TXT_UNKNOWN_SUBCOMMAND, "Unknown subcommand.");
68  addText(Texts::TXT_ILLEGAL_ARGUMENT, "Illegal argument.");
69  addText(Texts::TXT_ILLEGAL_ARGUMENTS, "Illegal arguments.");
70 
71 }

References addText(), Texts::TXT_FILE_NOT_FOUND, Texts::TXT_FILE_NOT_READABLE, Texts::TXT_FILE_X_NOT_FOUND, Texts::TXT_HELLO_WORLD, Texts::TXT_ILLEGAL_ARGUMENT, Texts::TXT_ILLEGAL_ARGUMENTS, Texts::TXT_ILLEGAL_INPUT_FILE, Texts::TXT_NO_FILENAME_DEFINED, Texts::TXT_NO_SUCH_SETTING, Texts::TXT_ONLY_ONE_FILENAME_EXPECTED, Texts::TXT_UNKNOWN_COMMAND, and Texts::TXT_UNKNOWN_SUBCOMMAND.

Here is the call graph for this function:

◆ ~TextGenerator()

Texts::TextGenerator::~TextGenerator ( )
virtual

Destructor.

Frees the allocated memory.

Definition at line 79 of file TextGenerator.cc.

79  {
80  for (MapIter mi = dataBase_.begin(); mi != dataBase_.end(); mi++) {
81  delete (*mi).second;
82  }
83 }

◆ TextGenerator() [2/2]

Texts::TextGenerator::TextGenerator ( const TextGenerator )
private

Copying not allowed.

Member Function Documentation

◆ addText()

void Texts::TextGenerator::addText ( int  textId,
const std::string &  templateString 
)
virtual

Records a new template string that can be used to generate text messages.

The template string is first copied to the dynamically allocated string, just to ensure that it will be not destroyed before TextGenerator.

Parameters
textIdNumeric code that identifies the template string.
templateStringTemplate string to be recorded.

Definition at line 118 of file TextGenerator.cc.

118  {
119  string* toBeAdded = new string(templateString);
120  dataBase_.insert(ValType(textId, toBeAdded));
121 }

Referenced by ADFSerializerTextGenerator::ADFSerializerTextGenerator(), BEMGeneratorCLITextGenerator::BEMGeneratorCLITextGenerator(), BEMTextGenerator::BEMTextGenerator(), GUITextGenerator::GUITextGenerator(), MachineTestReportTextGenerator::MachineTestReportTextGenerator(), MOMTextGenerator::MOMTextGenerator(), OSEdTextGenerator::OSEdTextGenerator(), PIGCLITextGenerator::PIGCLITextGenerator(), PIGTextGenerator::PIGTextGenerator(), ProDeTextGenerator::ProDeTextGenerator(), SimulatorTextGenerator::SimulatorTextGenerator(), and TextGenerator().

◆ operator=()

TextGenerator& Texts::TextGenerator::operator= ( const TextGenerator )
private

Assignment not allowed.

◆ replaceText()

void Texts::TextGenerator::replaceText ( int  textId,
const std::string &  newString 
)
virtual

Replaces existing text with a new one.

Parameters
textIDID of the text to be replaced
newStringnew string to be set
Exceptions
KeyNotFoundThrown if a text of given ID couldn't be found.

Definition at line 132 of file TextGenerator.cc.

132  {
133  if (!MapTools::containsKey(dataBase_, textId)) {
134  string message("Requested message (code ");
135  message += Conversion::toString(textId) + ") does not exist.";
136  throw KeyNotFound(__FILE__, __LINE__, __FUNCTION__, message);
137  }
138 
139  delete dataBase_[textId];
140  string* toBeAdded = new string(newString);
141  dataBase_[textId] = toBeAdded;
142 }

References MapTools::containsKey(), and Conversion::toString().

Referenced by SimulatorTextGenerator::generateCompiledSimTexts().

Here is the call graph for this function:

◆ text()

format Texts::TextGenerator::text ( int  textId)
virtual

Returns a format object that contains the template string.

Parameters
textIdNumeric code that identifies the template string.
Returns
format object that contains the template string.
Exceptions
KeyNotFoundIf textId doesn't identify any template string.

Definition at line 94 of file TextGenerator.cc.

94  {
95  if (!MapTools::containsKey(dataBase_, textId)) {
96  string method = "TextGenerator::text()";
97  string message("Requested message (code ");
98  message += Conversion::toString(textId) + ") does not exist.";
99  throw KeyNotFound(__FILE__, __LINE__, method, message);
100  }
101 
102  MapIter mt = dataBase_.find(textId);
103  const string& templateString = *((*mt).second);
104 
105  return format(templateString);
106 }

References MapTools::containsKey(), and Conversion::toString().

Referenced by CodeCompressorPlugin::addBitsForGuardField(), CodeCompressorPlugin::addBitsForICField(), CodeCompressorPlugin::addBitsForImmediateSlot(), CodeCompressorPlugin::addBitsForMoveSlot(), TTAMachine::AddressSpace::AddressSpace(), TTAMachine::Bus::adjustSegmentChain(), MachineStateBuilder::bindPortsToOperands(), TTAMachine::Bridge::Bridge(), MachineTestReporter::bridgingError(), CompiledSimSettingCommand::CompiledSimSettingCommand(), TTAMachine::Component::Component(), AddGCUCmd::Do(), AddBridgeCmd::Do(), OSEdBuildCmd::Do(), OSEdModifyBehaviorCmd::Do(), OSEdPropertiesCmd::Do(), OSEdRemoveModuleCmd::Do(), OSEdRemoveOperationCmd::Do(), OSEdUserManualCmd::Do(), OSEdAddModuleCmd::Do(), OSEdBuildAllCmd::Do(), PasteComponentCmd::Do(), DropDownMenu::DropDownMenu(), CodeCompressorPlugin::encodeFUTerminal(), CodeCompressorPlugin::encodeImmediateTerminal(), CodeCompressorPlugin::encodeIUTerminal(), CodeCompressorPlugin::encodeNOP(), CodeCompressorPlugin::encodeRFTerminal(), HelpCommand::execute(), ProgCommand::execute(), ConfCommand::execute(), MachCommand::execute(), InfoProgramCommand::execute(), ProDeBridgeEditPolicy::getCommand(), ProDeBusEditPolicy::getCommand(), ProDeFUEditPolicy::getCommand(), ProDeIUEditPolicy::getCommand(), ProDePortEditPolicy::getCommand(), ProDeSegmentEditPolicy::getCommand(), ProDeSocketEditPolicy::getCommand(), ProDeGCUEditPolicy::getCommand(), ProDeRFEditPolicy::getCommand(), HelpCommand::helpText(), ProgCommand::helpText(), QuitCommand::helpText(), ConfCommand::helpText(), KillCommand::helpText(), MachCommand::helpText(), IgnoreCommand::helpText(), CommandsCommand::helpText(), ResumeCommand::helpText(), ConditionCommand::helpText(), RunCommand::helpText(), DeleteBPCommand::helpText(), DisableBPCommand::helpText(), StepiCommand::helpText(), TBPCommand::helpText(), UntilCommand::helpText(), WatchCommand::helpText(), EnableBPCommand::helpText(), MemDumpCommand::helpText(), NextiCommand::helpText(), BPCommand::helpText(), InfoCommand::helpText(), DisassembleCommand::helpText(), MemWriteCommand::helpText(), SettingCommand::helpText(), TTAMachine::HWOperation::HWOperation(), TTAMachine::ImmediateSlot::ImmediateSlot(), ADFSerializer::immediateUnitToMachine(), SimulatorFrontend::initializeDataMemories(), OSEdInfoView::insertOperationPropertyColumns(), TTAMachine::InstructionTemplate::InstructionTemplate(), CodeCompressorPlugin::instructionTemplate(), ADFSerializer::instructionTemplateToMachine(), SimulatorFrontend::loadMachine(), SimulatorFrontend::loadProcessorConfiguration(), SimulatorFrontend::loadProgram(), TTAMachine::Bridge::loadState(), TTAMachine::Port::loadState(), TTAMachine::HWOperation::loadState(), TTAMachine::InstructionTemplate::loadState(), TTAMachine::ExecutionPipeline::loadState(), TTAMachine::Socket::loadState(), TTAMachine::FunctionUnit::loadState(), TTAMachine::PortGuard::loadState(), TTAMachine::Component::loadState(), TTAMachine::RegisterGuard::loadState(), TTAMachine::FUPort::loadStateWithoutReferences(), TTAMachine::Bus::loadStateWithoutReferences(), main(), OSEdInfoView::moduleView(), OperationPropertyDialog::onAddAffectedBy(), OperationPropertyDialog::onAddAffects(), BusDialog::onAddFUGuard(), OperationDialog::onAddOperand(), OTAFormatListDialog::onAddOTAFormat(), OperationDialog::onAddResource(), BusDialog::onAddRFGuard(), BusDialog::onAddSegment(), ImmediateSlotDialog::onAddSlot(), TemplateListDialog::onAddSlot(), TemplateListDialog::onAddTemplate(), AddressSpacesDialog::onASRightClick(), OSEdMainFrame::onCommandEvent(), OperationDialog::onDeleteOperand(), OperationDialog::onDeleteResource(), OSEdInfoView::onDropDownMenu(), OSEdTreeView::onDropDownMenu(), BusDialog::onFUGuardRightClick(), OSEd::OnInit(), OSEdTreeView::onItemSelected(), RFPortDialog::onOK(), IUPortDialog::onOK(), RFDialog::onOK(), AddModuleDialog::onOk(), SRPortDialog::onOK(), FUPortDialog::onOK(), RFGuardDialog::onOK(), SocketDialog::onOK(), FUGuardDialog::onOK(), FUDialog::onOK(), IUDialog::onOK(), BusDialog::onOK(), AddressSpaceDialog::onOK(), BridgeDialog::onOK(), OperationDialog::onOK(), GCUDialog::onOK(), ResultDialog::onOpen(), OperationPropertyDialog::onOpen(), OperationDialog::onOperandLClick(), GCUDialog::onOperationRightClick(), FUDialog::onOperationRightClick(), RFDialog::onPortRightClick(), FUDialog::onPortRightClick(), GCUDialog::onPortRightClick(), OperationDialog::onResourceLClick(), RFGuardDialog::onRFChoice(), BusDialog::onRFGuardRightClick(), OSEdOptionsDialog::onSave(), BusDialog::onSegmentRightClick(), OSEdInfoView::onSelection(), BusDialog::onUnconditionalGuard(), MDFDocument::openADF(), OSEdInfoView::operationPropertyView(), TTAMachine::OperationTriggeredFormat::OperationTriggeredFormat(), OSEdInfoView::operationView(), OSEdMainFrame::OSEdMainFrame(), OSEdInfoView::pathView(), TTAMachine::Port::Port(), TTAMachine::PortGuard::PortGuard(), SimulatorCmdLineOptions::printHelp(), SimControlLanguageCommand::printStopReasons(), PIGCmdLineOptions::printUsage(), BEMGeneratorCmdLineOptions::printVersion(), PIGCmdLineOptions::printVersion(), SimProgramBuilder::processBidirTerminal(), TTAMachine::RegisterGuard::RegisterGuard(), TTAMachine::Socket::setDirection(), TTAMachine::ControlUnit::setGlobalGuardLatency(), SourceField::setImmediateEncoding(), WidgetTools::setLabel(), GCUDialog::setLabels(), TTAMachine::HWOperation::setName(), TTAMachine::Component::setName(), AboutDialog::setTexts(), OSEdOptionsDialog::setTexts(), OSEdAboutDialog::setTexts(), AddModuleDialog::setTexts(), IUPortDialog::setTexts(), RFPortDialog::setTexts(), OperationDialog::setTexts(), BridgeDialog::setTexts(), ImmediateSlotDialog::setTexts(), FUPortDialog::setTexts(), EditParameterDialog::setTexts(), SRPortDialog::setTexts(), RFGuardDialog::setTexts(), OTAFormatListDialog::setTexts(), TemplateSlotDialog::setTexts(), AddressSpacesDialog::setTexts(), FUGuardDialog::setTexts(), SimulationInfoDialog::setTexts(), MemoryDialog::setTexts(), TemplateListDialog::setTexts(), RFDialog::setTexts(), OutputOperandDialog::setTexts(), SocketDialog::setTexts(), BusDialog::setTexts(), CallExplorerPluginWindow::setTexts(), IUDialog::setTexts(), InputOperandDialog::setTexts(), SimulateDialog::setTexts(), FUDialog::setTexts(), AddressSpaceDialog::setTexts(), OperationDAGDialog::setTexts(), OperationPropertyDialog::setTexts(), SettingCommand::SettingCommand(), SimulateDialog::showOrHideRegisters(), SimulationInfoDialog::SimulationInfoDialog(), MachineTestReporter::socketDirectionSettingError(), MachineTestReporter::socketPortConnectionError(), MachineTestReporter::socketSegmentConnectionError(), RFGuardDialog::TransferDataToWindow(), TTAMachine::UnconditionalGuard::UnconditionalGuard(), OperationPropertyDialog::updateOperation(), OperationDialog::warnOnResourcesWithoutUsages(), and OSEdInfoView::writeStaticPropertiesOfOperation().

Here is the call graph for this function:

Member Data Documentation

◆ dataBase_

std::map<int, const std::string*> Texts::TextGenerator::dataBase_
private

Database that contains all template strings.

Definition at line 101 of file TextGenerator.hh.


The documentation for this class was generated from the following files:
Texts::TXT_UNKNOWN_COMMAND
@ TXT_UNKNOWN_COMMAND
Definition: TextGenerator.hh:64
Texts::TXT_ONLY_ONE_FILENAME_EXPECTED
@ TXT_ONLY_ONE_FILENAME_EXPECTED
Definition: TextGenerator.hh:62
Texts::TextGenerator::MapIter
std::map< int, const std::string * >::iterator MapIter
Iterator for map.
Definition: TextGenerator.hh:93
Conversion::toString
static std::string toString(const T &source)
Texts::TXT_NO_SUCH_SETTING
@ TXT_NO_SUCH_SETTING
Definition: TextGenerator.hh:63
Texts::TextGenerator::addText
virtual void addText(int textId, const std::string &templateString)
Definition: TextGenerator.cc:118
Texts::TXT_ILLEGAL_ARGUMENT
@ TXT_ILLEGAL_ARGUMENT
Definition: TextGenerator.hh:66
Texts::TXT_UNKNOWN_SUBCOMMAND
@ TXT_UNKNOWN_SUBCOMMAND
Definition: TextGenerator.hh:65
Texts::TXT_ILLEGAL_ARGUMENTS
@ TXT_ILLEGAL_ARGUMENTS
Definition: TextGenerator.hh:67
Texts::TXT_ILLEGAL_INPUT_FILE
@ TXT_ILLEGAL_INPUT_FILE
Definition: TextGenerator.hh:60
Texts::TextGenerator::dataBase_
std::map< int, const std::string * > dataBase_
Database that contains all template strings.
Definition: TextGenerator.hh:101
MapTools::containsKey
static bool containsKey(const MapType &aMap, const KeyType &aKey)
Texts::TXT_FILE_NOT_READABLE
@ TXT_FILE_NOT_READABLE
Definition: TextGenerator.hh:59
Texts::TXT_NO_FILENAME_DEFINED
@ TXT_NO_FILENAME_DEFINED
Definition: TextGenerator.hh:61
Texts::TXT_FILE_NOT_FOUND
@ TXT_FILE_NOT_FOUND
Definition: TextGenerator.hh:57
KeyNotFound
Definition: Exception.hh:285
Texts::TXT_FILE_X_NOT_FOUND
@ TXT_FILE_X_NOT_FOUND
Definition: TextGenerator.hh:58
Texts::TXT_HELLO_WORLD
@ TXT_HELLO_WORLD
For testing. Do not remove.
Definition: TextGenerator.hh:56
Texts::TextGenerator::ValType
std::map< int, const std::string * >::value_type ValType
value_type for map.
Definition: TextGenerator.hh:91