//  Copyright (c) 2001, Reson, Inc. All Rights Reserved.
//
//  Filename:   EdgeTechProtocol.h
//
//  Project:    6046
//
//  Author(s):  W. Arcus
//
//  Purpose:    
//
//  Notes:      
//

#if !defined(AFX_EDGETECHNETWORKPROTOCOL_H__BDB714AB_06A1_4C67_A969_961AB7EE1920__INCLUDED_)
#define AFX_EDGETECHNETWORKPROTOCOL_H__BDB714AB_06A1_4C67_A969_961AB7EE1920__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#include "..\..\..\Utils\NetUtils\DynamicBuffer.h"

class CEdgeTechNetworkProtocol
{
public:

    ///////////////
    // Services.

    // Construction and destruction.

                        CEdgeTechNetworkProtocol    (   void );

    virtual            ~CEdgeTechNetworkProtocol    (   void );

    // Decoding.

    unsigned long       BytesFollowingHeader        (   void ) const;
                                                        
    bool                IsRecordComplete            (   void ) const;

    bool                ResetDecoder                (   void );

    bool                Add                         (   BYTE                *pbyStream,
                                                        const unsigned long &rulBytes,
                                                        const bool          &rbIsHeader );

    BYTE *              DecodedRecord               (   void );

    unsigned long       DecodedRecordBytes          (   void );

    static
    bool                IsValidHeader               (   BYTE                *pbyStream,
                                                        const unsigned long &rulNumBytes );
    static
    unsigned long       GetHeaderSize               (   void );

    // Encoding.
                                                    
    bool                EncodePackets               (   BYTE               *pbyStream,
                                                        unsigned long       ulNumBytes );
                                                    
    unsigned long       GetNumberOfPackets          (   void );
                                                    
    BYTE *              GetNextPacket               (   unsigned long      &rulBytesInPacket );
                                                    
private:

    ///////////////
    // Defintions.

    typedef CDynamicBuffer<BYTE>                    Buffer_t;

    ///////////////
    // Attributes.

    std::auto_ptr<Buffer_t>                         m_pDecoder;
    std::auto_ptr<Buffer_t>                         m_pEncoder;

    ///////////////
    // Services.

};

#endif // !defined(AFX_EDGETECHNETWORKPROTOCOL_H__BDB714AB_06A1_4C67_A969_961AB7EE1920__INCLUDED_)
