Getting Started:
Demonstrate how to build an Application with Tasks

ATest.h, ATest.cpp, Executive.h, Executive.cpp
Task1.h, Task1.cpp, Task2.h, Task2.cpp, Task3.h, Task3.cpp
GS.txt


/////////////////////////////////////////////////////////////////////
// Executive.cpp - directs execution of all program tasks
//

#include "Executive.h"
#include <iostream>

/*----< implicitly calls constructors for composed members >-------*/

Executive::Executive()
{
  std::cout << "\n  Executive starting up";
}
/*----< implicitly calls destructiors for composed members >-------*/

Executive::~Executive()
{
  std::cout << "\n  Executive shutting down";
}
/*----< directs execution of application >-------------------------*/

void Executive::doWork()
{
  std::cout << "\n  Executive doing a small amount of work";
  safeInvoke(t1, &Task1::doWork, __LINE__);
  safeInvoke(t2, &Task2::doWork, __LINE__);
  safeInvoke(t3, &Task3::doWork, __LINE__);

//////////////////////////////////////////////////////////
//  could use the calls, below, but that
//  won't trap exceptions that could be thrown
//  t1.doWork();
//  t2.doWork();
}
/*----< defines ATest's pure virtual test method >-----------------*/

bool Executive::test()
{
  return t1.testPackage() && t2.testPackage();
}
/*----< private test application test class focused on test >------*/
/*
 *  often test class will do some test specific initialization
*/
class TestExecutive : public ATest
{
public:
  TestExecutive()
  {
    std::cout << "\n  Testing Executive";
    std::cout << "\n ===================";
  }
  /*----< invokes executive testPackage >--------------------------*/
  /*
   *  - Executive::testPackage() invokes the testPackage function
   *    for each composed member, e.g., Task1 and Task2.
   *  - This causes a chaining of tests for the entire application.
  */
  bool test()
  {
    Executive ex;
    return ex.testPackage();
  }
};
/////////////////////////////////////////////////////////////////////
// Cosmetic struct simply ensures that program output text
// ends with two newlines

struct Cosmetic
{
  ~Cosmetic() { std::cout << "\n\n"; }
};

/*----< application entry point >----------------------------------*/

int main(int argc, char* argv[])
{
  Cosmetic cos;  // first object constructed is last to be destroyed

  std::cout << "\n  Demonstrating Executive";
  std::cout << "\n =========================";
  Executive ex;
  ex.doWork();
  std::cout << "\n";

  TestExecutive te;
  if (te.test())
    std::cout << "\n--Executive and its minions passed their tests";
  else
    std::cout << "\n--Executive or at least one of its minions failed their tests";
}