00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
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 }