FilterDev.h

Go to the documentation of this file.
00001 #ifndef FILTER_H
00002 #define FILTER_H
00003 
00004 
00005 #include "constants.h"
00006 
00007 #define VOID_3
00008 
00009 // Coutinho: If a c++ filter use this file, tell it that these functions are in C
00010 #ifdef __cplusplus
00011 extern "C" {
00012 #endif
00013 
00014 #define EOW -2 ///< the end of work message code
00015 #define ERROR -3 ///< Reader functions should return this on a internal error
00016 
00017 typedef int RecoverCallback_t( int taskId, int *deps, int depSize, char *metadata, int metaSize );
00018 
00019 #ifndef _PORT_HANDLERS_
00020 #define _PORT_HANDLERS_
00021 typedef int InputPortHandler, OutputPortHandler;
00022 #endif
00023 
00024 /*! \file FilterDev.h These functions all use the FilterData *fd global variable, 
00025  * which represents the filter on the client side. These functions are all available
00026  * to the filter developer.
00027  *
00028  * Global variable fd is declared on FilterData.h
00029  */
00030 
00031 //the filter library functions datatypes
00032 typedef int initialize_t(void *work, int worksize);
00033 typedef int process_t(void *work, int worksize);
00034 typedef int finalize_t();
00035 
00036 initialize_t initFilter;
00037 process_t processFilter;
00038 finalize_t finalizeFilter;
00039 
00040 /// get the handlers of ports
00041 InputPortHandler dsGetInputPortByName(const char *name);
00042 OutputPortHandler dsGetOutputPortByName(const char *name);
00043 int dsCloseOutputPort(OutputPortHandler oph); //< close an output port, sending EOW to receivers
00044 
00045 /// funtion to probe an input port for data, returns the size of the buffer, 0 otherwise
00046 int dsProbe(InputPortHandler ip);
00047 /// function that reads from other filter(receive and unpack)
00048 int dsReadBuffer(InputPortHandler ip, void *buf, int szBuf);
00049 /// returns 0 if there is no data to be received
00050 int dsReadNonBlockingBuffer(InputPortHandler iph, void *buf, int szBuf);
00051 /// function that writes to other filter(pack and send)
00052 int dsWriteBuffer(OutputPortHandler op, void *buf, unsigned int bufSz);
00053 
00054 /** these functions return the number of instances on the other side of the strem
00055   * say, we have a filter A->B. B knows it will receive one message only from each A. He can use this number
00056   * to leave a loop like while (numMessages != dsGetNumWriters(iph))
00057   */
00058 int dsGetNumWriters(InputPortHandler iph);
00059 int dsGetNumReaders(OutputPortHandler oph);
00060 
00061 /// function to start packing data, size in bytes
00062 int dsInitPack(int initSize);
00063 
00064 /// function to pack data to the buffer
00065 int dsPackData(void *data, int size);
00066 /// function to send the packed buffer
00067 int dsWritePackedBuffer(OutputPortHandler oph);
00068 
00069 /// function to receive a buffer, and unpack later
00070 int dsInitReceive(InputPortHandler iph);
00071 /// function to unpack data
00072 int dsUnpackData(void *buf, int size);
00073 
00074 /// get filter name
00075 char *dsGetFilterName();
00076 /// get filter id
00077 int dsGetFilterId();
00078 
00079 /// function to get the number of one filter input ports
00080 int dsGetNumInputPorts();
00081 /// function to get all input ports names of one filter
00082 char **dsGetInputPortNames();
00083 /// function to get the number of one filter output ports
00084 int dsGetNumOutputPorts();
00085 /// function to get all output ports names of one filter
00086 char **dsGetOutputPortNames();
00087 
00088 /// get the number of writers to me that are still running
00089 int dsGetNumUpStreamsRunning();
00090 
00091 /// get the ammount of memory this machine has for this execution
00092 int dsGetMachineMemory();
00093 /// the number of brothers I have in this machine + 1
00094 /// brothers are the same filters as me, so say, you have a filter A
00095 /// running here, and 2 Bs runnning here, if A calls this hell get 1,
00096 /// and B will get 2.
00097 int dsGetLocalInstances();
00098 
00099 /// Function that returns which brother am I
00100 int dsGetMyRank();
00101 /// returns the total intances of this filter(me + mybrothers)
00102 int dsGetTotalInstances();
00103 /// kill all filters and finish void, user calls this to exit the system abnormally
00104 int dsExit(char *mesg);
00105 
00106 /** Task functions */
00107 void dsUseTasks();
00108 /// creates a new task
00109 int dsCreateTask(int taskId, int *deps, int depSize, char *metadata, int metaSize);
00110 /// ends a task
00111 int dsEndTask(int taskId);
00112 ///get the current task we are working on
00113 int dsGetCurrentTask();
00114 int dsSetCurrentTask(int taskId);
00115 int *dsGetTaskDeps(int taskId, int *depsSz);
00116 int dsGetRunningTasks( int * numTasks, int ** taskList );
00117 int *dsGetFinishedTasks(int *numTasks);
00118 
00119 int dsRegisterRecoverCallback( RecoverCallback_t * callback );
00120 
00121 // data functions
00122 int dsPutData(char *id, void *val, int valSize);
00123 int dsRemoveData(char *id);
00124 void *dsGetData(int taskId, char *id, int *valSz);
00125 
00126 // instrumentation stuff
00127 void dsInstSetStates(char **states, int numStates);
00128 void dsInstSwitchState(int stateId);
00129 void dsInstEnterState(int stateId);
00130 void dsInstLeaveState();
00131 
00132 #ifdef __cplusplus
00133 }
00134 #endif
00135 
00136 #endif

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