| 1 | /* |
| 2 | * Copyright 2024 KylinSoft Co., Ltd. |
| 3 | * |
| 4 | * This program is free software: you can redistribute it and/or modify it under |
| 5 | * the terms of the GNU General Public License as published by the Free Software |
| 6 | * Foundation, either version 3 of the License, or (at your option) any later |
| 7 | * version. |
| 8 | * |
| 9 | * This program is distributed in the hope that it will be useful, but WITHOUT |
| 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
| 11 | * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more |
| 12 | * details. |
| 13 | * |
| 14 | * You should have received a copy of the GNU General Public License along with |
| 15 | * this program. If not, see <https://www.gnu.org/licenses/>. |
| 16 | */ |
| 17 | |
| 18 | #ifndef SERVICES_GENAIVISIONSERVICE_H |
| 19 | #define SERVICES_GENAIVISIONSERVICE_Hcxx . . $ `src/services/genai/vision/genaivisionservice.h:19:9`! |
| 20 | |
| 21 | #include <gio/gio.h> |
| 22 | #include <kylin-ai/aiengine.h> |
| 23 | |
| 24 | #include <map> |
| 25 | #include <memory> |
| 26 | #include <set> |
| 27 | #include <string> |
| 28 | |
| 29 | #include "engineselector/engineselector.h"cxx . . $ `<file>/src/engineselector/engineselector.h`/ |
| 30 | #include "genaivisionserviceglue.h"cxx . . $ `<file>/build/genaivisionserviceglue.h`/ |
| 31 | #include "imagegenerator.h"cxx . . $ `<file>/src/services/genai/vision/imagegenerator.h`/ |
| 32 | |
| 33 | class GenAiVisionServicecxx . . $ GenAiVisionService# : public stdcxx . . $ std/::enable_shared_from_thiscxx . . $ std/enable_shared_from_this#<GenAiVisionServicecxx . . $ GenAiVisionService#> { |
| 34 | public: |
| 35 | GenAiVisionServicecxx . . $ GenAiVisionService#GenAiVisionService(7a1cca9dd3aa3cff).(GDBusConnection& connection, EngineSelectorcxx . . $ EngineSelector#& engineSelector); |
| 36 | |
| 37 | ~cxx . . $ GenAiVisionService#`~GenAiVisionService`(ced63f7c635d850d).GenAiVisionServicecxx . . $ GenAiVisionService#(); |
| 38 | |
| 39 | void stopcxx . . $ GenAiVisionService#stop(49f6e7a06ebc5aa8).(); |
| 40 | |
| 41 | private: |
| 42 | void exportSkeletoncxx . . $ GenAiVisionService#exportSkeleton(49f6e7a06ebc5aa8).(); |
| 43 | void connectSignalcxx . . $ GenAiVisionService#connectSignal(49f6e7a06ebc5aa8).(); |
| 44 | void unexportSkeletoncxx . . $ GenAiVisionService#unexportSkeleton(49f6e7a06ebc5aa8).(); |
| 45 | int generateRandomSessionIdcxx . . $ GenAiVisionService#generateRandomSessionId(b126dc7c1de90089).(); |
| 46 | bool isSessionIdValidcxx . . $ GenAiVisionService#isSessionIdValid(83c267b20bac841a).(int sessionId); |
| 47 | |
| 48 | GVariant* buildGVariantFromImageResultcxx . . $ GenAiVisionService#buildGVariantFromImageResult(8c3835b5eee3b1a9).(const ImageGenerationResultcxx . . $ ImageGenerationResult#& result); |
| 49 | void emitImageResultSignalcxx . . $ GenAiVisionService#emitImageResultSignal(36c2e77e085a47c3).(const stdcxx . . $ std/::stringcxx . . $ std/string#& interfaceName, const ImageGenerationResultcxx . . $ ImageGenerationResult#& result); |
| 50 | genaicxx . . $ genai/::ImageConfigcxx . . $ genai/ImageConfig# imageConfigFromJsoncxx . . $ GenAiVisionService#imageConfigFromJson(4c1ee321b808f327).(const stdcxx . . $ std/::stringcxx . . $ std/string#& jsonStr); |
| 51 | |
| 52 | static bool onHandleInitcxx . . $ GenAiVisionService#onHandleInit(b06c907e61b7c0ac).(AiRuntimeGenAiVisionService* service, GDBusMethodInvocation* invocation, |
| 53 | gpointer userData); |
| 54 | static bool onHandleGenerateImagecxx . . $ GenAiVisionService#onHandleGenerateImage(ca64c1af25dd0d08).(AiRuntimeGenAiVisionService* service, GDBusMethodInvocation* invocation, |
| 55 | gint sessionId, const gchar* prompt, gpointer userData); |
| 56 | static bool onHandleStopImageGenerationcxx . . $ GenAiVisionService#onHandleStopImageGeneration(da1d821812cec9bf).(AiRuntimeGenAiVisionService* service, GDBusMethodInvocation* invocation, |
| 57 | gint sessionId, gpointer userData); |
| 58 | static bool onHandleGetSupportedImageNumbercxx . . $ GenAiVisionService#onHandleGetSupportedImageNumber(da1d821812cec9bf).(AiRuntimeGenAiVisionService* service, GDBusMethodInvocation* invocation, |
| 59 | gint sessionId, gpointer userData); |
| 60 | |
| 61 | static bool onHandleGetSupportedImageSizecxx . . $ GenAiVisionService#onHandleGetSupportedImageSize(da1d821812cec9bf).(AiRuntimeGenAiVisionService* service, GDBusMethodInvocation* invocation, |
| 62 | gint sessionId, gpointer userData); |
| 63 | |
| 64 | static bool onHandleGetSupportedImageStylecxx . . $ GenAiVisionService#onHandleGetSupportedImageStyle(da1d821812cec9bf).(AiRuntimeGenAiVisionService* service, GDBusMethodInvocation* invocation, |
| 65 | gint sessionId, gpointer userData); |
| 66 | |
| 67 | static bool onHandleSetImageConfigcxx . . $ GenAiVisionService#onHandleSetImageConfig(ca64c1af25dd0d08).(AiRuntimeGenAiVisionService* service, GDBusMethodInvocation* invocation, |
| 68 | gint sessionId, const gchar* imageConfig, gpointer userData); |
| 69 | |
| 70 | void setImageGeneratorCallbackcxx . . $ GenAiVisionService#setImageGeneratorCallback(395a782d217aef40).(const stdcxx . . $ std/::shared_ptrcxx . . $ std/shared_ptr#<ImageGeneratorcxx . . $ ImageGenerator#>& imageGenerator, int sessionId); |
| 71 | |
| 72 | private: |
| 73 | stdcxx . . $ std/::shared_ptrcxx . . $ std/shared_ptr#<GenAiVisionServicecxx . . $ GenAiVisionService#> getSharedObjectcxx . . $ GenAiVisionService#getSharedObject(925e2173caadac9).() { return shared_from_thiscxx . . $ std/enable_shared_from_this#shared_from_this(676e398b0772ed8e).(); } |
| 74 | |
| 75 | void tryToChangeModelcxx . . $ GenAiVisionService#tryToChangeModel(d4f767463ce0a6b3).(int sessionId); |
| 76 | |
| 77 | private: |
| 78 | bool isExported_cxx . . $ GenAiVisionService#isExported_. = false; |
| 79 | AiRuntimeGenAiVisionService* delegate_cxx . . $ GenAiVisionService#delegate_. = nullptr; |
| 80 | |
| 81 | GDBusConnection& connection_cxx . . $ GenAiVisionService#connection_.; |
| 82 | |
| 83 | EngineSelectorcxx . . $ EngineSelector#& engineSelector_cxx . . $ GenAiVisionService#engineSelector_.; |
| 84 | |
| 85 | stdcxx . . $ std/::shared_ptrcxx . . $ std/shared_ptr#<ai_enginecxx . . $ ai_engine/::gen_aicxx . . $ ai_engine/gen_ai/::visioncxx . . $ ai_engine/gen_ai/vision/::AbstractImageGenerationEnginecxx . . $ ai_engine/gen_ai/vision/AbstractImageGenerationEngine#> visionEngine_cxx . . $ GenAiVisionService#visionEngine_.{cxx . . $ std/shared_ptr#shared_ptr(6d988fd07f070dfc).nullptr}; |
| 86 | |
| 87 | stdcxx . . $ std/::setcxx . . $ std/set#<int> sessionIdSet_cxx . . $ GenAiVisionService#sessionIdSet_.; |
| 88 | stdcxx . . $ std/::mapcxx . . $ std/map#<int, stdcxx . . $ std/::shared_ptrcxx . . $ std/shared_ptr#<ImageGeneratorcxx . . $ ImageGenerator#>> imageGenerator_cxx . . $ GenAiVisionService#imageGenerator_.; |
| 89 | |
| 90 | stdcxx . . $ std/::mapcxx . . $ std/map#<int, stdcxx . . $ std/::atomic_boolcxx . . $ std/atomic_bool#> modelChangedMap_cxx . . $ GenAiVisionService#modelChangedMap_.{cxx . . $ std/map#map(49f6e7a06ebc5aa8).}; |
| 91 | stdcxx . . $ std/::vectorcxx . . $ std/vector#<gulong> handlerIds_cxx . . $ GenAiVisionService#handlerIds_.; |
| 92 | }; |
| 93 | |
| 94 | #endif |