(file) Return to MessageQueue.h CVS log (file) (dir) Up to [Pegasus] / pegasus / src / Pegasus / Common

File: [Pegasus] / pegasus / src / Pegasus / Common / MessageQueue.h (download)
Revision: 1.45, Thu Nov 30 11:33:20 2006 UTC (17 years, 7 months ago) by kamal.locahana
Branch: MAIN
CVS Tags: TASK_PEP328_SOLARIS_NEVADA_PORT, TASK-PEP328_SOLARIS_NEVADA_PORT_v2-root, TASK-PEP328_SOLARIS_NEVADA_PORT_v2-branch, TASK-PEP328_SOLARIS_NEVADA_PORT-root, TASK-PEP328_SOLARIS_NEVADA_PORT-branch, TASK-PEP328_SOLARIS_IX86_CC_PORT-root, TASK-PEP328_SOLARIS_IX86_CC_PORT-branch-v2, TASK-PEP328_SOLARIS_IX86_CC_PORT-branch, TASK-PEP305_VXWORKS-root, TASK-PEP305_VXWORKS-branch-pre-solaris-port, TASK-PEP305_VXWORKS-branch-post-solaris-port, TASK-PEP305_VXWORKS-branch-beta2, TASK-PEP305_VXWORKS-branch, TASK-PEP305_VXWORKS-2008-10-23, TASK-PEP291_IPV6-root, TASK-PEP291_IPV6-branch, TASK-PEP286_PRIVILEGE_SEPARATION-root, TASK-PEP286_PRIVILEGE_SEPARATION-branch, TASK-PEP274_dacim-root, TASK-PEP274_dacim-merged_out_to_branch, TASK-PEP274_dacim-merged_out_from_trunk, TASK-PEP274_dacim-merged_in_to_trunk, TASK-PEP274_dacim-merged_in_from_branch, TASK-PEP274_dacim-branch, TASK-Bug2102_RCMPIWindows-root, TASK-Bug2102_RCMPIWindows-merged_out_to_branch, TASK-Bug2102_RCMPIWindows-merged_out_from_trunk, TASK-Bug2102_RCMPIWindows-merged_in_to_trunk, TASK-Bug2102_RCMPIWindows-merged_in_from_branch, TASK-Bug2102_RCMPIWindows-branch, TASK-Bug2102Final-root, TASK-Bug2102Final-merged_out_to_branch, TASK-Bug2102Final-merged_out_from_trunk, TASK-Bug2102Final-merged_in_to_trunk, TASK-Bug2102Final-merged_in_from_branch, TASK-Bug2102Final-branch, TASK-BUG7240-root, TASK-BUG7240-branch, TASK-BUG7146_SqlRepositoryPrototype-root, TASK-BUG7146_SqlRepositoryPrototype-merged_out_to_branch, TASK-BUG7146_SqlRepositoryPrototype-merged_out_from_trunk, TASK-BUG7146_SqlRepositoryPrototype-merged_in_to_trunk, TASK-BUG7146_SqlRepositoryPrototype-merged_in_from_branch, TASK-BUG7146_SqlRepositoryPrototype-branch, RELEASE_2_8_2-RC1, RELEASE_2_8_2, RELEASE_2_8_1-RC1, RELEASE_2_8_1, RELEASE_2_8_0_BETA, RELEASE_2_8_0-RC2, RELEASE_2_8_0-RC1, RELEASE_2_8_0-FC, RELEASE_2_8_0, RELEASE_2_8-root, RELEASE_2_8-branch, RELEASE_2_7_3-RC1, RELEASE_2_7_3, RELEASE_2_7_2-RC1, RELEASE_2_7_2, RELEASE_2_7_1-RC1, RELEASE_2_7_1, RELEASE_2_7_0-RC1, RELEASE_2_7_0-BETA, RELEASE_2_7_0, RELEASE_2_7-root, RELEASE_2_7-branch, RELEASE_2_6_3-RC2, RELEASE_2_6_3-RC1, RELEASE_2_6_3, RELEASE_2_6_2-RC1, RELEASE_2_6_2, RELEASE_2_6_1-RC1, RELEASE_2_6_1, RELEASE_2_6_0-RC1, RELEASE_2_6_0, RELEASE_2_6-root, RELEASE_2_6-branch-clean, RELEASE_2_6-branch, PEP286_PRIVILEGE_SEPARATION_ROOT, PEP286_PRIVILEGE_SEPARATION_CODE_FREEZE, PEP286_PRIVILEGE_SEPARATION_BRANCH, PEP286_PRIVILEGE_SEPARATION_1, Makefile
Changes since 1.44: +4 -4 lines
BUG#: 5902

TITLE: Compiler Warnings

DESCRIPTION:  Fix for type mismatch in assignment

//%2006////////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2000, 2001, 2002 BMC Software; Hewlett-Packard Development
// Company, L.P.; IBM Corp.; The Open Group; Tivoli Systems.
// Copyright (c) 2003 BMC Software; Hewlett-Packard Development Company, L.P.;
// IBM Corp.; EMC Corporation, The Open Group.
// Copyright (c) 2004 BMC Software; Hewlett-Packard Development Company, L.P.;
// IBM Corp.; EMC Corporation; VERITAS Software Corporation; The Open Group.
// Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.;
// EMC Corporation; VERITAS Software Corporation; The Open Group.
// Copyright (c) 2006 Hewlett-Packard Development Company, L.P.; IBM Corp.;
// EMC Corporation; Symantec Corporation; The Open Group.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to
// deal in the Software without restriction, including without limitation the
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
// 
// THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
// ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED
// "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
// LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
// ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
//=============================================================================
//
//%////////////////////////////////////////////////////////////////////////////

