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 {
00029 &gAudioPortType,
00030 &gMidiPortType,
00031 };
00032
00033 jack_port_type_id_t PORT_TYPES_MAX = sizeof(port_types) / sizeof(port_types[0]);
00034
00035 jack_port_type_id_t GetPortTypeId(const char* port_type)
00036 {
00037 for (jack_port_type_id_t i = 0; i < PORT_TYPES_MAX; ++i) {
00038 const JackPortType* type = port_types[i];
00039 assert(type != 0);
00040 if (strcmp(port_type, type->name) == 0)
00041 return i;
00042 }
00043 return PORT_TYPES_MAX;
00044 }
00045
00046 const JackPortType* GetPortType(jack_port_type_id_t type_id)
00047 {
00048 assert(type_id >= 0 && type_id <= PORT_TYPES_MAX);
00049 const JackPortType* type = port_types[type_id];
00050 assert(type != 0);
00051 return type;
00052 }
00053
00054 }