-
-
Notifications
You must be signed in to change notification settings - Fork 94
Service logic moved to kernel #554
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
a2c6368
Refactor
KenVanHoeylandt d479359
Fix BT paths
KenVanHoeylandt 2433aeb
Remove C++ service state
KenVanHoeylandt 469cf0d
Improvements
KenVanHoeylandt e801dcf
Remove try_get and put functions for services
KenVanHoeylandt a2a802e
Merge branch 'main' into service-logic-move-to-kernel
KenVanHoeylandt e3bd87a
Remove ServiceInstance
KenVanHoeylandt affdd61
Simplify
KenVanHoeylandt File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,30 +1,33 @@ | ||
| #pragma once | ||
|
|
||
| #include <memory> | ||
| #include <tactility/service/service_manifest.h> | ||
|
|
||
| struct ServiceInstance; | ||
|
|
||
| namespace tt::service { | ||
|
|
||
| struct ServiceManifest; | ||
| class ServicePaths; | ||
|
|
||
| /** | ||
| * The public representation of a service instance. | ||
| * Thin, non-owning wrapper around the running TactilityKernel service instance | ||
| * (ServiceInstance, which the kernel API also calls ServiceContext). | ||
| * @warning Do not store references or pointers to these! You can retrieve them via the Loader service. | ||
| */ | ||
| class ServiceContext { | ||
|
|
||
| protected: | ||
| class ServiceContext final { | ||
|
|
||
| virtual ~ServiceContext() = default; | ||
| ::ServiceInstance* service_instance; | ||
|
|
||
| public: | ||
|
|
||
| explicit ServiceContext(::ServiceInstance* instance) : service_instance(instance) {} | ||
|
|
||
| /** @return a reference to the service's manifest */ | ||
| virtual const ServiceManifest& getManifest() const = 0; | ||
| const ::ServiceManifest* getManifest() const; | ||
|
|
||
| /** Retrieve the paths that are relevant to this service */ | ||
| virtual std::unique_ptr<ServicePaths> getPaths() const = 0; | ||
| std::unique_ptr<ServicePaths> getPaths() const; | ||
| }; | ||
|
|
||
|
|
||
| } // namespace | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,45 +1,67 @@ | ||
| #pragma once | ||
|
|
||
| #include <tactility/check.h> | ||
| #include <tactility/error.h> | ||
| #include <tactility/service/service_manifest.h> | ||
| #include <tactility/service/service_paths.h> | ||
|
|
||
| #include <cassert> | ||
| #include <string> | ||
| #include <memory> | ||
|
|
||
| namespace tt::service { | ||
|
|
||
| // Forward declarations | ||
| class ServiceManifest; | ||
| constexpr size_t PATH_BUFFER_SIZE = 255; | ||
|
|
||
| class ServicePaths { | ||
|
|
||
| std::shared_ptr<const ServiceManifest> manifest; | ||
| const ::ServiceManifest* manifest; | ||
|
|
||
| public: | ||
|
|
||
| explicit ServicePaths(std::shared_ptr<const ServiceManifest> manifest) : manifest(std::move(manifest)) {} | ||
| explicit ServicePaths(const ::ServiceManifest* manifest) : manifest(manifest) {} | ||
|
|
||
| /** | ||
| * The user data directory is intended to survive OS upgrades. | ||
| * The path will not end with a "/". | ||
| */ | ||
| std::string getUserDataDirectory() const; | ||
| std::string getUserDataDirectory() const { | ||
| char buffer[PATH_BUFFER_SIZE]; | ||
| check(service_paths_get_user_data_directory(manifest->id, buffer, sizeof(buffer)) == ERROR_NONE); | ||
| return buffer; | ||
| } | ||
|
|
||
| /** | ||
| * The user data directory is intended to survive OS upgrades. | ||
| * Configuration data should be stored here. | ||
| * @param[in] childPath the path without a "/" prefix | ||
| */ | ||
| std::string getUserDataPath(const std::string& childPath) const; | ||
| std::string getUserDataPath(const std::string& childPath) const { | ||
| assert(!childPath.starts_with('/')); | ||
| char buffer[PATH_BUFFER_SIZE]; | ||
| check(service_paths_get_user_data_path(manifest->id, childPath.c_str(), buffer, sizeof(buffer)) == ERROR_NONE); | ||
| return buffer; | ||
| } | ||
|
|
||
| /** | ||
| * You should not store configuration data here. | ||
| * The path will not end with a "/". | ||
| */ | ||
| std::string getAssetsDirectory() const; | ||
| std::string getAssetsDirectory() const { | ||
| char buffer[PATH_BUFFER_SIZE]; | ||
| check(service_paths_get_assets_directory(manifest->id, buffer, sizeof(buffer)) == ERROR_NONE); | ||
| return buffer; | ||
| } | ||
|
|
||
| /** | ||
| * You should not store configuration data here. | ||
| * @param[in] childPath the path without a "/" prefix | ||
| */ | ||
| std::string getAssetsPath(const std::string& childPath) const; | ||
| std::string getAssetsPath(const std::string& childPath) const { | ||
| assert(!childPath.starts_with('/')); | ||
| char buffer[PATH_BUFFER_SIZE]; | ||
| check(service_paths_get_assets_path(manifest->id, childPath.c_str(), buffer, sizeof(buffer)) == ERROR_NONE); | ||
| return buffer; | ||
| } | ||
| }; | ||
|
|
||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| #include <Tactility/service/ServiceContext.h> | ||
|
|
||
| #include <Tactility/service/ServicePaths.h> | ||
|
|
||
| #include <tactility/service/service_instance.h> | ||
|
|
||
| namespace tt::service { | ||
|
|
||
| const ::ServiceManifest* ServiceContext::getManifest() const { | ||
| return service_instance_get_manifest(service_instance); | ||
| } | ||
|
|
||
| std::unique_ptr<ServicePaths> ServiceContext::getPaths() const { | ||
| return std::make_unique<ServicePaths>(getManifest()); | ||
| } | ||
|
|
||
| } // namespace |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.