From 9b791e2ac349edeea02535ee5a022024524a734a Mon Sep 17 00:00:00 2001 From: HomeSpan Date: Wed, 26 Jun 2024 21:00:52 -0500 Subject: [PATCH] Update Reference.md --- docs/Reference.md | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/docs/Reference.md b/docs/Reference.md index 4673c7c..94076b3 100644 --- a/docs/Reference.md +++ b/docs/Reference.md @@ -386,11 +386,15 @@ The following methods are supported: * note that Linked Services are only applicable for select HAP Services. See Apple's HAP-R2 documentation for full details * example: `(new Service::Faucet)->addLink(new Service::Valve)->addLink(new Service::Valve);` (links two Valves to a Faucet) -* `vector getLinks()` - * returns a vector of pointers to Services that were added using `addLink()` - * useful for creating loops that iterate over all linked Services - * note that the returned vector points to generic SpanServices, which should be re-cast as needed - * example: `for(auto myValve : faucet->getLinks()) { if((MyValve *)myValve)->active->getVal()) ... }` checks all Valves linked to a Faucet +* `vector getLinks(const char *serviceName=NULL)` + * template function that returns a vector of pointers to Services that were added using `addLink()` + * if template parameter, *T*, is left blank, the elements of the returned vector will be of type *SpanService \** + * if template parameter, *T*, is specified, the elements of the returned vector will be cast into type *T* + * if *serviceName* is specified, only those services matching *serviceName* will be included in the return vector + * *serviceName* must be one of HomeSpan's built-in Services (e.g. "Valve") + * if *serviceName* is left blank or set to NULL, all services will be included in the return vector + * this function is useful for creating loops that iterate over all linked Services + * example: from within a Faucet Service containing linked Valves defined in *MyValveService*, use `for(auto valve : getLinks()) { if(valve->active->getVal()) ... }` to check which Valves are active * `virtual boolean update()` * HomeSpan calls this method upon receiving a request from a HomeKit Controller to update one or more Characteristics associated with the Service. Users should override this method with code that implements that requested updates using one or more of the SpanCharacteristic methods below. Method **must** return *true* if update succeeds, or *false* if not.