#ifndef Pegasus_MessageQueue_h
#define Pegasus_MessageQueue_h

#include <Pegasus/Common/Config.h>
#include <Pegasus/Common/Message.h>
#include <Pegasus/Common/Mutex.h>
#include <Pegasus/Common/List.h>
#include <Pegasus/Common/Linkage.h>

PEGASUS_NAMESPACE_BEGIN

/** The MessageQueue class represents a queue abstraction and is used by
    modules to exchange messages. Methods are provided for enqueuing,
    dequeuing, removing, iterating messages. Some methods are virtual and
    may be overriden but subclasses to modify the behavior.

    <h1>A Word about Queue Ids</h1>

    You may pass a specific queue id to the MessageQueue() constructor. The
    default is to call MessageQueue::getNextQueueId() to obtain one. Only pass
    queue ids generated by calling MessageQueue::getNextQueueId() to this
    constructor. Otherwise, you might end up with two queues with the same
    queue id.

    A technique we encourage, is to declare global queue ids like this:

    <pre>
    extern const Uint32 GROCERY_QUEUE_ID;
    </pre>

    And then define them like this:

    <pre>
    const Uint32 GROCERY_QUEUE_ID = MessageQueue::getNextQueueId();
    </pre>

    And then pass them to the constructor of MessageQueue (from the derived
    class). In this way you will secure a unique constant identifier by which
    you may refer to a queue later on.

    <h1>A Word about using the find() Methods</h1>

    There are two find() methods. One that takes a queue id and one that
    takes a name. The time complexity of the former is O(1); whereas, the
    time complexity of the latter is O(n). Therefore, use the queue id form
    since it is more efficient.
*/
class PEGASUS_COMMON_LINKAGE MessageQueue
{
public:

    /** This constructor places this object on a queue table which is
    maintained by this class. Each message queue has a queue-id (which
    may be obtained by calling getQueueId()). The queue-id may be passed
    to lookupQueue() to obtain a pointer to the corresponding queue).

    @param queueId the queue id to be used by this object. ONLY PASS IN
    QUEUE IDS WHICH WERE GENERATED USING MessageQueue::getNextQueueId().
    Otherwise, you might end up with more than one queue with the same
    queue id.
    */
    MessageQueue(
        const char *name,
        Boolean async = false,
        Uint32 queueId = MessageQueue::getNextQueueId());

    /** Removes this queue from the queue table. */
    virtual ~MessageQueue();

    /** Enques a message (places it at the back of the queue).
    @param message pointer to message to be enqueued.
    @exception  NullPointer exception if message parameter is null.
    @exception  IPCException if socket call has an error
    */
    virtual void enqueue(Message* message);

    /** allows a caller to determine if this message queue is asynchronous or
    not.
    */
    virtual Boolean isAsync() const { return _async; }

    /** Dequeues a message (removes it from the front of the queue).
    @return pointer to message or zero if queue is empty.
    @exception IPCException Thrown if an IPC error occurs.
    */
    virtual Message* dequeue();

    /** Returns true if there are no messages on the queue. */
    Boolean isEmpty() const { return  (Boolean) _messageList.is_empty(); }

    /** Returns the number of messages on the queue. */
    Uint32 getCount() const {  return (Uint32) _messageList.size(); }

    /** Retrieve the queue id for this queue. */
    Uint32 getQueueId() const throw() { return _queueId; }

    Uint32 get_capabilities() const throw()
    {
        return _capabilities;
    }

    /** Provide a string name for this queue to be used by the print method.
     */
    const char* getQueueName() const;

    /** This method is called after a message has been enqueued. This default
    implementation does nothing. Derived classes may override this to
    take some action each time a message is enqueued (for example, this
    method could handle the incoming message in the thread of the caller
    of enqueue()).
    */
    virtual void handleEnqueue() ;

    /** This method <b>may</b> be called prior to enqueueing an message.
    the message queue can inform the caller that it does not want
    to handle the message by returning false **/

    virtual Boolean messageOK(const Message *msg) { return true ;}

    /** Lookup a message queue from a queue id. Note this is an O(1) operation.
    @exception IPCException Thrown if an IPC error occurs.
     */
    static MessageQueue* lookup(Uint32 queueId);

    /** Lookup a message given a queue name. NOte this is an O(N) operation.
    @exception IPCException Thrown if an IPC error occurs.
     */
    static MessageQueue* lookup(const char *name);

    /** Get the next available queue id. It always returns a non-zero
    queue id an monotonically increases and finally wraps (to one)
    after reaching the maximum unsigned 32 bit integer.
    @exception IPCException Thrown if an IPC error occurs.
    */
    static Uint32 getNextQueueId();

    /** Put the queue id into the stack.
    */
    static void putQueueId(Uint32 queueId);

protected:
    Uint32 _queueId;
    char *_name;
    Uint32 _capabilities;

private:
    List<Message, Mutex> _messageList;
    Boolean _async;
};

PEGASUS_NAMESPACE_END

#endif /* Pegasus_MessageQueue_h */

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2