/*
 * (c) 2005 Research Group Dr. Fuhrmann, University of Karlsruhe, Germany
 * All rights reserved.
 *
 * Author:
 *         Kendy Kutzner <kutzner@ira.uka.de>
 *
 * $Id: vtmsg.h,v 1.5 2005/12/27 12:12:33 kutzner Exp $
 *
 */

#ifndef _VTMSG_H_
#define _VTMSG_H_


// vidtrans

#include "igorinterface.h"
#include "aggr_dest.h"
#include "videosource.h"
#include <libigor.h>

/** Message exchanged between plugins over the igor.
 * Representation of one message between two plugins.
 * The messages are exchanged over the igor.
 * It is used to transport video sources.
 * \bug More of the members should become private and get their own accessor methods.
 */
class vtmsg {
	private:
	public:
		/** What this message is about.
		 * What this message is about. This is neccessary for upstream
		 * (aggr-tree wise) plugins. With this piece of information
		 * they can put video sources from this message into their data
		 * stores.
		 */
		aggr_dest dest;
		/** Same information as dest, but in their hashed/hashable form.
		 * Same as dest, but either
		 *  - in string form prepended by VT_APPTYPE
		 *  - the above string hashed.
		 */
		sa_igor hdst;
		/** Source of the message.
		 * Originating node of the message. This is used when we answer
		 * an incoming REQ (and then copied to hdst).
		 */
		sa_igor src;
		/** Type of message.
		 * REQ messages are always sent upstreams to request
		 * information. Which information are requestes is said in the
		 * dest member. DATA messages can be sent upstream to publish
		 * information. DATA messages can also be sent downstream as an
		 * answer to REQ messages.
		 */
		enum { DATA, REQ } type;
		/** List of video sources.
		 * The list of video sources we are talking about.
		 * For REQ messages this list is likely to be empty.
		 */
		sourcelist_t sources;
		/** Same as the igor upcall parameter.
		 * Whether intermediate nodes during transport by the igor
		 * should see this message. It should be true for REQ
		 * messages, so the first node with the appropriate knowledge
		 * can answer. It should be true for upstream DATA messages,
		 * so other nodes can aggregate the information and the root of
		 * the aggregation tree doesn't become overloaded. It should
		 * be false for downstream DATA messages, because nodes
		 * transporting such a message are likely not interested in the
		 * content.
		 */
		bool upcall;
		/** Transform a message to a string.
		 * Transform the message to a network transportable string.
		 */
		string tostring();
		/// Transform something we got from the network into a message.
		bool fromstring(const char *buf , int len);
};

	

#endif // _VTMSG_H_
