VR-Forces 4.0.4 Class Documentation
include/vrfExtObjects/radioMessageReceivedHandler.h
Go to the documentation of this file.
00001 /*******************************************************************************
00002 ** Copyright (c) 2012 MAK Technologies, Inc.
00003 ** All rights reserved.
00004 *******************************************************************************/
00005 
00009 
00010 #pragma once
00011 
00012 #include <vrfExtObjects/vrfExtObjectsDefines.h>
00013 #include <vrfExtProtocol/ifRadioMessageReceived.h>
00014 #include <vl/exerciseConn.h>
00015 #include <vl/dataInter.h>
00016 #include <vector>
00017 
00018 typedef void (*DtRadioMessageReceivedHandlerCallback) (DtIfRadioMessageReceived msg, void* usr);
00019 
00020 class DT_DLL_vrfExtObjects DtRadioMessageReceivedHandler
00021 {
00022 public:
00023    // Default constructor does not fully initialize itself. Must call initialize() to complete
00024    // the initialization process.
00025    DtRadioMessageReceivedHandler();
00026 
00027    // Default destructor does remove all callbacks upon destruction so there is no need to
00028    // explicitly remove a callback.
00029    virtual ~DtRadioMessageReceivedHandler();
00030 
00031    // Initializes the instance. Will do nothing if already initialized. Thus you can't
00032    // replace the exercise connection this is using. Auto-registers for this message type
00033    // once it is initialized. This message type being one of DtIfRadioMessageReceived.
00034    virtual void initialize(DtExerciseConn* exConn);
00035 
00036    // Adds a callback function to the list of callbacks. Your function and class are passed
00037    // in as the two arguments (respectively) and will get invoked when a message of this
00038    // specific type comes in on the network.
00039    virtual void addCallback(DtRadioMessageReceivedHandlerCallback cBackFunc, void* usr);
00040 
00041    // Removes a callback function from the list of callbacks. Your function and class 
00042    // that you passed in to add the callback can be used to remove it from the list.
00043    // An explicit removal is not required upon termination of the program as it will
00044    // clean itself up when this gets destroyed.
00045    virtual void removeCallback(DtRadioMessageReceivedHandlerCallback cBackFunc, void* usr);
00046 
00047    // Publishes a DtIfRadioMessageReceived message to the network. Since this class handles
00048    // receiving messages of this type, it also handles sending them. This makes it easy to
00049    // send and receive messages of this type.
00050    virtual bool publishRadioMessageReceivedMessage(DtIfRadioMessageReceived msg);
00051 
00052 protected:
00053    // Callback function registered to receive data interactions on the network
00054    static void dataInteractionCallbackFunction(DtDataInteraction* interaction, void* usr);
00055 
00056    // Where the data interaction is processed
00057    virtual void processDataInteraction(DtDataInteraction* interaction);
00058 
00059    // Where the callback functions registered to this class are called.
00060    virtual void invokeCallbacks(DtIfRadioMessageReceived msg);
00061 
00062    DtExerciseConn* myExerciseConnection;
00063    std::vector<std::pair<void*, DtRadioMessageReceivedHandlerCallback> > myCallbacks;
00064 };

Document ID: Generated on Fri Jun 29 16:33:32 EDT 2012 from SVN revision 116588
Copyright © 2005-2012 VT MÄK Inc. All Rights Reserved (www.mak.com)