StreamSpec.c

Go to the documentation of this file.
00001 #include <stdio.h>
00002 #include <stdlib.h>
00003 #include <string.h>
00004 #include <dlfcn.h>
00005 #include "StreamSpec.h"
00006 #include "FilterData/Policies.h"
00007 
00008 // tag 0 is for internal Void messages
00009 // tag 1 is for PvmTaskExit notifications
00010 // tag 2 is for PvmHostDelete notifications
00011 // tag 3 is for filter termination
00012 static int nextTag = 4;
00013 
00014 /* Constructor and destroyer *****************************************************/
00015 /// Constructor 
00016 StreamSpec *createEmptyStreamSpec() {
00017         StreamSpec *s = (StreamSpec *) malloc(sizeof(StreamSpec));
00018         s->tag = nextTag++;
00019         return s;
00020 }
00021 /// Destroyer
00022 void destroyStreamSpec(StreamSpec *s){
00023         //we dont need to free stuff, as they are allocated statically
00024         free(s);
00025 }
00026 /********************************************************************************/
00027 
00028 /* Setting source and destinations **********************************************/
00029 /// Set stream origin, ie, the filter which writes to this stream
00030 int setFrom(StreamSpec *s, FilterSpec *filter, char *portName, char *writePolicyName, char *polibName
00031 #ifdef VOID_TERM
00032                 , int breakLoop
00033 #endif          
00034 ){
00035         writePolicy_t p;
00036         
00037         s->fromFilter  = filter;
00038         strncpy(s->fromPortName, portName, MAX_PTNAME_LENGTH); 
00039         strncpy(s->writePolicyName, writePolicyName, MAX_PLNAME_LENGTH);
00040         s->fromFilter->outputs[s->fromFilter->numOutputs++] = s;
00041         
00042         //if we are using labeled stream, we need the library name of the functions
00043         p = getWritePolicyByName(writePolicyName);
00044         if ((p == LABELED_STREAM) || (p == MULTICAST_LABELED_STREAM)){
00045                 //if we are labeled, we need a policy library name
00046                 if ((polibName == NULL) || (strlen(polibName) == 0))
00047                         return 0;
00048                 else
00049                         strncpy(s->lsLibName, polibName, MAX_PLNAME_LENGTH);
00050         }
00051         else if (p == W_POLICY_ERROR){
00052                 return 0;
00053         }
00054 #ifdef VOID_TERM
00055         s->breakLoop = breakLoop;
00056 #endif
00057         return 1;
00058 }
00059 ///set stream destination, ie, the filter which reads from this stream
00060 int setTo(StreamSpec *s, FilterSpec *filter, char *portName, char *readPolicyName){
00061         //we are not using read policies...
00062         
00063         s->toFilter    = filter;
00064         s->toFilter->inputs[s->toFilter->numInputs++] = s;
00065         strncpy(s->toPortName, portName, MAX_PTNAME_LENGTH);
00066         return 1;
00067 }
00068 /*******************************************************************************/

Generated on Tue Jan 17 19:18:39 2006 for Void by  doxygen 1.4.6