//  Copyright © 2003, RESON Inc. All Rights Reserved.
//
//  No part of this file may be reproduced or transmitted in any form or by
//  any means, electronic or mechanical, including photocopy, recording, or
//  information storage or retrieval system, without permission in writing
//  from RESON Inc.
//
//  Filename:   TriggerTableManager.h
//
//  Project:    6046
//
//  Author(s):  W. Arcus
//
//  Purpose:    
//
//  Notes:      
//

#if !defined(AFX_TRIGGERTABLEMANAGER_H__7E088AFA_85E2_4C82_BCCE_41A9196B1A50__INCLUDED_)
#define AFX_TRIGGERTABLEMANAGER_H__7E088AFA_85E2_4C82_BCCE_41A9196B1A50__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#include "7kPort.h"
#include "7kTrigger.h"
#include "7kTriggerSequence.h"

#pragma warning( push, 3 )                                                          // Microsoft's STL is dirty so suppress necessary warnings.
#pragma warning( disable : 4018 )
#include <list>
#pragma warning( default : 4018 )
#pragma warning( pop )

typedef std::list<C7kPort>      PortList_t;
typedef PortList_t::iterator    PortListIterator_t;

typedef std::list<C7kTrigger>           TriggerList_t;
typedef TriggerList_t::iterator         TriggerListIterator_t;

typedef std::list<C7kTriggerSequence>   SequenceList_t;
typedef SequenceList_t::iterator        SequenceListIterator_t;

class CTriggerTableManager
{
public:

    ///////////////
    // Services.

                            CTriggerTableManager    (   void );
    virtual                ~CTriggerTableManager    (   void );

    bool                    Clear                   (   void );

    bool                    AddSequence             (   C7kTriggerSequence  &rSequence );
    bool                    RemoveSequence          (   const unsigned long &rulSequence );

    bool                    AddTrigger              (   C7kTrigger          &rTrigger );
    bool                    RemoveTrigger           (   const unsigned long &rulTrigger );
    C7kTrigger *            Trigger                 (   const unsigned long &rulTrigger );

    bool                    AddPort                 (   C7kPort &rPort );
    bool                    RemovePort              (   const unsigned long &rulPortIndex );
    C7kPort *               Port                    (   const unsigned long &rulPortIndex );

private:

    ///////////////
    // Attributes.

    typedef std::list<C7kPort>              PortList_t;
    typedef PortList_t::iterator            PortListIterator_t;

    typedef std::list<C7kTrigger>           TriggerList_t;
    typedef TriggerList_t::iterator         TriggerListIterator_t;

    typedef std::list<C7kTriggerSequence>   SequenceList_t;
    typedef SequenceList_t::iterator        SequenceListIterator_t;

    ///////////////
    // Attributes.

    PortList_t              m_Ports;
    TriggerList_t           m_Triggers;
    SequenceList_t          m_Sequences;

    ///////////////
    // Services.

    bool                    DoesPortExist           (   const unsigned long        &rulPortId ) const;

    unsigned long           NextPortIndexNumber     (   void );

    bool                    SortAll                 (   void );

    bool                    RemoveLinkages          (   PortListIterator_t         &rpPort );

                            CTriggerTableManager    (   const CTriggerTableManager &rRhs );     // Not implemented thus private.
    CTriggerTableManager &  operator =              (   const CTriggerTableManager &rRhs );     // Not implemented thus private.

};

#endif // !defined(AFX_TRIGGERTABLEMANAGER_H__7E088AFA_85E2_4C82_BCCE_41A9196B1A50__INCLUDED_)
