Skip to content

Commit 56e985d

Browse files
authored
Merge pull request #1986 from gofractally/no-doc-crtp-service
psibase::Service doesn't use CRTP
2 parents a2af0fa + a3b5d20 commit 56e985d

3 files changed

Lines changed: 5 additions & 23 deletions

File tree

doc/src/development/services/cpp-service/reference/services-events.md

Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -4,32 +4,14 @@
44

55
To define a service:
66

7-
- Make a struct or class. It may optionally publicly inherit from [psibase::Service] to gain the [psibase::Service::emit] and [psibase::Service::events] convenience methods.
7+
- Make a struct or class. It may optionally publicly inherit from [psibase::Service] to gain several convenience methods.
88
- Define or declare the set of methods
99
- Reflect the methods using `PSIO_REFLECT`. Only reflected methods become actions; these are available for transactions and for other services to call using [psibase::Actor] or [psibase::call].
1010

11-
### Example without convenience base class:
12-
13-
```c++
14-
struct MyService
15-
{
16-
// The account this service is normally installed on. This definition
17-
// is optional.
18-
static constexpr auto service = psibase::AccountNumber("myservice");
19-
20-
void doSomething(std::string_view str);
21-
std::string somethingElse(uint32_t x, psibase::AccountNumber y);
22-
};
23-
24-
PSIO_REFLECT(MyService,
25-
method(doSomething, str),
26-
method(somethingElse, x, y))
27-
```
28-
2911
### Example with convenience base class:
3012

3113
```c++
32-
struct MyService: psibase::Service<MyService>
14+
struct MyService: psibase::Service
3315
{
3416
// The account this service is normally installed on. This definition
3517
// is optional.
@@ -71,7 +53,7 @@ To define events for a service, declare the event functions as below, then refle
7153
After you have defined your events, use [psibase::Service::emit] to emit them and [psibase::Service::events] to read them.
7254

7355
```c++
74-
struct MyService: psibase::Service<MyService> {
56+
struct MyService: psibase::Service {
7557
struct Events {
7658
// Events which live a long time
7759
struct History {

libraries/psibase/common/include/psibase/Actor.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,7 @@ namespace psibase
380380
/// For example, if `SomeService` has this set of methods:
381381
///
382382
/// ```c++
383-
/// struct SomeService : psibase::Service<SomeService>
383+
/// struct SomeService : psibase::Service
384384
/// {
385385
/// void doSomething(std::string_view str);
386386
/// std::string doAnother(uint32_t x, psibase::AccountNumber y);

libraries/psibase/common/include/psibase/serveGraphQL.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ namespace psibase
280280
/// };
281281
/// PSIO_REFLECT(Query, method(rowsByPrimary), method(rowsBySecondary))
282282
///
283-
/// struct ExampleService : psibase::Service<ExampleService>
283+
/// struct ExampleService : psibase::Service
284284
/// {
285285
/// std::optional<psibase::HttpReply> serveSys(psibase::HttpRequest request)
286286
/// {

0 commit comments

Comments
 (0)