a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync/* ***** BEGIN LICENSE BLOCK *****
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync * Version: MPL 1.1/GPL 2.0/LGPL 2.1
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync *
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync * The contents of this file are subject to the Mozilla Public License Version
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync * 1.1 (the "License"); you may not use this file except in compliance with
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync * the License. You may obtain a copy of the License at
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync * http://www.mozilla.org/MPL/
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync *
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync * Software distributed under the License is distributed on an "AS IS" basis,
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync * for the specific language governing rights and limitations under the
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync * License.
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync *
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync * The Original Code is Mozilla Transaction Manager.
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync *
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync * The Initial Developer of the Original Code is
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync * Netscape Communications Corp.
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync * Portions created by the Initial Developer are Copyright (C) 2003
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync * the Initial Developer. All Rights Reserved.
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync *
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync * Contributor(s):
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync * John Gaunt <jgaunt@netscape.com>
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync *
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync * Alternatively, the contents of this file may be used under the terms of
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync * either the GNU General Public License Version 2 or later (the "GPL"), or
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync * in which case the provisions of the GPL or the LGPL are applicable instead
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync * of those above. If you wish to allow use of your version of this file only
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync * under the terms of either the GPL or the LGPL, and not to allow others to
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync * use your version of this file under the terms of the MPL, indicate your
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync * decision by deleting the provisions above and replace them with the notice
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync * and other provisions required by the GPL or the LGPL. If you do not delete
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync * the provisions above, a recipient may use your version of this file under
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync * the terms of any one of the MPL, the GPL or the LGPL.
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync *
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync * ***** END LICENSE BLOCK ***** */
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync#ifndef _tmTransactionManager_H_
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync#define _tmTransactionManager_H_
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync#include "plhash.h"
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync#include "tmUtils.h"
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync#include "tmVector.h"
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync#include "tmIPCModule.h"
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync// forward declarations
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsyncclass tmQueue;
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsyncclass tmClient;
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsyncclass tmTransaction;
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync/**
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync * This class manages the flow of messages from the IPC daemon (coming to
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync * it through the tmIPCModule) that ultimately come from a Transaction
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync * Service (TS) in a mozilla based client somewhere. The message is
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync * delivered to the proper queue, where it is dealt with.
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync *
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync * New queues get created here as clients request them.
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync */
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsyncclass tmTransactionManager
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync{
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsyncpublic:
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync ////////////////////////////////////////////////////////////////////////////
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync // Constructor(s) & Destructor & Initializer
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync /**
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync * reclaim the memory allcoated during initialization
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync */
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync virtual ~tmTransactionManager();
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync
/**
* Set up the storage of the queues - initialize the vector
*
* @returns NS_OK if successful
* @returns -1 if initialization fails
*/
PRInt32 Init();
////////////////////////////////////////////////////////////////////////////
// Public Member Functions
/**
* Called from the tmIPCModule. Decide where to send the message and
* dispatch it.
*/
void HandleTransaction(tmTransaction *aTrans);
/**
* Called by the queues when they need to get a message back out to a
* client.
*/
void SendTransaction(PRUint32 aDestClientIPCID, tmTransaction *aTrans) {
PR_ASSERT(aTrans);
tmIPCModule::SendMsg(aDestClientIPCID, aTrans);
}
protected:
////////////////////////////////////////////////////////////////////////////
// Protected Member Functions
// Queue management
/**
* @returns the queue indexed by the ID passed in, which could be nsnull
*/
tmQueue* GetQueue(PRUint32 aQueueID) {
return (tmQueue*) mQueues[aQueueID];
}
/**
* @returns the queue with the name passed in
* @returns nsnull if there is no queue with that name
*/
tmQueue* GetQueue(const char *aQueueName);
/**
* If all is successful a new queue with the name provided will be created,
* and added to the collection of queues. It will be initialized and ready
* to have transactions added.
*
* This doesn't check for the existance of a queue with this name. IF
* there is already a queue with this name then you will
* get that when using GetQueue(qName) and never get the new queue
* created here. A call to GetQueue(qID) will be able to get at the new
* queue, however you had better cache the ID.
*
* @returns -1 if the queue can't be created, or is not added
* @returns >= 0 if the queue was added successfully
*/
PRInt32 AddQueue(const char *aQueueType);
/**
*/
void RemoveQueue(PRUint32 aQueueID);
////////////////////////////////////////////////////////////////////////////
// Protected Member Variables
tmVector mQueues;
private:
};
#endif