67 lines
1.9 KiB
C++
67 lines
1.9 KiB
C++
//----------------------------------------------------------------------------
|
|
//
|
|
// Copyright (C) 2010 Intel Corporation
|
|
//
|
|
// File: ConnectedSystems.h
|
|
//
|
|
// Contents: This class handles connected systems per request
|
|
//
|
|
//----------------------------------------------------------------------------
|
|
|
|
#ifndef _CONNECTED_SYSTEMS__H__
|
|
#define _CONNECTED_SYSTEMS__H__
|
|
|
|
#include <set>
|
|
#include <map>
|
|
#include <ace/Refcounted_Auto_Ptr.h>
|
|
|
|
|
|
typedef std::set<ACE_CString> SYSTEMS_SET;
|
|
|
|
class Connected_Systems_Enumeration_Data
|
|
{
|
|
public:
|
|
Connected_Systems_Enumeration_Data();
|
|
time_t get_expires(void) {return _expires;}
|
|
SYSTEMS_SET::iterator& get_systems_set_iterator(void) { return _systems_set_iterator; };
|
|
SYSTEMS_SET::iterator get_systems_set_end(void) { return _systems_set.end(); };
|
|
private:
|
|
Connected_Systems_Enumeration_Data(const Connected_Systems_Enumeration_Data&);
|
|
SYSTEMS_SET _systems_set;
|
|
SYSTEMS_SET::iterator _systems_set_iterator;
|
|
time_t _expires;
|
|
} ;
|
|
|
|
typedef ACE_Refcounted_Auto_Ptr<Connected_Systems_Enumeration_Data, ACE_Thread_Mutex> ConnectedSystemsEnumerationDataPtr;
|
|
typedef std::map<ACE_UINT32, ConnectedSystemsEnumerationDataPtr> CONNECTED_SYSTEMS_MAP;
|
|
|
|
class Connected_Systems
|
|
{
|
|
private:
|
|
Connected_Systems(void); // Ctor.
|
|
|
|
public:
|
|
static Connected_Systems& instance() {
|
|
static Connected_Systems c;
|
|
return c;
|
|
}
|
|
bool add_new_enumeration(ACE_UINT32 &context ,const ConnectedSystemsEnumerationDataPtr& cs);
|
|
bool context_exists(ACE_UINT32 context);
|
|
ConnectedSystemsEnumerationDataPtr* get_connected_system_enumeration_data_ptr(ACE_UINT32 context);
|
|
bool release_context(ACE_UINT32 context);
|
|
bool release_expired_enumerations(void);
|
|
bool max_concurrent_enums_exceeded(void);
|
|
|
|
|
|
private:
|
|
// Data members
|
|
ACE_UINT32 _curr_context;
|
|
CONNECTED_SYSTEMS_MAP _connected_systems_map;
|
|
|
|
// Read/Write lock of this container
|
|
ACE_Recursive_Thread_Mutex rwmutex_;
|
|
|
|
};
|
|
|
|
#endif //_CONNECTED_SYSTEMS__H__
|