/*------------------------------------------------------------------------------
 src/lib/dj/djType.h
 
 Copyright (c) 2004-2006 Darby Johnston.
 All rights reserved.
 Use is subject to license terms.
------------------------------------------------------------------------------*/

#ifndef DJ_TYPE_H
#define DJ_TYPE_H
#include <sys/types.h>
#include <inttypes.h>
#include <float.h>

namespace dj {

// Pair.
//
template <class A, class B>
class Pair {
public:

  Pair() {}
  Pair(const A & a, const B & b) :
    a(a), b(b)
  {}

  A a;
  B b;
};

template <class A, class B>
bool operator == (const Pair<A, B> &, const Pair<A, B> &);
template <class A, class B>
bool operator != (const Pair<A, B> &, const Pair<A, B> &);

// Reference count.
//
class Ref {
public:

  Ref() : _count(1) {}
  virtual ~Ref() = 0;

  void ref() { ++_count; }
  void refDel() { --_count; if (! _count) del(); }
  int count() const { return _count; }

protected:

  virtual void del() { delete this; }

private:

  int _count;
};

}

#include <djType_.h>
#endif
