DatabaseDemo.h 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. // Copyright (c) 2008-2023 the Urho3D project
  2. // License: MIT
  3. #pragma once
  4. #include "Sample.h"
  5. /// Database demo. This sample demonstrates how to use database subsystem to connect to a database and execute adhoc SQL statements.
  6. class DatabaseDemo : public Sample
  7. {
  8. URHO3D_OBJECT(DatabaseDemo, Sample)
  9. public:
  10. /// Construct.
  11. explicit DatabaseDemo(Context* context);
  12. /// Destruct.
  13. ~DatabaseDemo() override;
  14. /// Setup after engine initialization and before running the main loop.
  15. void Start() override;
  16. protected:
  17. /// Return XML patch instructions for screen joystick layout for a specific sample app, if any.
  18. String GetScreenJoystickPatchString() const override { return
  19. "<patch>"
  20. " <add sel=\"/element/element[./attribute[@name='Name' and @value='Button2']]\">"
  21. " <attribute name=\"Is Visible\" value=\"false\" />"
  22. " </add>"
  23. " <add sel=\"/element/element[./attribute[@name='Name' and @value='Hat0']]\">"
  24. " <attribute name=\"Is Visible\" value=\"false\" />"
  25. " </add>"
  26. "</patch>";
  27. }
  28. private:
  29. /// Handle console command event.
  30. void HandleConsoleCommand(StringHash eventType, VariantMap& eventData);
  31. /// Handle frame update event.
  32. void HandleUpdate(StringHash eventType, VariantMap& eventData);
  33. /// Handle ESC key down event to quit the engine.
  34. void HandleEscKeyDown(StringHash eventType, VariantMap& eventData);
  35. /// Handle Database cursor event.
  36. void HandleDbCursor(StringHash eventType, VariantMap& eventData);
  37. /// Handle user input either from the engine console or standard input.
  38. void HandleInput(const String& input);
  39. /// Print text to the engine console and standard output.
  40. void Print(const String& output);
  41. /// Managed database connection object (owned by Database subsystem).
  42. DbConnection* connection_;
  43. /// Internal row counter.
  44. unsigned row_;
  45. /// Maximum rows to be printed out.
  46. unsigned maxRows_;
  47. };