Open-Transactions  0.93.0-ge03d287
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
opentxs::OTScript Class Reference

#include <OTScript.hpp>

Collaboration diagram for opentxs::OTScript:

Public Member Functions

 OTScript ()
 
 OTScript (const OTString &strValue)
 
 OTScript (const char *new_string)
 
 OTScript (const char *new_string, size_t sizeLength)
 
 OTScript (const std::string &new_string)
 
virtual ~OTScript ()
 
EXPORT void SetScript (const OTString &strValue)
 
EXPORT void SetScript (const char *new_string)
 
EXPORT void SetScript (const char *new_string, size_t sizeLength)
 
EXPORT void SetScript (const std::string &new_string)
 
void SetDisplayFilename (std::string str_display_filename)
 
void AddParty (std::string str_party_name, OTParty &theParty)
 
void AddAccount (std::string str_acct_name, OTPartyAccount &theAcct)
 
EXPORT void AddVariable (std::string str_var_name, OTVariable &theVar)
 
EXPORT OTVariableFindVariable (std::string str_var_name)
 
EXPORT void RemoveVariable (OTVariable &theVar)
 
virtual bool ExecuteScript (OTVariable *pReturnVar=nullptr)
 

Protected Attributes

std::string m_str_script
 
std::string m_str_display_filename
 
mapOfParties m_mapParties
 
mapOfPartyAccounts m_mapAccounts
 
mapOfVariables m_mapVariables
 

Detailed Description

Definition at line 174 of file OTScript.hpp.

Constructor & Destructor Documentation

opentxs::OTScript::OTScript ( )

Definition at line 275 of file OTScript.cpp.

276 {
277 }
opentxs::OTScript::OTScript ( const OTString strValue)

Definition at line 279 of file OTScript.cpp.

280  : m_str_script(strValue.Get())
281 {
282 }
std::string m_str_script
Definition: OTScript.hpp:177
opentxs::OTScript::OTScript ( const char *  new_string)

Definition at line 284 of file OTScript.cpp.

285  : m_str_script(new_string)
286 {
287 }
std::string m_str_script
Definition: OTScript.hpp:177
opentxs::OTScript::OTScript ( const char *  new_string,
size_t  sizeLength 
)

Definition at line 289 of file OTScript.cpp.

290  : m_str_script(new_string, sizeLength)
291 {
292 }
std::string m_str_script
Definition: OTScript.hpp:177
opentxs::OTScript::OTScript ( const std::string &  new_string)

Definition at line 294 of file OTScript.cpp.

295  : m_str_script(new_string)
296 {
297 }
std::string m_str_script
Definition: OTScript.hpp:177
opentxs::OTScript::~OTScript ( )
virtual

Definition at line 299 of file OTScript.cpp.

300 {
301  // mapOfParties; // NO NEED to clean this up, since OTScript doesn't own the
302  // parties.
303  // See OTSmartContract, rather, for that.
304 
305  while (!m_mapVariables.empty()) {
306  OTVariable* pVar = m_mapVariables.begin()->second;
307  OT_ASSERT(nullptr != pVar);
308 
309  // NOTE: We're NOT going to delete pVar, since we don't own it.
310  // But we ARE going to remove pVar's pointer to this script, so
311  // pVar doesn't dereference a bad pointer later on.
312  //
313  pVar->UnregisterScript();
314  m_mapVariables.erase(m_mapVariables.begin());
315  }
316 }
#define OT_ASSERT(x)
Definition: Assert.hpp:150
mapOfVariables m_mapVariables
Definition: OTScript.hpp:185

Member Function Documentation

void opentxs::OTScript::AddAccount ( std::string  str_acct_name,
OTPartyAccount theAcct 
)

Definition at line 363 of file OTScript.cpp.

364 {
365  m_mapAccounts.insert(
366  std::pair<std::string, OTPartyAccount*>(str_acct_name, &theAcct));
367 
368  // We're just storing these pointers for reference value. Script doesn't
369  // actually Own the
370  // accounts, and isn't responsible to clean them up.
371 }
mapOfPartyAccounts m_mapAccounts
Definition: OTScript.hpp:182
void opentxs::OTScript::AddParty ( std::string  str_party_name,
OTParty theParty 
)

Definition at line 350 of file OTScript.cpp.

