//                           UNCLASSIFIED
/*-------------------------------------------------------------------------
RAYTHEON PROPRIETARY: THIS DOCUMENT CONTAINS DATA OR INFORMATION
PROPRIETARY TO RAYTHEON COMPANY AND IS RESTRICTED TO USE ONLY BY PERSONS
AUTHORIZED BY RAYTHEON COMPANY IN WRITING TO USE IT. DISCLOSURE TO
UNAUTHORIZED PERSONS WOULD LIKELY CAUSE SUBSTANTIAL COMPETITIVE HARM TO
RAYTHEON COMPANY'S BUSINESS POSITION. NEITHER SAID DOCUMENT NOR ITS
CONTENTS SHALL BE FURNISHED OR DISCLOSED TO OR COPIED OR USED BY PERSONS
OUTSIDE RAYTHEON COMPANY WITHOUT THE EXPRESS WRITTEN APPROVAL OF RAYTHEON
COMPANY.

THIS PROPRIETARY NOTICE IS NOT APPLICABLE IF DELIVERED TO THE U.S.
GOVERNMENT.

UNPUBLISHED WORK - COPYRIGHT RAYTHEON COMPANY.
-------------------------------------------------------------------------*/

using System;
using System.Collections.Generic;

namespace BitMeasurementManagerLib
{
   /// <summary>
   /// 
   /// </summary>
   internal class BitMessageIDs
   {
      #region PrivateClassMembers
      private Dictionary<uint, uint> _idToSizeMap;
      private Dictionary<uint, uint> _cmdIdToRspIdMap;
      private List<uint> _msgIds;
      #endregion

      #region PublicFuctions

      /// <summary>
      /// 
      /// </summary>
      internal BitMessageIDs()
      {
         _idToSizeMap = new Dictionary<uint, uint>();
         _cmdIdToRspIdMap = new Dictionary<uint, uint>();
         _msgIds = new List<uint>();
      }

      /// <summary>
      /// 
      /// </summary>
      /// <param name="messageId"></param>
      internal void AddId(uint messageId)
      {
         _idToSizeMap.Add(messageId, 0);
         _msgIds.Add(messageId);
      }

      /// <summary>
      /// 
      /// </summary>
      /// <param name="id"></param>
      /// <returns></returns>
      internal bool ContainsId(uint id)
      {
         return _idToSizeMap.ContainsKey(id);
      }

      /// <summary>
      /// 
      /// </summary>
      /// <returns></returns>
      internal List<uint> GetAllIds()
      {
         return _msgIds;
      }

      /// <summary>
      /// 
      /// </summary>
      /// <param name="cmdId"></param>
      /// <returns></returns>
      internal uint GetResponseId(uint cmdId)
      {
         if (_cmdIdToRspIdMap.ContainsKey(cmdId) == false)
         {
            throw new Exception("BitMessageIDs::GetResponseId() - cmdIdToRspIdMap does not contains messageId: " + cmdId.ToString("X8"));
         }

         return _cmdIdToRspIdMap[cmdId];
      }

      /// <summary>
      /// 
      /// </summary>
      /// <param name="id"></param>
      /// <returns></returns>
      internal uint GetSize(uint id)
      {
         if (_idToSizeMap.ContainsKey(id) == false)
         {
            throw new Exception("BitMessageIDs::GetSize() - _idToSizeMap does not contais messageId: " + id.ToString("X8"));
         }

         return _idToSizeMap[id];
      }

      /// <summary>
      /// 
      /// </summary>
      /// <param name="cmdId"></param>
      /// <returns></returns>
      internal bool IsThereAResponseMessage(uint cmdId)
      {
         if (_cmdIdToRspIdMap.ContainsKey(cmdId) == false)
         {
            return false;
         }
         else
         {
            return true;
         }
      }

      /// <summary>
      /// 
      /// </summary>
      /// <param name="msgId"></param>
      /// <param name="numBytes"></param>
      internal void SetMsgSize(uint msgId, uint numBytes)
      {
         _idToSizeMap[msgId] = numBytes;
      }

      /// <summary>
      /// 
      /// </summary>
      /// <param name="cmdId"></param>
      /// <param name="rspId"></param>
      internal void SetRspId(uint cmdId, uint rspId)
      {
         _cmdIdToRspIdMap[cmdId] = rspId;
      }

      #endregion
   }
}
