fatalmind::oracle::OptimizedBatchCommand< CommandType > Class Template Reference

#include <OptimizedBatchCommand.hh>

Inherits fatalmind::BatchCommand< CommandType >< CommandType >.

List of all members.


Detailed Description

template<class CommandType>
class fatalmind::oracle::OptimizedBatchCommand< CommandType >

The class is a collection of Commands to be executed in sequential order.

Execution of commands stopps in case an exception is thrown. BatchCommand's can also be nested.

Public Types

typedef CommandType innercommand_t
typedef
list_t::const_iterator 
const_iterator

Public Member Functions

 OptimizedBatchCommand (const OptimizedBatchCommand &rho)
 OptimizedBatchCommand (bool a_cont=false)
 OptimizedBatchCommand (const ResourcePool< typename CommandType::pool_type > &p, bool a_cont=false)
virtual void add (const CommandType &)
 Adds a command to the batch.
virtual void add (const optimizeablecommand_t &)
virtual void execute (typename CommandType::pool_type::resource_t &)
virtual void outputoperator (std::ostream &) const
int getError ()
 Returns the number of the command which failed during execution.
const_iterator getExecPosition () const
 returns the current execution position.
bool doesContinue () const
 A Predicate if the continuation mode is enabled in this command.
const_iterator end () const
 Returns an iterator beyond the last command in the batch.
const_iterator begin () const
 Returns an interator to the first command in the batch.
bool empty () const
 
Return values:
true if the batch is empty.


Static Public Attributes

static const int NOT_STARTED = -1
static const int NO_FURTHER_ERROR = -2

Protected Types

typedef BatchCommand
< CommandType > 
super
typedef SQLExecute
< typename
CommandType::pool_type::ThreadingModell,
oracle::SelectListMetaDataCache > 
optimizeablecommand_t
typedef gc_ptr
< CommandType > 
member_t
typedef std::vector
< member_t
list_t
typedef std::vector
< int > 
errors_t

Protected Member Functions

virtual Clone * DoClone () const
member_t getLast () const
bool wasStarted () const

Protected Attributes

const_iterator exec_pos
errors_t errors
unsigned int error_pos


Member Function Documentation

template<class CommandType>
void fatalmind::oracle::OptimizedBatchCommand< CommandType >::add ( const CommandType &  cmd  )  [inline, virtual]

Adds a command to the batch.

The command will be added to the end of the batch like push_back for vectros.

Please note that adding commands to an Batch is not allowed after the batch was executed(), not even if the execution aborted due to an exception.

Reimplemented from fatalmind::BatchCommand< CommandType >.

template<class CommandType>
int fatalmind::BatchCommand< CommandType >::getError (  )  [inline, inherited]

Returns the number of the command which failed during execution.

Can be used together with BatchCommand::begin() to obtain the command which failed:

 int error = batchcommand.getError();
 if (error >= 0) {
    Command& failed = *(batchcommand.begin() + error);
 }

In continuation mode (see BatchCommand::BatchCommand()) getError() will return all errors, one for every call. To fetch all errors use a structure like this:

 while (b.getExecPosition() != b.end()) {
   try {
     p.execute(b);
   } catch (...) {
     // each unsuccessful execution will deliver one error
     p::Command::Base& failed = *(b.begin() + b.getError());
   }
 }

The getError() method returns only the errors which already happend. After unsuccessful execution of a batch, it is guaranteed that getError() one error, after the next unsuccessful execution the next will be available.

You could also execute the batch first (until no error) and then fetch all failed commands.

Return values:
>=0 Index of a failed command
<0 non-error conditions. Listed below
BatchCommand::NOT_STARTED in case the execution was not yet started
BatchCommand::NO_FURTHER_ERROR in case no further errors are available (yet)

template<class CommandType>
BatchCommand< CommandType >::const_iterator fatalmind::BatchCommand< CommandType >::getExecPosition (  )  const [inline, inherited]

returns the current execution position.

required to determine if the batch has been executed completley. if equals end() the batch was fully executed.

template<class CommandType>
bool fatalmind::BatchCommand< CommandType >::doesContinue (  )  const [inline, inherited]

A Predicate if the continuation mode is enabled in this command.

Return values:
true If the continuation mode is enabled
false otherwise

template<class CommandType>
BatchCommand< CommandType >::const_iterator fatalmind::BatchCommand< CommandType >::begin (  )  const [inline, inherited]

Returns an interator to the first command in the batch.

will equals to end() if the batch is empty.

template<class CommandType>
bool fatalmind::BatchCommand< CommandType >::empty (  )  const [inline, inherited]

Return values:
true if the batch is empty.

Return values:
else if there is at lease one command in the batch.


The documentation for this class was generated from the following files:
Generated on Mon Nov 9 16:21:24 2009 for ResourcePool by  doxygen 1.5.3