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::stencil Class Reference

class stencil: contains individial model template and keeps track of coordinates for replacement More...

#include <modelTemplate.h>

List of all members.

Public Member Functions

 stencil ()
 stencil (std::string &)
bool parse (std::string &)
 Construct stencil from string.
std::string getTemplate (std::string &, std::string &, std::map< std::string, std::string > &)
 Returns a string with template filled out.
std::string CheckParameter (std::string &)
 Returns the template with all user and identifiers filled out.
void print ()
std::string stringify ()
 Prints template string.

Private Attributes

std::string states
 Returns template string.
std::set< std::string > UserParameterKeys
 Template string.

Detailed Description

class stencil: contains individial model template and keeps track of coordinates for replacement

Definition at line 43 of file modelTemplate.h.


Constructor & Destructor Documentation

StochHMM::stencil::stencil ( )

Definition at line 31 of file modelTemplate.cpp.

{};
StochHMM::stencil::stencil ( std::string &  txt)

Definition at line 33 of file modelTemplate.cpp.

References parse().

{
parse(txt);
}

Member Function Documentation

std::string StochHMM::stencil::CheckParameter ( std::string &  )

Returns the template with all user and identifiers filled out.

std::string StochHMM::stencil::getTemplate ( std::string &  Template,
std::string &  ID,
std::map< std::string, std::string > &  UserValues 
)

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
map_templatemap string of strings filled out in other subroutines

Find all userParameters and replace

Check the coordinates and replace with proper coordinats The name should be only the tagName without brackets But the start should be the position of first bracket and stop should be the position of the last bracket

Definition at line 63 of file modelTemplate.cpp.

References states.

{
std::string FilledOutModel = states;
size_t beginposition=FilledOutModel.find("<<");
size_t endposition=0;
//!Find all userParameters and replace
while (beginposition!=std::string::npos){
endposition=FilledOutModel.find(">>",beginposition+1);
/*!Check the coordinates and replace with proper coordinats
The name should be only the tagName without brackets
But the start should be the position of first bracket and stop
should be the position of the last bracket */
std::string tagName=FilledOutModel.substr(beginposition+2,endposition-beginposition-2);
std::string ValueToFill = UserValues[tagName];
FilledOutModel.replace(beginposition,(endposition+2-beginposition),ValueToFill);
beginposition=FilledOutModel.find("<<",endposition+1);
}
beginposition=FilledOutModel.find("((");
endposition=0;
while (beginposition!=std::string::npos){
endposition=FilledOutModel.find("))",beginposition+1);
/*! */
std::string tagName=FilledOutModel.substr(beginposition+2,endposition-beginposition-2);
std::string ValueToFill = tagName + ID;
FilledOutModel.replace(beginposition,(endposition+2-beginposition),ValueToFill);
beginposition=FilledOutModel.find("((",endposition+1);
}
return FilledOutModel;
}
bool StochHMM::stencil::parse ( std::string &  txt)

Construct stencil from string.

Takes a template string and finds all user defined variables (userParameters). Adds these to a set of strings

Find all userParameters Marks

Definition at line 39 of file modelTemplate.cpp.

References states, and UserParameterKeys.

Referenced by StochHMM::templates::parse(), and stencil().

{
states = txt;
size_t opening=txt.find("<<");
size_t closing=0;
//!Find all userParameters Marks
while (opening!=std::string::npos){
closing=txt.find(">>",opening+1);
std::string tagName=txt.substr(opening+2,closing-opening-2);
UserParameterKeys.insert(tagName);
opening=txt.find("<<",closing+1);
}
return true;
}
void StochHMM::stencil::print ( )
inline

Definition at line 55 of file modelTemplate.h.

References stringify().

{std::cout << stringify() <<std::endl;};//!Prints template string
std::string StochHMM::stencil::stringify ( )
inline

Prints template string.

Definition at line 56 of file modelTemplate.h.

References states.

Referenced by print().

{return states;}; //!Returns template string

Member Data Documentation

std::string StochHMM::stencil::states
private

Returns template string.

Definition at line 56 of file modelTemplate.h.

Referenced by getTemplate(), parse(), and stringify().

std::set<std::string> StochHMM::stencil::UserParameterKeys
private

Template string.

Definition at line 60 of file modelTemplate.h.

Referenced by parse().


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