StochHMM  v0.34
Flexible Hidden Markov Model C++ Library and Application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Private Attributes
StochHMM::templates Class Reference

class templates: contains a map of all templates More...

#include <modelTemplate.h>

List of all members.

Public Member Functions

 templates ()
 templates (std::string &)
 ~templates ()
 Create templates from file.
bool parse (std::string &)
 Parses the model templates string.
void addTemplate (std::string &)
 hand it a string with multiple stencles and have it parse out each one to be added to the templates
void print ()
std::string & stringify ()
std::string getTemplate (std::string &, std::string &, std::map< std::string, std::string > &)
 returns string representation of states with all parameters filled out

Private Attributes

std::map< std::string, stencil * > temps
 returns all filled out templates for ID give

Detailed Description

class templates: contains a map of all templates

class templates: contains a map of all templates, each should have a different identifier.

Definition at line 66 of file modelTemplate.h.


Constructor & Destructor Documentation

StochHMM::templates::templates ( )

Definition at line 94 of file modelTemplate.cpp.

{}
StochHMM::templates::templates ( std::string &  template_string)

Definition at line 96 of file modelTemplate.cpp.

References parse().

{
templates::parse(template_string);
}
StochHMM::templates::~templates ( )

Create templates from file.

Definition at line 100 of file modelTemplate.cpp.

References temps.

{
std::map<std::string,stencil*>::iterator it;
for(it=temps.begin();it!=temps.end();it++){
std::string key = (*it).first;
delete temps[key];
}
}

Member Function Documentation

void StochHMM::templates::addTemplate ( std::string &  template_string)

hand it a string with multiple stencles and have it parse out each one to be added to the templates

Adds more templates when passed a template string.

Definition at line 144 of file modelTemplate.cpp.

References parse().

{
templates::parse(template_string);
}
std::string StochHMM::templates::getTemplate ( std::string &  Template,
std::string &  ID,
std::map< std::string, std::string > &  UserVals 
)

returns string representation of states with all parameters filled out

Returns a string with template filled out.

Takes the template map and fills it out according to the specific Template you are looking at and the ID number that you want to use

Parameters:
TemplateName of template you want to return
IDThe number iterated in this return

Definition at line 155 of file modelTemplate.cpp.

References temps.

Referenced by StochHMM::model::_processTemplateState().

{
std::string FilledOutModel = temps[Template]->getTemplate(Template,ID,UserVals);
return FilledOutModel;
}
bool StochHMM::templates::parse ( std::string &  model_temp)

Parses the model templates string.

Takes the string passed to it and parses out each template to then be added to the Templates structure using stensil on each one

Definition at line 110 of file modelTemplate.cpp.

References StochHMM::stencil::parse(), and temps.

Referenced by StochHMM::model::_parseTemplates(), addTemplate(), and templates().

{
std::string copyofpassedstring = model_temp;
size_t model_end_position=model_temp.find("TEMPLATE: ",10);
size_t model_start_position=0;
std::string modelstring = "";
std::string stenName;
size_t stenNameStart = 10;
size_t stenNameEnd;
while (model_start_position!=std::string::npos){
stencil* stencil_to_push = new(std::nothrow) stencil();
if (stencil_to_push==NULL){
std::cerr << "OUT OF MEMORY\nFile" << __FILE__ << "Line:\t"<< __LINE__ << std::endl;
exit(1);
}
model_end_position=copyofpassedstring.find("TEMPLATE: ",(model_start_position + 10)) - 1;
modelstring=model_temp.substr(model_start_position,model_end_position - model_start_position);
stenNameEnd=modelstring.find("\n");
stenName=model_temp.substr(stenNameStart,stenNameEnd-stenNameStart);
stencil_to_push->parse(modelstring);
//Need to correctly push the stencil to the map
temps[stenName] = stencil_to_push;
model_start_position=model_end_position + 1;
}
return true;
}
void StochHMM::templates::print ( )
inline

Definition at line 78 of file modelTemplate.h.

References stringify().

{std::cout << stringify() <<std::endl;};
std::string& StochHMM::templates::stringify ( )

Referenced by print().


Member Data Documentation

std::map<std::string,stencil*> StochHMM::templates::temps
private

returns all filled out templates for ID give

Definition at line 88 of file modelTemplate.h.

Referenced by getTemplate(), parse(), and ~templates().


The documentation for this class was generated from the following files: