/////////////////////////////////////////////////////////////
// CINEMA 4D SDK                                           //
/////////////////////////////////////////////////////////////
// (c) 1989-2009 MAXON Computer GmbH, all rights reserved  //
/////////////////////////////////////////////////////////////
#include "lib_batchrender.h"

BatchRenderLibrary* batchrender_lib_cache = NULL;

static BatchRenderLibrary* CheckBatchRenderLib(LONG offset)
{
	return (BatchRenderLibrary*)CheckLib(C4D_BATCHRENDER_LIBRARY_ID, offset, (C4DLibrary**)&batchrender_lib_cache);
}

BatchRender* GetBatchRender()
{
	BatchRenderLibrary *lib = CheckBatchRenderLib(LIBOFFSET(BatchRenderLibrary, GetBatchRender));
	if (!lib || !lib->GetBatchRender) return NULL;
	return (BatchRender*)lib->GetBatchRender();
}

Bool BatchRender::Open()
{
	BatchRenderLibrary *lib = CheckBatchRenderLib(LIBOFFSET(BatchRenderLibrary, Open));
	if (!lib || !lib->Open) return FALSE;
	return (((iBatchRender*)this)->*(lib->Open))(); 
}

Bool BatchRender::AddFile(const Filename &File, LONG number)
{
	BatchRenderLibrary *lib = CheckBatchRenderLib(LIBOFFSET(BatchRenderLibrary, AddFile));
	if (!lib || !lib->AddFile) return FALSE;
	return (((iBatchRender*)this)->*(lib->AddFile))(File,number);  
}

Bool BatchRender::DelFile(const Filename &File)
{
	BatchRenderLibrary *lib = CheckBatchRenderLib(LIBOFFSET(BatchRenderLibrary, DelFile));
	if (!lib || !lib->DelFile) return FALSE;
	return (((iBatchRender*)this)->*(lib->DelFile))(File);  
}

LONG BatchRender::GetElementCount()
{
	BatchRenderLibrary *lib = CheckBatchRenderLib(LIBOFFSET(BatchRenderLibrary, GetElementCount));
	if (!lib || !lib->GetElementCount) return NOTOK;
	return (((iBatchRender*)this)->*(lib->GetElementCount))();  
}

Filename BatchRender::GetElement(LONG n)
{
	BatchRenderLibrary *lib = CheckBatchRenderLib(LIBOFFSET(BatchRenderLibrary, GetElement));
	if (!lib || !lib->GetElement) return Filename();
	return (((iBatchRender*)this)->*(lib->GetElement))(n);  
}

void BatchRender::EnableElement(LONG n, Bool bSet)
{
	BatchRenderLibrary *lib = CheckBatchRenderLib(LIBOFFSET(BatchRenderLibrary, EnableElement));
	if (!lib || !lib->EnableElement) return;
	return (((iBatchRender*)this)->*(lib->EnableElement))(n,bSet);  
}

Bool BatchRender::GetEnableElement(LONG n)
{
	BatchRenderLibrary *lib = CheckBatchRenderLib(LIBOFFSET(BatchRenderLibrary, GetEnableElement));
	if (!lib || !lib->GetEnableElement) return FALSE;
	return (((iBatchRender*)this)->*(lib->GetEnableElement))(n);  
}

LONG BatchRender::GetElementStatus(LONG n)
{
	BatchRenderLibrary *lib = CheckBatchRenderLib(LIBOFFSET(BatchRenderLibrary, GetElementStatus));
	if (!lib || !lib->GetElementStatus) return NOTOK;
	return (((iBatchRender*)this)->*(lib->GetElementStatus))(n);  
}

Bool BatchRender::IsRendering()
{
	BatchRenderLibrary *lib = CheckBatchRenderLib(LIBOFFSET(BatchRenderLibrary, IsRendering));
	if (!lib || !lib->IsRendering) return FALSE;
	return (((iBatchRender*)this)->*(lib->IsRendering))();  
}

void BatchRender::SetRendering(LONG set)
{
	BatchRenderLibrary *lib = CheckBatchRenderLib(LIBOFFSET(BatchRenderLibrary, SetRendering));
	if (!lib || !lib->SetRendering) return;
	return (((iBatchRender*)this)->*(lib->SetRendering))(set);  
}
