#include "tmvaluetype.h" #include "tmtrace.h" #include "tmmem.h" #include "tmlist.h" #include "tmtopicset.h" #include "tmassert.h" #include "tmbasictypes.h" static int topicset_equal(TMValueType, const void *, const void*); static void topicset_free(TMValueType vtype, void *s); static void* topicset_new(TMValueType vtype); static void* topicset_new_from_string(TMValueType vtype,const char *s); static int topicset_to_string(TMValueType, const void *topicset, char* buf, size_t size); static int topicset_to_xml(TMValueType, const void *topicset, char* buf, size_t size); static void* topicset_add_member(TMValueType, void *topicset,va_list args); /* static void* topicset_get_player(TMValueType, void *topicset,va_list args); static void* topicset_set_type(TMValueType, void *topicset,va_list args); */ static void* topicset_replace_topics(TMValueType, void *topicset,va_list args); static void *topicset_parse_argstring(TMValueType vtype, int opcode, const char *argstring); static struct function_table ftab[] = { { "addMember" , topicset_add_member }, { "replaceTopics" , topicset_replace_topics }, { NULL , NULL} }; static struct op_table ops[] = { /* { "HAS_TYPE" , TM_OP_ASIDP_HAS_TYPE }, { "HAS_PLAYER_PAIR" , TM_OP_ASIDP_HAS_PLAYER_PAIR }, */ { "VALUE_INCLUDES_TOPIC" , TM_OP_TOPICSET_VALUE_INCLUDES_TOPICS }, { NULL, 0 } }; struct TMValueType TopicSet = { "TopicSet", 1, /* values contain topics */ topicset_new, topicset_new_from_string, topicset_to_string, topicset_to_xml, topicset_equal, topicset_free, ftab, ops, topicset_parse_argstring }; void* topicset_new(TMValueType vtype) { TMTopicSet self; self = tm_topicset_new(5); return self; } void* topicset_new_from_string(TMValueType vtype, const char *s) { assert(0); /* struct topicset_value *p; TM_NEW(p); p->type = 0; p->memberships = NULL; return p; */ return NULL; } void topicset_free(TMValueType vtype, void *v) { TMTopicSet self; self = (TMTopicSet)(TMTopicSet*)v; tm_topicset_delete(&self); } int topicset_to_string(TMValueType vtype, const void *v, char* buf, size_t size) { TMTopicSet self; char locbuf[1024]; int n,i; locbuf[0] = '\0'; self = (TMTopicSet)v; n = tm_topicset_size(self); for(i=0;i%s",locbuf); assert(n < size); return n; } int topicset_equal(TMValueType vtype, const void *lhs, const void *rhs) { assert(lhs); assert(rhs); return ( tm_topicset_equal((TMTopicSet)lhs,(TMTopicSet)rhs) ); } void *topicset_add_member(TMValueType vtype, void *v,va_list args) { TMTopicSet self; TMTopic topic; self = (TMTopicSet)v; topic = va_arg(args,TMTopic); tm_topicset_add(self,topic); return NULL; } void *topicset_replace_topics(TMValueType vtype, void *v,va_list args) { TMTopicSet self; int i,len; TMTopicSet merge_set; TMTopic stays; int changed = 0; self = (TMTopicSet)v; merge_set = va_arg(args,TMTopicSet); len = tm_topicset_size(merge_set); stays = tm_topicset_get(merge_set,0); /* start at 1 because we skip stays */ for(i=1;irole),(int*)&(mp->player)); return (mp); break; } default: assert(0); } #endif return NULL; }