351 {
352  // typedef std::map<std::string, OTParty *> mapOfParties;
353 
354  m_mapParties.insert(
355  std::pair<std::string, OTParty*>(str_party_name, &theParty));
356  // We're just storing these pointers for reference value. Script doesn't
357  // actually Own the
358  // parties, and isn't responsible to clean them up.
359 
360  theParty.RegisterAccountsForExecution(*this);
361 }
mapOfParties m_mapParties
Definition: OTScript.hpp:180
void opentxs::OTScript::AddVariable ( std::string  str_var_name,
OTVariable theVar 
)

Definition at line 380 of file OTScript.cpp.

381 {
382  // mapOfVariables m_mapVariables;
383 
384  m_mapVariables.insert(
385  std::pair<std::string, OTVariable*>(str_var_name, &theVar));
386 
387  // We're just storing these pointers for reference value. Script doesn't
388  // actually Own the
389  // variables, and isn't responsible to clean them up.
390 }
mapOfVariables m_mapVariables
Definition: OTScript.hpp:185
bool opentxs::OTScript::ExecuteScript ( OTVariable pReturnVar = nullptr)
virtual

Definition at line 416 of file OTScript.cpp.

417 {
418  otErr << "OTScript::ExecuteScript: Scripting has been disabled.\n";
419  return true;
420 }
OTLOG_IMPORT OTLogStream otErr
OTVariable * opentxs::OTScript::FindVariable ( std::string  str_var_name)

Definition at line 392 of file OTScript.cpp.

393 {
394  auto it_var = m_mapVariables.find(str_var_name);
395  return it_var != m_mapVariables.end() ? it_var->second : nullptr;
396 }
mapOfVariables m_mapVariables
Definition: OTScript.hpp:185
void opentxs::OTScript::RemoveVariable ( OTVariable theVar)

Definition at line 405 of file OTScript.cpp.

406 {
407  const std::string str_var_name = theVar.GetName().Get();
408  auto it_var = m_mapVariables.find(str_var_name);
409 
410  if (it_var != m_mapVariables.end()) {
411  m_mapVariables.erase(it_var); // no need to delete the variable pointer
412  // since the script doesn't own it anyway.
413  }
414 }
mapOfVariables m_mapVariables
Definition: OTScript.hpp:185
void opentxs::OTScript::SetDisplayFilename ( std::string  str_display_filename)
inline

Definition at line 204 of file OTScript.hpp.

205  {
206  m_str_display_filename = str_display_filename;
207  }
std::string m_str_display_filename
Definition: OTScript.hpp:178
void opentxs::OTScript::SetScript ( const OTString strValue)

Definition at line 318 of file OTScript.cpp.

319 {
320  if (strValue.Exists()) m_str_script = strValue.Get();
321 }
std::string m_str_script
Definition: OTScript.hpp:177
void opentxs::OTScript::SetScript ( const char *  new_string)

Definition at line 323 of file OTScript.cpp.

324 {
325  if (nullptr != new_string) m_str_script = new_string;
326 }
std::string m_str_script
Definition: OTScript.hpp:177
void opentxs::OTScript::SetScript ( const char *  new_string,
size_t  sizeLength 
)

Definition at line 328 of file OTScript.cpp.

329 {
330  if (nullptr != new_string) m_str_script.assign(new_string, sizeLength);
331 }
std::string m_str_script
Definition: OTScript.hpp:177
void opentxs::OTScript::SetScript ( const std::string &  new_string)

Definition at line 333 of file OTScript.cpp.

334 {
335  m_str_script = new_string;
336 }
std::string m_str_script
Definition: OTScript.hpp:177

Member Data Documentation

mapOfPartyAccounts opentxs::OTScript::m_mapAccounts
protected

Definition at line 182 of file OTScript.hpp.

mapOfParties opentxs::OTScript::m_mapParties
protected

Definition at line 180 of file OTScript.hpp.

mapOfVariables opentxs::OTScript::m_mapVariables
protected

Definition at line 185 of file OTScript.hpp.

std::string opentxs::OTScript::m_str_display_filename
protected

Definition at line 178 of file OTScript.hpp.

std::string opentxs::OTScript::m_str_script
protected

Definition at line 177 of file OTScript.hpp.


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