JackPortType.cpp

00001 /*
00002 Copyright (C) 2007 Dmitry Baikov
00003 
00004 This program is free software; you can redistribute it and/or modify
00005   it under the terms of the GNU General Public License as published by
00006   the Free Software Foundation; either version 2 of the License, or
00007   (at your option) any later version.
00008 
00009   This program is distributed in the hope that it will be useful,
00010   but WITHOUT ANY WARRANTY; without even the implied warranty of
00011   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012   GNU General Public License for more details.
00013 
00014   You should have received a copy of the GNU General Public License
00015   along with this program; if not, write to the Free Software
00016   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00017 
00018 */
00019 
00020 #include "JackPortType.h"
00021 #include <string.h>
00022 #include <assert.h>
00023 
00024 namespace Jack
00025 {
00026 
00027 static const JackPortType* port_types[] = {
00028     &gAudioPortType,
00029     &gMidiPortType,
00030 };
00031 
00032 enum { PORT_TYPES_MAX = sizeof(port_types)/sizeof(port_types[0]) };
00033 
00034 int GetPortTypeId(const char* port_type)
00035 {
00036     for (int i = 0; i < PORT_TYPES_MAX; ++i) {
00037         const JackPortType* type = port_types[i];
00038                 assert(type != 0);
00039         if (strcmp(port_type, type->name) == 0)
00040                         return i;
00041     }
00042     return -1;
00043 }
00044 
00045 const JackPortType* GetPortType(int type_id)
00046 {
00047         assert(type_id >= 0 && type_id <= PORT_TYPES_MAX);
00048     const JackPortType* type = port_types[type_id];
00049     assert(type != 0);
00050     return type;
00051 }
00052 
00053 } // namespace Jack

Generated on Thu Feb 14 11:16:02 2008 for Jackdmp by  doxygen 1.5.1