{"id":19389510,"url":"https://github.com/linksplatform/delegates","last_synced_at":"2025-07-24T20:05:30.934Z","repository":{"id":44040349,"uuid":"231249913","full_name":"linksplatform/Delegates","owner":"linksplatform","description":"LinksPlatform's Platform.Delegates Template Library","archived":false,"fork":false,"pushed_at":"2024-10-13T18:35:38.000Z","size":220,"stargazers_count":4,"open_issues_count":5,"forks_count":3,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-07-16T15:05:19.762Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"unlicense","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/linksplatform.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-01-01T18:27:25.000Z","updated_at":"2025-04-30T07:53:13.000Z","dependencies_parsed_at":"2024-11-10T10:16:41.202Z","dependency_job_id":"0a8a6f48-0ec2-4c76-9145-3ab4857956a8","html_url":"https://github.com/linksplatform/Delegates","commit_stats":null,"previous_names":[],"tags_count":37,"template":false,"template_full_name":null,"purl":"pkg:github/linksplatform/Delegates","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/linksplatform%2FDelegates","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/linksplatform%2FDelegates/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/linksplatform%2FDelegates/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/linksplatform%2FDelegates/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/linksplatform","download_url":"https://codeload.github.com/linksplatform/Delegates/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/linksplatform%2FDelegates/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265702266,"owners_count":23813771,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-10T10:16:26.725Z","updated_at":"2025-07-24T20:05:30.899Z","avatar_url":"https://github.com/linksplatform.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![NuGet Version and Downloads count](https://img.shields.io/nuget/v/Platform.Delegates.TemplateLibrary?label=nuget\u0026style=flat)](https://www.nuget.org/packages/Platform.Delegates.TemplateLibrary)\n[![ConanCenter package](https://repology.org/badge/version-for-repo/conancenter/platform.delegates.svg)](https://conan.io/center/platform.delegates)\n\n# Delegates\nLinksPlatform's Platform::Delegates Template Class Library\n\nDelegate and MulticastDelegate classes are modeled after [.NET Delegates](https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/delegates/).\n\nDelegate is a container for callable function. Delegate can contain:\n* Pointer to simple function (represented by a single pointer).\n* Pointer to an instanse of class and to a member method of this class.\n* Pointer to std::function instance.\n\nUnlike std::function Delegate class supports primitive by reference comparision for equality.\n\nMulticastDelegate represents a thread-safe collection of Delegates that are callable at the same time. If you call MulticastDelegate all Delegates added to its collection will be called. MulticastDelegate can be used as a basis for simple event model (similar of that you can find in .NET). Because Delegate class supports the comparision for equality you can both subscribe and unsubscribe any Delegate instance to MulticastDelegate. To be able to unsubscribe from event represented by MulticastDelegate instance you should store Delegate instance somewhere. Due to its thread safety MulticastDelegate instance can be global/static object to which every thread is safe to subscribe.\n\nNuGet package: [Platform.Delegates.TemplateLibrary](https://www.nuget.org/packages/Platform.Delegates.TemplateLibrary)\n\nConan package: [platform.delegates](http://www.conan.io/center/platform.delegates)\n\n## Example\n\n```C++\n#include \u003cPlatform.Delegates.h\u003e\n\nvoid function(const char *str) \n{ \n    std::cout \u003c\u003c \"function(\" \u003c\u003c str \u003c\u003c \")\" \u003c\u003c std::endl; \n}\n\nstruct Object\n{\n    void Method(const char *str) \n    {\n        std::cout \u003c\u003c \"Object::Method(\" \u003c\u003c str \u003c\u003c \")\" \u003c\u003c std::endl;\n    }\n};\n\nint main()\n{\n    MulticastDelegate\u003cvoid(const char *)\u003e event;\n\n    Delegate\u003cvoid(const char *)\u003e memberMethod(std::make_shared\u003cObject\u003e(), \u0026Object::Method);\n\n    auto lambda = std::make_shared\u003cstd::function\u003cvoid(const char *)\u003e\u003e([](const char *str) \n    { \n        std::cout \u003c\u003c \"lambda(\" \u003c\u003c str \u003c\u003c \")\" \u003c\u003c std::endl;\n    });\n\n    // Subscribe\n    event += function;\n    event += lambda;\n    event += memberMethod;\n\n    // Raise the event\n    event(\"value\");\n\n    // Unsubscribe\n    event -= function;\n    event -= lambda;\n    event -= memberMethod;\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flinksplatform%2Fdelegates","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flinksplatform%2Fdelegates","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flinksplatform%2Fdelegates/lists"}