{"id":21861316,"url":"https://github.com/seng3694/servicelocator","last_synced_at":"2025-04-14T19:33:47.698Z","repository":{"id":114139507,"uuid":"155107320","full_name":"Seng3694/ServiceLocator","owner":"Seng3694","description":"A simple implementation of the service locator design pattern in C++","archived":false,"fork":false,"pushed_at":"2022-02-19T08:59:19.000Z","size":6,"stargazers_count":21,"open_issues_count":0,"forks_count":3,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-28T07:51:15.058Z","etag":null,"topics":["cpp","servicelocator"],"latest_commit_sha":null,"homepage":null,"language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Seng3694.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":"2018-10-28T19:25:21.000Z","updated_at":"2024-10-02T07:50:52.000Z","dependencies_parsed_at":"2023-06-14T07:15:37.365Z","dependency_job_id":null,"html_url":"https://github.com/Seng3694/ServiceLocator","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Seng3694%2FServiceLocator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Seng3694%2FServiceLocator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Seng3694%2FServiceLocator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Seng3694%2FServiceLocator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Seng3694","download_url":"https://codeload.github.com/Seng3694/ServiceLocator/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248946343,"owners_count":21187491,"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":["cpp","servicelocator"],"created_at":"2024-11-28T03:11:10.589Z","updated_at":"2025-04-14T19:33:47.691Z","avatar_url":"https://github.com/Seng3694.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# C++ Simple ServiceLocator #\nA simple implementation of the service locator design pattern in C++.\n\n## Usage ##\n\n### Single Instance ###\nRegister an instance:\n```cpp\nServiceLocator locator;\nlocator.registerInstance\u003cIMathService\u003e(new MathService());\n```\nAnd resolve it somewhere else:\n```cpp\nauto svc1 = locator.resolve\u003cIMathService\u003e();\nauto svc2 = locator.resolve\u003cIMathService\u003e(); // \u003c= same instance\n```\n\n\n### Lazy Initialization ###\nRegister a delegate which creates a shared pointer to the corresponding instance:\n```cpp\nServiceLocator locator;\nlocator.registerCreator\u003cIMathService\u003e([]() { return std::make_shared\u003cMathService\u003e(); });\n```\nEverytime you call `resolve`, the service locator will call the delegate and return the pointer:\n```cpp\nauto svc1 = locator.resolve\u003cIMathService\u003e();\nauto svc2 = locator.resolve\u003cIMathService\u003e(); // \u003c= not the same instance\n```\n\n### Clearing all registrations\n\nYou can clear all registrations manually (will be called in destructor automatically):\n```cpp\nlocator.clear();\n```\n\n## License ##\n\nYou can redistribute it and/or modify it under the terms of the MIT license. See [LICENSE][1] for details.\n\n[1]:LICENSE","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fseng3694%2Fservicelocator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fseng3694%2Fservicelocator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fseng3694%2Fservicelocator/lists"}