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

#include <OTStashItem.hpp>

Public Member Functions

int64_t GetAmount () const
 
void SetAmount (int64_t lAmount)
 
bool CreditStash (const int64_t &lAmount)
 
bool DebitStash (const int64_t &lAmount)
 
const OTStringGetAssetTypeID ()
 
 OTStashItem ()
 
 OTStashItem (const OTString &strAssetTypeID, int64_t lAmount=0)
 
 OTStashItem (const OTIdentifier &theAssetTypeID, int64_t lAmount=0)
 
virtual ~OTStashItem ()
 

Detailed Description

Definition at line 141 of file OTStashItem.hpp.

Constructor & Destructor Documentation

opentxs::OTStashItem::OTStashItem ( )

Definition at line 149 of file OTStashItem.cpp.

150  : m_lAmount(0)
151 {
152 }
opentxs::OTStashItem::OTStashItem ( const OTString strAssetTypeID,
int64_t  lAmount = 0 
)

Definition at line 154 of file OTStashItem.cpp.

155  : m_strAssetTypeID(strAssetTypeID)
156  , m_lAmount(lAmount)
157 {
158 }
opentxs::OTStashItem::OTStashItem ( const OTIdentifier theAssetTypeID,
int64_t  lAmount = 0 
)

Definition at line 160 of file OTStashItem.cpp.

161  : m_strAssetTypeID(theAssetTypeID)
162  , m_lAmount(lAmount)
163 {
164 }
opentxs::OTStashItem::~OTStashItem ( )
virtual

Definition at line 166 of file OTStashItem.cpp.

167 {
168 }

Member Function Documentation

bool opentxs::OTStashItem::CreditStash ( const int64_t &  lAmount)

Definition at line 191 of file OTStashItem.cpp.

192 {
193  if (lAmount < 0) {
194  otOut << "OTStashItem::CreditStash: Failed attempt to credit a "
195  "negative amount (" << lAmount
196  << "). Asset Type: " << m_strAssetTypeID << " \n";
197  return false;
198  }
199 
200  m_lAmount += lAmount;
201 
202  return true;
203 }
OTLOG_IMPORT OTLogStream otOut
bool opentxs::OTStashItem::DebitStash ( const int64_t &  lAmount)

Definition at line 205 of file OTStashItem.cpp.

206 {
207  if (lAmount < 0) {
208  otOut << "OTStashItem::DebitStash: Failed attempt to debit a negative "
209  "amount (" << lAmount << "). Asset Type: " << m_strAssetTypeID
210  << " \n";
211  return false;
212  }
213 
214  const int64_t lTentativeNewBalance = (m_lAmount - lAmount);
215 
216  if (lTentativeNewBalance < 0) {
217  otOut << "OTStashItem::DebitStash: Failed attempt to debit (amount of) "
218  << lAmount << ": New stash balance would have been a negative "
219  "amount (" << lTentativeNewBalance
220  << "). Asset Type: " << m_strAssetTypeID << " \n";
221  return false;
222  }
223 
224  m_lAmount = lTentativeNewBalance;
225 
226  return true;
227 }
OTLOG_IMPORT OTLogStream otOut
int64_t opentxs::OTStashItem::GetAmount ( ) const
inline

Definition at line 147 of file OTStashItem.hpp.

148  {
149  return m_lAmount;
150  }
const OTString& opentxs::OTStashItem::GetAssetTypeID ( )
inline

Definition at line 157 of file OTStashItem.hpp.

158  {
159  return m_strAssetTypeID;
160  }
void opentxs::OTStashItem::SetAmount ( int64_t  lAmount)
inline

Definition at line 151 of file OTStashItem.hpp.

152  {
153  m_lAmount = lAmount;
154  }

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