blob: 9ffab55341b2380d29742422bc2bb82e103fd79e [file]
/* $Id$
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to you under the Apache License, Version
* 2.0 (the "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*
* etch_valufact.c
* value factory
*/
#include <stdio.h>
#include "etch_valufact.h"
#include "etch_tagdata_out.h"
#include "etch_global.h"
/**
* value factory virtual function default implementations
*/
etch_type* vf_add_type (void* vf, etch_type* t)
{
return NULL;
}
etch_type* vf_get_type_by_id (void* vf, const unsigned id)
{
return NULL;
}
etch_type* vf_get_type_by_name (void* vf, const wchar_t* name)
{
return NULL;
}
etch_arraylist* vf_get_types (void* vf)
{
return NULL;
}
wchar_t* vf_get_string_encoding (void* vf)
{
return NULL;
}
etch_int64* vf_get_message_id (void* vf, etch_message* msgobj)
{
return NULL;
}
int vf_set_message_id (void* vf, etch_message* msgobj, etch_int64* msgid)
{
return 0;
}
etch_int64* vf_get_in_reply_to (void* vf, etch_message* msgobj)
{
return NULL;
}
int vf_set_in_reply_to (void* vf, etch_message* msgobj, etch_int64* msgid)
{
return 0;
}
etch_structvalue* vf_export_custom_value (void* vf, objmask* value)
{
return NULL;
}
objmask* vf_import_custom_value (void* vf, etch_structvalue* svobj)
{
return NULL;
}
etch_type* vf_get_custom_struct_type (void* vf, const unsigned etchclass)
{
return NULL;
}
etch_type* vf_get_mt_exception (void* vf)
{
return NULL;
}
/**
* new_value_factory()
* value factory constructor
*/
etch_value_factory* new_value_factory(const int objlen)
{
etch_value_factory* vf = NULL;
i_value_factory* vtab = NULL;
const unsigned short CLASS_ID = CLASSID_VALUEFACTORY;
int result = 0, objsize = objlen? objlen: sizeof(etch_value_factory);
vf = (etch_value_factory*) new_object
(objsize, ETCHTYPEB_VALUEFACTORY, CLASSID_VALUEFACTORY);
vf->destroy = destroy_valuefactory;
vf->clone = clone_null;
vtab = cache_find(get_vtable_cachehkey(CLASS_ID), 0);
if(!vtab)
{
vtab = new_vtable(NULL, sizeof(i_value_factory), CLASS_ID);
/* default virtual function implementations */
vtab->add_type = vf_add_type;
vtab->export_custom_value = vf_export_custom_value;
vtab->get_in_reply_to = vf_get_in_reply_to;
vtab->get_message_id = vf_get_message_id;
vtab->get_string_encoding = vf_get_string_encoding;
vtab->get_type_by_id = vf_get_type_by_id;
vtab->get_type_by_name = vf_get_type_by_name;
vtab->get_types = vf_get_types;
vtab->import_custom_value = vf_import_custom_value;
vtab->set_in_reply_to = vf_set_in_reply_to;
vtab->set_message_id = vf_set_message_id;
vtab->get_custom_struct_type= vf_get_custom_struct_type;
vtab->get_mt_exception = vf_get_mt_exception;
cache_insert(vtab->hashkey, vtab, FALSE);
}
vf->vtab = vtab;
return vf;
}
int destroy_valuefactory(etch_value_factory* vf)
{
if (vf->refcount > 0 && --vf->refcount > 0) return -1;
if (!is_etchobj_static_content(vf))
if (vf->impl)
vf->impl->destroy(vf->impl);
return destroy_objectex((objmask*)vf);
}