def _new(self, track_list): """ :param track_list: List of tracks to initialize the set with :type track_list: collections.Iterable[Track] | None """ if track_list is None: track_list = [] # noinspection PyCallingNonCallable c_track_array = (Track.c_ptr_type() * len(track_list))(*(t.c_pointer for t in track_list)) return self._call_cfunc( 'vital_object_trackset_new', [ctypes.c_size_t, ctypes.POINTER(Track.c_ptr_type())], [len(track_list), c_track_array], self.C_TYPE_PTR)
def tracks(self): """ Get the list of all tracks contained in this set (new instances). :return: list of new Track instances of tracks contained in this set :rtype: list[Track] """ c_ptr_arr = self._call_cfunc('vital_trackset_tracks', [self.C_TYPE_PTR], [self], ctypes.POINTER(Track.c_ptr_type())) tracks = [] for cptr in c_ptr_arr[:self.size()]: cptr = Track.c_ptr_type()(cptr.contents) tracks.append(Track(from_cptr=cptr)) free_void_ptr(c_ptr_arr) return tracks
def get_track(self, tid): """ Get the track in this set with the specified ID :raises IndexError: If no tracks in this set match the given ID. :param tid: The ID of the track to get :type tid: int :return: New Track instance referring to the track with the given ID in this set, or None if no tracks in this set have the given ID. :rtype: Track """ track_cptr = self._call_cfunc('vital_trackset_get_track', [self.C_TYPE_PTR, ctypes.c_int64], [self, tid], Track.c_ptr_type()) if not track_cptr: raise IndexError(tid) return Track(from_cptr=track_cptr)