Ports.h

Go to the documentation of this file.
00001 #ifndef _PORTS_H
00002 #define _PORTS_H
00003 
00004 #include "../constants.h"
00005 #include "Policies.h"
00006 #include "hashDefault.h"
00007 //TODO: nao esquecer que na hora de dar o set no nome da biliboteca
00008 //temos que passar a mesma no formato lib*.so
00009 
00010 #ifndef _PORT_HANDLERS_
00011 #define _PORT_HANDLERS_
00012 // output port handler
00013 typedef int OutputPortHandler; ///< index of the OutputPort int the FilterData, used for every operations the filter make to a stream. 
00014 typedef int InputPortHandler; ///< Index of InputPort in the FilterData
00015 #endif
00016 
00017 #define OP_STATE_OPEN 1
00018 #define OP_STATE_CLOSED 0
00019 
00020 /* Output port stuff *************************************************/
00021 /* Labeled stream data */
00022 typedef void (GetLabel)(void *msg, int tamMsg, char label[]); ///< getLabel prototype
00023 typedef int (Hash)(char *label, int image); ///< Hash function prototype
00024 typedef void (MLSHash)(char *label, int  image, int destArray[]); ///< Multicast LS hash function prototype
00025 
00026 typedef struct __LabeledStreamData {
00027         void *lsHandler; ///< handler for dynamic library that contains hash and getLabel
00028         char libname[MAX_LNAME_LENGTH+1];       ///< the library name with the functions
00029         Hash *hash; ///< pointer to the hash function, if used
00030         MLSHash *mlshash; ///< pointer to the mls hash, if used
00031         GetLabel *getLabel; ///< getLabel pointer
00032 } LabeledStreamData;
00033 
00034 
00035 //output port
00036 typedef struct {
00037         char *name; ///< OutputPort Name
00038         int numDestinations; ///< number of destinations connected to this port
00039         int *tidsDestinations; ///< the array of tids
00040         writePolicy_t writePolicy; ///< the write policy used by this port
00041         int tag;  ///< stream tag
00042         int nextToSend; ///< who is the next instance to get our msgs?
00043         LabeledStreamData lsData; ///< the labeled stream data
00044         int state; ///< the port state
00045 }OutputPort;
00046 
00047 ///constructor
00048 OutputPort *createOutputPort();
00049 
00050 ///destroyer: must release the libraries
00051 void destroyOutputPort(OutputPort *o);
00052 
00053 ///closes the door, must be called before finalizing if port is not closed
00054 void closeOutputPort(OutputPort *o);
00055 
00056 ///resets the output port, i.e open it
00057 void resetOutputPort(OutputPort *o);
00058 
00059 
00060 /// set stuff, user can free the second argument after that
00061 void setOPState(OutputPort *op, int state);
00062 void setOPName(OutputPort *op, const char *name);
00063 void setOPNumDestinations(OutputPort *op, int num);
00064 void setOPWritePolicy(OutputPort *op, writePolicy_t p);
00065 void setOPNextToSend(OutputPort *op, int next);
00066 void setOPLibName(OutputPort *op, const char *libname);
00067 void setOPTidsDestinations(OutputPort *op, const int *tids);
00068 void setOPTag(OutputPort *op, int tag);
00069 
00070 /// This function loads the libraries of the labeled stream, returns 1 on success 0 otherwise
00071 int loadOPLSData(OutputPort *op);
00072 int loadOPMLSData(OutputPort *op);
00073 /* End outputport stuff ***************************************************/
00074 
00075 
00076 /* Input port stuff *************************************************/
00077 
00078 typedef struct {
00079         char *name; ///< InputPort name
00080         int numSources; ///< we receive from this number of sources
00081         int *tidsSources;  ///< the array of tids we receive from
00082         int tag; //< the stream tag
00083         int numEowRecv; ///< the number of EOW received so far
00084 } InputPort;
00085 
00086 ///constructor
00087 InputPort *createInputPort();
00088 ///destroyer: must release the libraries
00089 void destroyInputPort(InputPort *o);
00090 
00091 ///reset an input port. Must be used before starting work
00092 void resetInputPort(InputPort *ip);
00093 
00094 // set stuff, user can free the second argument after that
00095 void setIPName(InputPort *ip, const char *name);
00096 void setIPNumSources(InputPort *ip, int num);
00097 void setIPTag(InputPort *ip, int tag);
00098 void setIPTidsSources(InputPort *ip, const int *tids);
00099 void setNumEowRecv(InputPort *ip, int numRecv);
00100 /*********************************************************************/
00101 
00102 #endif

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