javacommons/comms/src/commscontext.h
author Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
Tue, 27 Apr 2010 16:30:29 +0300
branchRCL_3
changeset 19 04becd199f91
permissions -rw-r--r--
Revision: v2.1.22 Kit: 201017

/*
* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
* All rights reserved.
* This component and the accompanying materials are made available
* under the terms of "Eclipse Public License v1.0"
* which accompanies this distribution, and is available
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
*
* Initial Contributors:
* Nokia Corporation - initial contribution.
*
* Contributors:
*
* Description:  Container for sharable endpoints. Sharable endpoints can be
                 found using name (wstring)
*
*/

#ifndef COMMSCONTEXT_H
#define COMMSCONTEXT_H
#include <map>
#include <string>

#include "javaosheaders.h"
#include "scopedlocks.h"

using std::wstring;

namespace java
{
namespace comms
{
class CommsClientEndpoint;
class CommsServerEndpoint;

OS_NONSHARABLE_CLASS(CommsContext)
{
public:
    CommsContext();
    virtual ~CommsContext();
    static CommsContext& getContext();

    void add(CommsClientEndpoint* endpoint, const wstring& name);
    void remove(CommsClientEndpoint* endpoint);
    CommsClientEndpoint* find(const wstring& name);

    void add(CommsServerEndpoint* endpoint, const wstring& name);
    void remove(CommsServerEndpoint* endpoint);
    CommsServerEndpoint* findServer(const wstring& name);

private:
    typedef std::map<CommsClientEndpoint*, wstring*> endpoints_t;
    endpoints_t mEndpoints;

    typedef std::map<CommsServerEndpoint*, wstring*> serverEndpoints_t;
    serverEndpoints_t mServerEndpoints;

    java::util::ScopedMutex mEndpointsMutex;
};

} // namespace comms
} // namespace java

#endif // COMMSCONTEXT_H