/*
 * $Id$
 *
 * Created: 20.2.2007
 * Author: jedi
 *
 * This example merely scratches the surface of demonstrating the
 * many features of Loki's smart pointer implementation.
 */


#include <iostream>
#include <loki/SmartPtr.h>


using namespace std;
using namespace Loki;


class Hoth
{
   public:
      Hoth() : name_("noname") {}
      Hoth(const std::string& name) : name_(name) {}
      ~Hoth() { cout << name_ << " destroyed" << endl; }
      Hoth* Clone() {return new Hoth(name_ + " (copy)");}

   private:
      string name_;
};


typedef SmartPtr <Hoth> HothPtr;
typedef SmartPtr <Hoth, DeepCopy> HothPtrDC;

typedef SmartPtr <
   Hoth, RefCounted, DisallowConversion, AssertCheck, ArrayStorage
   > HothArrayPtr;


//////////////////////////////////////////////////
//
// program output:
//
// deep copy (copy) destroyed
// deep copy destroyed
// noname destroyed
// noname destroyed
// dynamic destroyed
//
int main()
{
   HothPtr h1 = new Hoth("dynamic");
   HothArrayPtr h2 = new Hoth[2];
   HothPtrDC h3 = new Hoth("deep copy");
   HothPtrDC h4 = h3; // creates a new Hoth

   return 0;
}