/*
* Copyright 2004 iAnwhere Solutions, Inc. All rights reserved.
*
* objectsrc.c
*
*/
#include "pods.h"
#include "podsstartup.h"
#include "objectsrc.h"
// This is the function that it invoked when the
// object manager is searching for an object. If
// the name matches our SAMPLE_NAME, we return our
// object (creating it if necessary) and return it
// to the object manager.
static PODSObject
*ObjectSrcObjectForName(PODSObjectSrc
*podsObjSrc, PODSString name)
{
ObjectSrc *self = (ObjectSrc *)podsObjSrc;
if (0 == strcmp(name, SAMPLE_NAME)) {
if (!self->sampleObject)
self->sampleObject = SampleObjectNew();
return (PODSObject *)self->sampleObject;
}
return NULL;
}
static void ObjectSrcDestroy(PODSObjectSrc
*podsObjSrc)
{
ObjectSrc *self = (ObjectSrc *)podsObjSrc;
if (self->sampleObject)
PODSdestroy((PODSObject *)self->sampleObject);
free(self->vtable);
free(self);
}
// Create our object source and fill in vtable
// entries for objectForName and destroy
// ObjectSrc *ObjectSrcNew(PODSObjectMgr *objectMgr)
{
ObjectSrc *self = (ObjectSrc *)calloc(1, sizeof(ObjectSrc));
self->vtable = (PODSObjectSrcVTable *)calloc(1, sizeof(PODSObjectSrcVTable));
PODS_SET_METHOD(self->vtable, objectForName, ObjectSrcObjectForName);
PODS_SET_METHOD(self->vtable, destroy, ObjectSrcDestroy);
self->objectMgr = objectMgr;
return self;
}