Mass++ Common Libraries v2.7.5
 All Classes Namespaces Files Functions Variables Enumerations Macros
Classes | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | Static Protected Attributes | List of all members
kome::objects::Script Class Referenceabstract

script abstract class More...

#include <Script.h>

Collaboration diagram for kome::objects::Script:
Collaboration graph
[legend]

Classes

struct  VariableInfo
 variable information More...
 

Public Member Functions

 Script ()
 constructor
 
virtual ~Script ()
 destructor
 
void setScript (const char *script)
 sets the script More...
 
const char * getScript ()
 gets the script More...
 
void setVariant (kome::objects::Variant &var)
 sets the variant(Active Object) More...
 
const kome::objects::VariantgetVariant (void)
 gets the variant More...
 
void setParameters (kome::objects::Parameters *pParams)
 sets the variant(Active Object) More...
 
const kome::objects::ParametersgetParameters (void)
 gets the parameter More...
 
std::string getTemplate ()
 gets the template More...
 
std::string run (const char *script, kome::objects::Variant &var, kome::objects::Parameters *pParams)
 run the script More...
 
std::string run ()
 run the script More...
 
void clearVariables ()
 clears variables
 
void addVariable (const char *name, const char *desc)
 adds variable
 
unsigned int getNumberOfVariables ()
 gets the number of variables More...
 
const char * getVariableName (const unsigned int idx)
 gets the variable name More...
 
const char * getVariableDescription (const unsigned int idx)
 gets the variable description More...
 

Static Public Member Functions

static void setScriptFilePath (const char *path)
 sets the script file path More...
 
static const char * getScriptFilePath ()
 gets the script file path More...
 

Protected Member Functions

virtual std::string onRun (const char *script, kome::objects::Variant &var, kome::objects::Parameters *pParams)=0
 This method is called from the run method. (abstract method) More...
 
virtual std::string onGetTemplate ()=0
 This method is called from the getTempalte method. (abstract method) More...
 

Protected Attributes

std::string m_script
 
std::vector< VariableInfom_variables
 
kome::objects::Variant m_refVariant
 
kome::objects::Parametersm_pParams
 

Static Protected Attributes

static std::string m_filePath
 

Detailed Description

script abstract class

Definition at line 39 of file Script.h.

Member Function Documentation

unsigned int kome::objects::Script::getNumberOfVariables ( )

gets the number of variables

Returns
the number of variables

Definition at line 156 of file Script.cpp.

156  {
157  return m_variables.size();
158 }
std::vector< VariableInfo > m_variables
Definition: Script.h:67
const kome::objects::Parameters * kome::objects::Script::getParameters ( void  )

gets the parameter

Returns
pointer of parameter

Definition at line 93 of file Script.cpp.

94 {
95  return m_pParams;
96 }
kome::objects::Parameters * m_pParams
Definition: Script.h:77
const char * kome::objects::Script::getScript ( )

gets the script

Returns
character string of the script

Definition at line 62 of file Script.cpp.

62  {
63  return m_script.c_str();
64 }
std::string m_script
Definition: Script.h:55
static const char * kome::objects::Script::getScriptFilePath ( )
static

gets the script file path

Returns
script file path

Definition at line 184 of file Script.cpp.

184  {
185  return m_filePath.c_str();
186 }
static std::string m_filePath
Definition: Script.h:70
std::string kome::objects::Script::getTemplate ( )

gets the template

Returns
template

Definition at line 67 of file Script.cpp.

67  {
68  std::string t = onGetTemplate();
69 
70  return t;
71 }
virtual std::string onGetTemplate()=0
This method is called from the getTempalte method. (abstract method)

Here is the call graph for this function:

const char * kome::objects::Script::getVariableDescription ( const unsigned int  idx)

gets the variable description

Parameters
[in]idxvariable index
Returns
variable description

Definition at line 170 of file Script.cpp.

170  {
171  if( idx >= m_variables.size() ) {
172  return NULL;
173  }
174 
175  return m_variables[ idx ].desc.c_str();
176 }
std::vector< VariableInfo > m_variables
Definition: Script.h:67
#define NULL
Definition: CoreMacros.h:18
const char * kome::objects::Script::getVariableName ( const unsigned int  idx)

gets the variable name

Parameters
[in]idxvariable index
Returns
variable name

Definition at line 161 of file Script.cpp.

161  {
162  if( idx >= m_variables.size() ) {
163  return NULL;
164  }
165 
166  return m_variables[ idx ].name.c_str();
167 }
std::vector< VariableInfo > m_variables
Definition: Script.h:67
#define NULL
Definition: CoreMacros.h:18
const kome::objects::Variant & kome::objects::Script::getVariant ( void  )

