#include "c4d_nodeplugin.h"
#include "c4d_memory.h"
#include "c4d_general.h"
#include "operatingsystem.h"

Bool NodeData::Init(GeListNode *node) 
{ 
	return TRUE; 
}

void NodeData::Free(GeListNode *node) 
{ 
}

Bool NodeData::CopyTo( NodeData *dest, GeListNode *snode, GeListNode *dnode, COPYFLAGS flags, AliasTrans *trn )
{ 
	return TRUE; 
}

Bool NodeData::Read(GeListNode *node, HyperFile *hf, LONG level) 
{ 
	return TRUE; 
}

Bool NodeData::Write(GeListNode *node, HyperFile *hf) 
{ 
	return TRUE; 
}

Bool NodeData::Message(GeListNode *node, LONG type, void *data) 
{ 
	return TRUE; 
}

void NodeData::GetBubbleHelp(GeListNode *node, String &str)
{
}

Bool NodeData::IsInstanceOf(const GeListNode *node, LONG type) const
{
	return FALSE;
}

BaseDocument* NodeData::GetDocument(GeListNode *node) 
{ 
	return NULL; 
}

LONG NodeData::GetBranchInfo(GeListNode *node, BranchInfo *info, LONG max, GETBRANCHINFO flags) 
{ 
	return 0; 
}

Bool NodeData::TranslateDescID(GeListNode *node, const DescID &id, DescID &res_id, C4DAtom *&res_at) 
{ 
	return FALSE; 
}

Bool NodeData::IsDocumentRelated(const GeListNode *node, Bool &docrelated) const
{
	return FALSE;
}

Bool NodeData::GetDDescription(GeListNode *node, Description *description,DESCFLAGS_DESC &flags)
{
	return FALSE;
}

Bool NodeData::GetDEnabling(GeListNode *node, const DescID &id,const GeData &t_data,DESCFLAGS_ENABLE flags,const BaseContainer *itemdesc)
{
	return TRUE;
}

Bool NodeData::GetDParameter(GeListNode *node, const DescID &id,GeData &t_data,DESCFLAGS_GET &flags)
{
	return TRUE;
}

Bool NodeData::SetDParameter(GeListNode *node, const DescID &id,const GeData &t_data,DESCFLAGS_SET &flags)
{
	return TRUE;
}

void FillNodePlugin(NODEPLUGIN *np, LONG info, DataAllocator *g, BaseBitmap *icon, LONG disklevel, void *emulation)
{
	np->Allocator				= g;
	np->Destructor			= &NodeData::Destructor;
	np->Init						= &NodeData::Init;
	np->Free						= &NodeData::Free;
	np->Read						= &NodeData::Read;
	np->Write						= &NodeData::Write;
	np->CopyTo					= &NodeData::CopyTo;
	np->Message					= &NodeData::Message;
	np->GetDocument			= &NodeData::GetDocument;
	np->GetBranchInfo		= &NodeData::GetBranchInfo;
	np->GetDDescription	= &NodeData::GetDDescription;
	np->GetDParameter		= &NodeData::GetDParameter;	
	np->SetDParameter		= &NodeData::SetDParameter;	
	np->GetDEnabling		= &NodeData::GetDEnabling;
	np->GetBubbleHelp   = &NodeData::GetBubbleHelp;
	np->IsInstanceOf		= &NodeData::IsInstanceOf;
	np->TranslateDescID = &NodeData::TranslateDescID;
	np->IsDocumentRelated	= &NodeData::IsDocumentRelated;

	np->disklevel		= disklevel;
	np->info				= info;
	np->icon				= icon;
	np->emulation		= emulation;
	np->fallback    = NULL;
}

Bool RegisterNodePlugin(LONG id, const String &str, LONG info, DataAllocator *g, BaseBitmap *icon, LONG disklevel, LONG *fallback)
{
	NODEPLUGIN np; 
	ClearMem(&np,sizeof(np));
	FillNodePlugin(&np,info,g,icon,disklevel);
	np.fallback=fallback;
	return GeRegisterPlugin(PLUGINTYPE_NODE,id,str,&np,sizeof(np));
}

#ifndef __API_INTERN__
#include "c4d_basebitmap.h"
#include "c4d_file.h"

AutoBitmap::AutoBitmap(const String &str)
{
	bmp=BaseBitmap::Alloc();
	if (!bmp) return;
	if (bmp->Init(GeGetPluginPath()+String("res")+str)!=IMAGERESULT_OK)
		BaseBitmap::Free(bmp);
}

AutoBitmap::AutoBitmap(LONG id)
{
	bmp = InitResourceBitmap(id);
}

AutoBitmap::~AutoBitmap()
{
	BaseBitmap::Free(bmp);
}
#endif