Remove all use of nframes_t.
[ardour.git] / libs / midi++2 / midi++ / manager.h
index eef52abe521664e79f2f3dcd2b3d8eb64a432bed..dec9d0d9f17b91dd0cd290780bd2e56b2b49b901 100644 (file)
 #ifndef __midi_manager_h__
 #define __midi_manager_h__
 
-#include <map>
+#include <list>
+
 #include <string>
 
-#include <midi++/types.h>
-#include <midi++/port.h>
+#include "midi++/types.h"
+#include "midi++/port.h"
 
 namespace MIDI {
 
-/** Creates, stores, and manages system MIDI ports.
- */
+class MachineControl;  
+
 class Manager {
   public:
        ~Manager ();
        
-       void set_api_data(void* data) { api_data = data; }
-
        /** Signal the start of an audio cycle.
         * This MUST be called before any reading/writing for this cycle.
         * Realtime safe.
         */
-       void cycle_start(nframes_t nframes);
-
+       void cycle_start (pframes_t nframes);
+       
        /** Signal the end of an audio cycle.
         * This signifies that the cycle began with @ref cycle_start has ended.
         * This MUST be called at the end of each cycle.
         * Realtime safe.
         */
-       void cycle_end();
+       void cycle_end ();
 
-       Port *add_port (PortRequest &);
-       int   remove_port (Port*);
+       MachineControl* mmc () const { return _mmc; }
+       Port *mtc_input_port() const { return _mtc_input_port; }
+       Port *mtc_output_port() const { return _mtc_output_port; }
+       Port *midi_input_port() const { return _midi_input_port; }
+       Port *midi_output_port() const { return _midi_output_port; }
+       Port *midi_clock_input_port() const { return _midi_clock_input_port; }
+       Port *midi_clock_output_port() const { return _midi_clock_output_port; }
 
-       Port *port (std::string name);
+       Port* add_port (Port *);
 
-       size_t    nports () { return ports_by_device.size(); }
+       Port* port (std::string const &);
 
-       int foreach_port (int (*func)(const Port &, size_t n, void *), 
-                         void *arg);
+       void set_port_states (std::list<XMLNode*>);
 
-       typedef std::map<std::string, Port *> PortMap;
+       typedef std::list<Port *> PortList;
 
-       const PortMap& get_midi_ports() const { return ports_by_tag; } 
+       const PortList& get_midi_ports() const { return _ports; } 
 
+       static void create (jack_client_t* jack);
+       
        static Manager *instance () {
-               if (theManager == 0) {
-                       theManager = new Manager;
-               }
                return theManager;
        }
 
-       static int parse_port_request (std::string str, Port::Type type);
+       void reestablish (jack_client_t *);
+       void reconnect ();
+
+       PBD::Signal0<void> PortsChanged;
 
   private:
        /* This is a SINGLETON pattern */
        
-       Manager ();
-
+       Manager (jack_client_t *);
        static Manager *theManager;
-       PortMap         ports_by_device; /* canonical */
-       PortMap         ports_by_tag;    /* may contain duplicate Ports */
 
-       void *api_data;
-
-       void close_ports ();
+       MIDI::MachineControl*   _mmc;
+       MIDI::Port*             _mtc_input_port;
+       MIDI::Port*             _mtc_output_port;
+       MIDI::Port*             _midi_input_port;
+       MIDI::Port*             _midi_output_port;
+       MIDI::Port*             _midi_clock_input_port;
+       MIDI::Port*             _midi_clock_output_port;
+       
+       std::list<Port*> _ports;
 };
 
 } // namespace MIDI