#pragma once
class P4Connection;
class StrPtr;
class P4BridgeServer;
#ifndef time
#include "time.h";
#endif
//forward references
class ConnectionManager;
//#ifdef _DEBUG_MEMORY
//class IdleConnection : public DoublyLinkedListItem, p4base
//#else
//class IdleConnection : public DoublyLinkedListItem
//#endif
//{
//public:
//	unsigned _int64 ReleaseTime;
//	P4Connection* pCon;
//
//#ifdef _DEBUG_MEMORY
//	IdleConnection(P4Connection* pcon, _int64 releaseTime);
//#else
//	IdleConnection(P4Connection* pcon, _int64 releaseTime)
//		: DoublyLinkedListItem(NULL) { pCon = pcon; ReleaseTime = releaseTime;} 
//#endif
//
//	virtual ~IdleConnection(void);
//
//#ifdef _DEBUG_MEMORY
//	    // Simple type identification for registering objects
//	virtual int Type(void) {return tIdleConnection;}
//#endif
//};
#ifdef _DEBUG_MEMORY
class ConnectionManager : public DoublyLinkedList, p4base
#else
class ConnectionManager : public DoublyLinkedList
#endif
{
private:
	char* client;
	char* user;
	char* port;
	char* password;
	char* programName;
	char* programVer;
	char* cwd;
	CharSetApi::CharSet charset;
	CharSetApi::CharSet file_charset;
	P4BridgeServer *pServer;
	ConnectionManager(void);
	DoublyLinkedList* IdleConnections;
	void DiscardConnections();
public:
	int Initialized;
	ConnectionManager(P4BridgeServer *pserver);
	virtual ~ConnectionManager(void);
	P4Connection* GetConnection(int cmdId);
	void ReleaseConnection(int cmdId, unsigned _int64 releaseTime);
	void ReleaseConnection(P4Connection* pCon, unsigned _int64 releaseTime);
	int FreeConnections( unsigned _int64 currentTime );
	P4Connection* NewConnection(int cmdId);
	//P4Connection* DefaultConnection();
	// Set the connection data used
	void SetClient( const char* newVal );
	void SetUser( const char* newVal );
	void SetPort( const char* newVal );
	void SetPassword( const char* newVal );
	void SetProgramName( const char* newVal );
	void SetProgramVer( const char* newVal );
	void SetCwd( const char* newCwd );
	void SetCharset( CharSetApi::CharSet c, CharSetApi::CharSet filec );
	void SetConnection(const char* newPort, const char* newUser, const char* newPassword, const char* newClient)
		{SetClient(newClient); SetUser(newUser);SetPort(newPort);SetPassword(newPassword);}
	const StrPtr* GetCharset( );
	int Disconnect( void );
#ifdef _DEBUG_MEMORY
	    // Simple type identification for registering objects
	virtual int Type(void) {return tConnectionManager;}
#endif
};
                     
                                
                    
                
            
                | # | 
                Change | 
                User | 
                Description | 
                Committed | 
                 | 
            
        
        
        
        
            
                | 
                    
                        #3                    
                 | 
                
                    28480                 | 
                
                    eskopljak                 | 
                
                    submit                 | 
                
                    
                 | 
                
                                            
                                                                
                                                                
                                                         | 
            
        
            
                | 
                    
                        #2                    
                 | 
                
                    28479                 | 
                
                    eskopljak                 | 
                
                    submit                 | 
                
                    
                 | 
                
                                                                                                        
                                     | 
            
        
            
                | 
                    
                        #1                    
                 | 
                
                    28441                 | 
                
                    eskopljak                 | 
                
                    Merging using p4api.net_branch                 | 
                
                    
                 | 
                
                                            
                                                                
                                                                
                                                         | 
            
                
    
                
            
                | 
                    
                    //guest/perforce_software/p4api-net/main/p4bridge/ConnectionManager.h                 | 
            
        
        
        
        
            
                | 
                    
                        #1                    
                 | 
                
                    19043                 | 
                
                    Liz Lam                 | 
                
                    Rename p4api.net to p4api-net                 | 
                
                    
                 | 
                
                                            
                                                                
                                                                
                                                         | 
            
                
    
                
            
                | 
                    
                    //guest/perforce_software/p4api.net/main/p4bridge/ConnectionManager.h                 | 
            
        
        
        
        
            
                | 
                    
                        #1                    
                 | 
                
                    19042                 | 
                
                    Liz Lam                 | 
                
                    Rename/move file(s) to proper main branch.                 | 
                
                    
                 | 
                
                                            
                                                                
                                                                
                                                         | 
            
                
    
                
            
                | 
                    
                    //guest/perforce_software/p4api.net/p4bridge/ConnectionManager.h                 | 
            
        
        
        
        
            
                | 
                    
                        #4                    
                 | 
                
                    11220                 | 
                
                    Matt Attaway                 | 
                
                    Update Workshop version with most recent 14.2 patch of p4api.net                 | 
                
                    
                 | 
                
                                            
                                                                
                                                                
                                                         | 
            
        
            
                | 
                    
                        #3                    
                 | 
                
                    10191                 | 
                
                    Matt Attaway                 | 
                
                    Bring Workshop version of p4api.net up-to-date with the 14.2 release.                 | 
                
                    
                 | 
                
                                            
                                                                
                                                                
                                                         | 
            
        
            
                | 
                    
                        #2                    
                 | 
                
                    8964                 | 
                
                    Bill                 | 
                
                    fix line endings                 | 
                
                    
                 | 
                
                                            
                                                                
                                                                
                                                         | 
            
        
            
                | 
                    
                        #1                    
                 | 
                
                    8873                 | 
                
                    Matt Attaway                 | 
                
                    Initial add of the P4API.NET source code                 | 
                
                    
                 | 
                
                                            
                                                                
                                                                
                                                         |