124 lines
3.2 KiB
C++

//----------------------------------------------------------------------------
//
// Copyright (C) Intel Corporation, 2006 - 2007.
//
// File: DataStructures.h
//
// Contents: General DataStructures
//
// Notes:
//----------------------------------------------------------------------------
#ifndef _DATA_STRUCTURES__H__
#define _DATA_STRUCTURES__H__
#include <ace/Synch.h>
#include "global.h"
#include "MPS_Utils.h"
#include <list>
#include <map>
#include <string>
using namespace std;
//===================================================
// GLOBAL Structures and Classes
//===================================================
class ServerData
{
private:
string _hostname;
unsigned short _port;
public:
ServerData():_hostname(), _port(){}
inline unsigned short getPort() const { return _port; }
STATUS validateINETdata() const;
string getAddressStr() const;
inline void setPort(const unsigned short& port) { _port = port; }
inline void setHostname(const string& hostname) { _hostname = hostname; }
};
class URL_Wrapper
{
private:
ServerData _serverData;
string _httpPrefix;
string _urlSuffix;
public:
URL_Wrapper():_serverData(), _httpPrefix(), _urlSuffix() {}
inline STATUS validateServer() const { return _serverData.validateINETdata(); }
inline void setPort(const unsigned short& port) { _serverData.setPort(port); }
inline void setHostname(const string& hostname) { _serverData.setHostname(hostname); }
inline ServerData& getServerData() { return _serverData; }
// set the suffix of the url - that is, without the server information
inline void setHttpPrefix(const string& httpPrefix) { _httpPrefix = httpPrefix; }
inline void setURLSuffix(const string& urlSuffix) { _urlSuffix = urlSuffix; }
inline string getServerAddressStr() const{ return _serverData.getAddressStr(); }
inline string getURLStr() const { return _httpPrefix + getServerAddressStr() + _urlSuffix; }
inline const string& getURLSuffixStr() const { return _urlSuffix; }
inline const string& getHttpPrefixStr() const { return _httpPrefix; }
};
typedef list<URL_Wrapper*> MCDataList;
class MCList:public MCDataList
{
public:
MCList(){};
~MCList();
void clearList();
ACE_RW_Thread_Mutex& guard() {return _rwmutex;}
private:
// Read/Write lock of this container
ACE_RW_Thread_Mutex _rwmutex;
};
/*
* A hash containing the authorized servers that messages can be sent to.
* Key is the name given to the server, and the value is a pointer to ServerData
* containing the information on that server.
*/
typedef map< const ACE_TString, ServerData *, ACE_TString_compare> AuthServerDataHash;
class AuthServerHash: public AuthServerDataHash
{
public:
AuthServerHash() {};
~AuthServerHash();
void clearHash();
ACE_RW_Thread_Mutex& guard() {return _rwmutex;}
private:
// Read/Write lock of this container
ACE_RW_Thread_Mutex _rwmutex;
};
class Authentication_Param
{
public:
Authentication_Param(const bool& authenticate,
const ACE_TString& dllName,
const ACE_TString& dllParams)
{
_authenticate = authenticate;
if(_authenticate)
{
_dllName = dllName.c_str();
_dllParams = dllParams.c_str();
}
else
{
_dllName = "";
_dllParams = "";
}
}
bool _authenticate;
string _dllName;
string _dllParams;
};
#endif /*_DATA_STRUCTURES__H__*/