gets the variant

Returns
refer of ActiveObject what is provided by the Variant type

Definition at line 81 of file Script.cpp.

82 {
83  return m_refVariant;
84 }
kome::objects::Variant m_refVariant
Definition: Script.h:74
std::string kome::objects::Script::onGetTemplate ( )
protectedpure virtual

This method is called from the getTempalte method. (abstract method)

Returns
template
std::string kome::objects::Script::onRun ( const char *  script,
kome::objects::Variant var,
kome::objects::Parameters pParams 
)
protectedpure virtual

This method is called from the run method. (abstract method)

Parameters
[in]scriptcharacter string of the script
[in]varActiveObject what is provided by the Variant type
[in]pParamspointer of parameter
Returns
result string
std::string kome::objects::Script::run ( const char *  script,
kome::objects::Variant var,
kome::objects::Parameters pParams 
)

run the script

Parameters
[in]scriptcharacter string of the script
[in]varActiveObject what is provided by the Variant type
[in]pParamspointer of parameter
Returns
result string

Definition at line 102 of file Script.cpp.

102  {
103  setScript( script );
104 // >>>>>> @Date:2013/07/29 <Add> A.Ozaki
105  setVariant( var );
106  setParameters( pParams );
107 // <<<<<< @Date:2013/07/29 <Add> A.Ozaki
108 
109  std::string ret = run();
110 
111  return ret;
112 }
std::string run()
run the script
Definition: Script.cpp:115
void setParameters(kome::objects::Parameters *pParams)
sets the variant(Active Object)
Definition: Script.cpp:87
void setVariant(kome::objects::Variant &var)
sets the variant(Active Object)
Definition: Script.cpp:75
void setScript(const char *script)
sets the script
Definition: Script.cpp:57

Here is the call graph for this function:

std::string kome::objects::Script::run ( )

run the script

Returns
result string

Definition at line 115 of file Script.cpp.

115  {
116 // >>>>>> @Date:2013/07/29 <Add> A.Ozaki
117  std::string ret = onRun( m_script.c_str( ), m_refVariant, m_pParams );
118 // <<<<<< @Date:2013/07/29 <Add> A.Ozaki
119 
120  return ret;
121 }
kome::objects::Variant m_refVariant
Definition: Script.h:74
std::string m_script
Definition: Script.h:55
kome::objects::Parameters * m_pParams
Definition: Script.h:77
virtual std::string onRun(const char *script, kome::objects::Variant &var, kome::objects::Parameters *pParams)=0
This method is called from the run method. (abstract method)

Here is the call graph for this function:

void kome::objects::Script::setParameters ( kome::objects::Parameters pParams)

sets the variant(Active Object)

Parameters
[in]pParamspointer of parameter

Definition at line 87 of file Script.cpp.

88 {
89  m_pParams = pParams;
90 }
kome::objects::Parameters * m_pParams
Definition: Script.h:77
void kome::objects::Script::setScript ( const char *  script)

sets the script

Parameters
[in]scriptcharacter string of the script

Definition at line 57 of file Script.cpp.

57  {
58  m_script = NVL( script, "" );
59 }
#define NVL(checkVal, replaceVal)
Definition: CoreMacros.h:99
std::string m_script
Definition: Script.h:55
static void kome::objects::Script::setScriptFilePath ( const char *  path)
static

sets the script file path

Parameters
[in]pathscript file path

Definition at line 179 of file Script.cpp.

179  {
180  m_filePath = NVL( path, "" );
181 }
#define NVL(checkVal, replaceVal)
Definition: CoreMacros.h:99
static std::string m_filePath
Definition: Script.h:70
void kome::objects::Script::setVariant ( kome::objects::Variant var)

sets the variant(Active Object)

Parameters
[in]varActiveObject what is provided by the Variant type

Definition at line 75 of file Script.cpp.

76 {
77  m_refVariant = var;
78 }
kome::objects::Variant m_refVariant
Definition: Script.h:74

Member Data Documentation

std::string Script::m_filePath
staticprotected

script file path

Definition at line 70 of file Script.h.

kome::objects::Parameters* kome::objects::Script::m_pParams
protected

parameter

Definition at line 77 of file Script.h.

kome::objects::Variant kome::objects::Script::m_refVariant
protected

Active Object

Definition at line 74 of file Script.h.

std::string kome::objects::Script::m_script
protected

script

Definition at line 55 of file Script.h.

std::vector< VariableInfo > kome::objects::Script::m_variables
protected

variables

Definition at line 67 of file Script.h.


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