v_actionResult cmx_readerReadCopy( c_object o, c_voidp args) { sd_serializer ser; sd_serializedData data; v_dataReaderSample sample, newer; struct cmx_readerArg *arg; v_actionResult result; result = 0; if(o != NULL){ sample = v_dataReaderSample(o); if(v_stateTest(v_readerSampleState(sample), L_READ)){ v_actionResultSet(result, V_PROCEED); } else { sample = v_dataReaderSample(o); newer = sample->newer; sample->newer = NULL; arg = (struct cmx_readerArg *)args; ser = sd_serializerXMLNewTyped(c_getType(o)); data = sd_serializerSerialize(ser, o); arg->result = sd_serializerToString(ser, data); sd_serializedDataFree(data); sd_serializerFree(ser); sample->newer = newer; } } return result; }
v_actionResult nb_topicObjectReaderAction( c_object o, c_voidp copyArg, /* c_iter<nb_topicObject> * */ nb_topicObjectAllocFunc allocFunc) { nb_topicObject to; v_actionResult result = 0; assert(allocFunc); if(o != NULL){ c_iter *iter; v_dataReaderSample s = v_dataReaderSample(o); v_message message = v_dataReaderSampleMessage(s); const void * from = C_DISPLACE (message, C_MAXALIGNSIZE(sizeof(*message))); iter = (c_iter*)copyArg; assert(iter); v_actionResultSet(result, V_PROCEED); to = allocFunc(); to->state = v_nodeState(message); to->writeTime = message->writeTime; nb_topicObjectCopyOut(to, from); *iter = c_iterAppend(*iter, to); } return result; }
static v_actionResult readerActionView ( c_object o, c_voidp copyArg) { readerViewActionArg *info = (readerViewActionArg *) copyArg; v_readerSampleSeq *samples = info->samples; v_readerSample sample; v_actionResult result = V_PROCEED; gapi_unsigned_long i; if ( o ) { sample = v_readerSample(o); if (gapi_matchesReaderMask(o, &info->datareaderview->reader_mask)) { if ( !sampleSeqContains(samples, sample) ) { i = samples->_length; if ( v_readerSampleSeq_setLength(samples, i+1) ) { samples->_buffer[i] = c_keep(sample); c_keep(sample->instance); } else { info->result = GAPI_RETCODE_OUT_OF_RESOURCES; v_actionResultClear(result, V_PROCEED); } if ( samples->_length >= info->max ) { v_actionResultClear(result, V_PROCEED); } } } else { v_actionResultSet(result, V_SKIP); } } else { if ( samples->_length > 0 ) { determineSampleInfoView(info); for ( i = 0UL; i < samples->_length; i++ ) { c_free(samples->_buffer[i]->instance); c_free(samples->_buffer[i]); } } else { info->readerCopy(NULL, info->readerInfo); info->result = GAPI_RETCODE_NO_DATA; } v_actionResultClear(result, V_PROCEED); } return result; }
v_actionResult v_dataViewSampleReadTake( v_dataViewSample sample, v_readerSampleAction action, c_voidp arg, c_bool consume) { v_dataViewInstance instance; v_state state; v_state mask; v_actionResult result = 0; instance = v_dataViewSampleInstance(sample); state = v_instanceState(instance); mask = L_NEW | L_DISPOSED | L_NOWRITERS; /* Copy the value of instance state bits specified by the mask * to the sample state bits without affecting other bits. */ v_readerSampleSetState(sample,(state & mask)); v_readerSampleClearState(sample,(~state & mask)); /* If the status of the sample is READ by the previous read * operation and the flag is not yet set (specified by the * LAZYREAD flag) then correct the state before executing the * read action. */ if (v_readerSampleTestState(sample,L_LAZYREAD)) { v_readerSampleSetState(sample,L_READ); v_readerSampleClearState(sample,L_LAZYREAD); } /* An action routine is provided in case the sample needs to be returned * to the user. If an action routine is not provided, it means the sample * needs to be removed from the administration, so the reader should be * modified accordingly. That means the 'proceed' flag should be set in * that case. */ V_MESSAGE_STAMP(v_dataReaderSampleMessage(sample),readerReadTime); if (action) { /* Invoke the action routine with the typed sample. */ result = action(v_readerSample(sample), arg); } else { v_actionResultSet(result, V_PROCEED); } /* A sample is considered 'skipped' if the action routine invoked above * does not want to keep track of the sample (for example because it * didn't match its readerMasks). In that case, it sets the 'skip' flag * to true, which indicates that those samples should be considered * 'untouched' and therefore their instance and sample states should * not be modified. */ if (v_actionResultTestNot(result, V_SKIP)) { V_MESSAGE_STAMP(v_dataReaderSampleMessage(sample),readerCopyTime); V_MESSAGE_REPORT(v_dataReaderSampleMessage(sample), v_dataReaderInstanceDataReader(instance)); v_stateClear(v_instanceState(instance),L_NEW); if (!v_stateTest(v_readerSample(sample)->sampleState,L_READ)) { v_stateSet(v_readerSample(sample)->sampleState,L_LAZYREAD); } if (consume) { v_dataViewSampleListRemove(v_dataViewSampleList(sample)); v_dataViewSampleRemove(sample); } } return result; }