#ifndef __CC_CAST__
#define __CC_CAST__

#include <RKObject.h>

template <class T>
T* ccptr_cast(RKObject* obj) {
  if (obj &&
      obj->IsClass<T>())
  {
    return static_cast<T*>(obj);
  }
  return static_cast<T*>(nullptr);
}

template <class T>
const T* ccptr_cast(const RKObject* obj) {
  if (obj &&
      obj->IsClass<T>())
  {
    return static_cast<const T*>(obj);
  }
  return static_cast<const T*>(nullptr);
}

#define CCPTR_CAST(ClassDef, obj) ccptr_cast<ClassDef>(obj)

#endif
