summaryrefslogtreecommitdiffstats
path: root/include/unoidl/unoidl.hxx
blob: 7791fcd41c913214435bdd7235ab20c0b9cbd1b7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
 * This file is part of the LibreOffice project.
 *
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 */

#ifndef INCLUDED_UNOIDL_UNOIDL_HXX
#define INCLUDED_UNOIDL_UNOIDL_HXX

#include <sal/config.h>

#include <cassert>
#include <utility>
#include <vector>

#include <osl/mutex.hxx>
#include <rtl/ref.hxx>
#include <rtl/ustring.hxx>
#include <sal/types.h>
#include <salhelper/simplereferenceobject.hxx>
#include <unoidl/detail/dllapi.hxx>

namespace unoidl {

class SAL_WARN_UNUSED LO_DLLPUBLIC_UNOIDL NoSuchFileException final {
public:
    SAL_DLLPRIVATE NoSuchFileException(OUString uri): uri_(std::move(uri)) {}

    SAL_DLLPRIVATE NoSuchFileException(NoSuchFileException const & other):
        uri_(other.uri_) {}

    SAL_DLLPRIVATE ~NoSuchFileException() noexcept;

    const OUString& getUri() const { return uri_; }

private:
    NoSuchFileException& operator =(NoSuchFileException const &) = delete;

    OUString uri_;
};

class SAL_WARN_UNUSED LO_DLLPUBLIC_UNOIDL FileFormatException final {
public:
    SAL_DLLPRIVATE FileFormatException(
        OUString uri, OUString detail):
        uri_(std::move(uri)), detail_(std::move(detail))
    {}

    SAL_DLLPRIVATE FileFormatException(FileFormatException const & other):
        uri_(other.uri_), detail_(other.detail_)
    {}

    SAL_DLLPRIVATE ~FileFormatException() noexcept;

    const OUString& getUri() const { return uri_; }

    const OUString& getDetail() const { return detail_; }

private:
    FileFormatException& operator =(FileFormatException const &) = delete;

    OUString uri_;
    OUString detail_;
};

struct AnnotatedReference {
    AnnotatedReference(
        OUString theName,
        std::vector< OUString > && theAnnotations):
        name(std::move(theName)), annotations(std::move(theAnnotations))
    {}

    OUString name;

    std::vector< OUString > annotations;
};

class SAL_WARN_UNUSED LO_DLLPUBLIC_UNOIDL Entity: public salhelper::SimpleReferenceObject {
public:
    enum Sort {
        SORT_MODULE, SORT_ENUM_TYPE, SORT_PLAIN_STRUCT_TYPE,
        SORT_POLYMORPHIC_STRUCT_TYPE_TEMPLATE, SORT_EXCEPTION_TYPE,
        SORT_INTERFACE_TYPE, SORT_TYPEDEF, SORT_CONSTANT_GROUP,
        SORT_SINGLE_INTERFACE_BASED_SERVICE, SORT_ACCUMULATION_BASED_SERVICE,
        SORT_INTERFACE_BASED_SINGLETON, SORT_SERVICE_BASED_SINGLETON
    };

    Sort getSort() const { return sort_; }

protected:
    explicit SAL_DLLPRIVATE Entity(Sort sort): sort_(sort) {}

    virtual SAL_DLLPRIVATE ~Entity() noexcept override;

private:
    Sort sort_;
};

class SAL_WARN_UNUSED LO_DLLPUBLIC_UNOIDL MapCursor: public salhelper::SimpleReferenceObject {
public:
    // throws FileFormatException:
    virtual rtl::Reference< Entity > getNext(OUString * name) = 0;

protected:
    SAL_DLLPRIVATE MapCursor() {}

    virtual SAL_DLLPRIVATE ~MapCursor() noexcept override;
};

class SAL_WARN_UNUSED LO_DLLPUBLIC_UNOIDL ModuleEntity: public Entity {
public:
    // throws FileFormatException:
    virtual std::vector< OUString > getMemberNames() const = 0;

    // throws FileFormatException:
    virtual rtl::Reference< MapCursor > createCursor() const = 0;

protected:
    SAL_DLLPRIVATE ModuleEntity(): Entity(SORT_MODULE) {}

    virtual SAL_DLLPRIVATE ~ModuleEntity() noexcept override;
};

class SAL_WARN_UNUSED LO_DLLPUBLIC_UNOIDL PublishableEntity: public Entity {
public:
    bool isPublished() const { return published_; }

    std::vector< OUString > const & getAnnotations() const
    { return annotations_; }

protected:
    SAL_DLLPRIVATE PublishableEntity(
        Sort sort, bool published,
        std::vector< OUString >&& annotations):
        Entity(sort), published_(published), annotations_(std::move(annotations))
    {}

    virtual SAL_DLLPRIVATE ~PublishableEntity() noexcept override;

private:
    bool published_;

    std::vector< OUString > annotations_;
};

class SAL_WARN_UNUSED LO_DLLPUBLIC_UNOIDL EnumTypeEntity final : public PublishableEntity {
public:
    struct Member {
        Member(
            OUString theName, sal_Int32 theValue,
            std::vector< OUString >&& theAnnotations):
            name(std::move(theName)), value(theValue), annotations(std::move(theAnnotations))
        {}

        OUString name;

        sal_Int32 value;

        std::vector< OUString > annotations;
    };

    SAL_DLLPRIVATE EnumTypeEntity(
        bool published, std::vector< Member >&& members,
        std::vector< OUString >&& annotations):
        PublishableEntity(SORT_ENUM_TYPE, published, std::move(annotations)),
        members_(std::move(members))
    { assert(!members_.empty()); }

    std::vector< Member > const & getMembers() const { return members_; }

private:
    virtual SAL_DLLPRIVATE ~EnumTypeEntity() noexcept override;

    std::vector< Member > members_;
};

class SAL_WARN_UNUSED LO_DLLPUBLIC_UNOIDL PlainStructTypeEntity final : public PublishableEntity {
public:
    struct Member {
        Member(OUString theName, OUString theType,
               std::vector< OUString >&& theAnnotations):
            name(std::move(theName)), type(std::move(theType)), annotations(std::move(theAnnotations))
        {}

        OUString name;

        OUString type;

        std::vector< OUString > annotations;
    };

    SAL_DLLPRIVATE PlainStructTypeEntity(
        bool published, OUString directBase,
        std::vector< Member >&& directMembers,
        std::vector< OUString > && annotations):
        PublishableEntity(SORT_PLAIN_STRUCT_TYPE, published, std::move(annotations)),
        directBase_(std::move(directBase)), directMembers_(std::move(directMembers))
    {}

    const OUString& getDirectBase() const { return directBase_; }

    std::vector< Member > const & getDirectMembers() const
    { return directMembers_; }

private:
    virtual SAL_DLLPRIVATE ~PlainStructTypeEntity() noexcept override;

    OUString directBase_;
    std::vector< Member > directMembers_;
};

class SAL_WARN_UNUSED LO_DLLPUBLIC_UNOIDL PolymorphicStructTypeTemplateEntity final :
    public PublishableEntity
{
public:
    struct Member {
        Member(
            OUString theName, OUString theType,
            bool theParameterized,
            std::vector< OUString >&& theAnnotations):
            name(std::move(theName)), type(std::move(theType)), parameterized(theParameterized),
            annotations(std::move(theAnnotations))
        {}

        OUString name;

        OUString type;

        bool parameterized;

        std::vector< OUString > annotations;
    };

    SAL_DLLPRIVATE PolymorphicStructTypeTemplateEntity(
        bool published, std::vector< OUString >&& typeParameters,
        std::vector< Member >&& members,
        std::vector< OUString >&& annotations):
        PublishableEntity(
            SORT_POLYMORPHIC_STRUCT_TYPE_TEMPLATE, published, std::move(annotations)),
        typeParameters_(std::move(typeParameters)), members_(std::move(members))
    {}

    std::vector< OUString > const & getTypeParameters() const
    { return typeParameters_; }

    std::vector< Member > const & getMembers() const { return members_; }

private:
    virtual SAL_DLLPRIVATE ~PolymorphicStructTypeTemplateEntity() noexcept override;

    std::vector< OUString > typeParameters_;
    std::vector< Member > members_;
};

class SAL_WARN_UNUSED LO_DLLPUBLIC_UNOIDL ExceptionTypeEntity final : public PublishableEntity {
public:
    struct Member {
        Member(
            OUString theName, OUString theType,
            std::vector< OUString >&& theAnnotations):
            name(std::move(theName)), type(std::move(theType)), annotations(std::move(theAnnotations))
        {}

        OUString name;

        OUString type;

        std::vector< OUString > annotations;
    };

    SAL_DLLPRIVATE ExceptionTypeEntity(
        bool published, OUString directBase,
        std::vector< Member >&& directMembers,
        std::vector< OUString >&& annotations):
        PublishableEntity(SORT_EXCEPTION_TYPE, published, std::move(annotations)),
        directBase_(std::move(directBase)), directMembers_(std::move(directMembers))
    {}

    const OUString& getDirectBase() const { return directBase_; }

    std::vector< Member > const & getDirectMembers() const
    { return directMembers_; }

private:
    virtual SAL_DLLPRIVATE ~ExceptionTypeEntity() noexcept override;

    OUString directBase_;
    std::vector< Member > directMembers_;
};

class SAL_WARN_UNUSED LO_DLLPUBLIC_UNOIDL InterfaceTypeEntity final : public PublishableEntity {
public:
    struct Attribute {
        Attribute(
            OUString theName, OUString theType,
            bool theBound, bool theReadOnly,
            std::vector< OUString >&& theGetExceptions,
            std::vector< OUString >&& theSetExceptions,
            std::vector< OUString >&& theAnnotations):
            name(std::move(theName)), type(std::move(theType)), bound(theBound),
            readOnly(theReadOnly), getExceptions(std::move(theGetExceptions)),
            setExceptions(std::move(theSetExceptions)), annotations(std::move(theAnnotations))
        { assert(!theReadOnly || setExceptions.empty()); }

        OUString name;

        OUString type;

        bool bound;

        bool readOnly;

        std::vector< OUString > getExceptions;

        std::vector< OUString > setExceptions;

        std::vector< OUString > annotations;
    };

    struct Method {
        struct Parameter {
            enum Direction { DIRECTION_IN, DIRECTION_OUT, DIRECTION_IN_OUT };

            Parameter(
                OUString theName, OUString theType,
                Direction theDirection):
                name(std::move(theName)), type(std::move(theType)), direction(theDirection)
            {}

            OUString name;

            OUString type;

            Direction direction;
        };

        Method(
            OUString theName, OUString theReturnType,
            std::vector< Parameter >&& theParameters,
            std::vector< OUString >&& theExceptions,
            std::vector< OUString >&& theAnnotations):
            name(std::move(theName)), returnType(std::move(theReturnType)), parameters(std::move(theParameters)),
            exceptions(std::move(theExceptions)), annotations(std::move(theAnnotations))
        {}

        OUString name;

        OUString returnType;

        std::vector< Parameter > parameters;

        std::vector< OUString > exceptions;

        std::vector< OUString > annotations;
    };

    SAL_DLLPRIVATE InterfaceTypeEntity(
        bool published,
        std::vector< AnnotatedReference >&& directMandatoryBases,
        std::vector< AnnotatedReference >&& directOptionalBases,
        std::vector< Attribute >&& directAttributes,
        std::vector< Method >&& directMethods,
        std::vector< OUString >&& annotations):
        PublishableEntity(SORT_INTERFACE_TYPE, published, std::move(annotations)),
        directMandatoryBases_(std::move(directMandatoryBases)),
        directOptionalBases_(std::move(directOptionalBases)),
        directAttributes_(std::move(directAttributes)),
        directMethods_(std::move(directMethods))
    {}

    std::vector< AnnotatedReference > const & getDirectMandatoryBases() const
    { return directMandatoryBases_; }

    std::vector< AnnotatedReference > const & getDirectOptionalBases() const
    { return directOptionalBases_; }

    std::vector< Attribute > const & getDirectAttributes() const
    { return directAttributes_; }

    std::vector< Method > const & getDirectMethods() const
    { return directMethods_; }

private:
    virtual SAL_DLLPRIVATE ~InterfaceTypeEntity() noexcept override;

    std::vector< AnnotatedReference > directMandatoryBases_;
    std::vector< AnnotatedReference > directOptionalBases_;
    std::vector< Attribute > directAttributes_;
    std::vector< Method > directMethods_;
};

class SAL_WARN_UNUSED LO_DLLPUBLIC_UNOIDL TypedefEntity final : public PublishableEntity {
public:
    SAL_DLLPRIVATE TypedefEntity(
        bool published, OUString type,
        std::vector< OUString >&& annotations):
        PublishableEntity(SORT_TYPEDEF, published, std::move(annotations)), type_(std::move(type))
    {}

    const OUString& getType() const { return type_; }

private:
    virtual SAL_DLLPRIVATE ~TypedefEntity() noexcept override;

    OUString type_;
};

struct SAL_WARN_UNUSED LO_DLLPUBLIC_UNOIDL ConstantValue {
    enum Type {
        TYPE_BOOLEAN, TYPE_BYTE, TYPE_SHORT, TYPE_UNSIGNED_SHORT, TYPE_LONG,
        TYPE_UNSIGNED_LONG, TYPE_HYPER, TYPE_UNSIGNED_HYPER, TYPE_FLOAT,
        TYPE_DOUBLE };

    ConstantValue(bool value): type(TYPE_BOOLEAN), booleanValue(value) {}

    ConstantValue(sal_Int8 value): type(TYPE_BYTE), byteValue(value) {}

    ConstantValue(sal_Int16 value): type(TYPE_SHORT), shortValue(value) {}

    ConstantValue(sal_uInt16 value):
        type(TYPE_UNSIGNED_SHORT), unsignedShortValue(value)
    {}

    ConstantValue(sal_Int32 value): type(TYPE_LONG), longValue(value) {}

    ConstantValue(sal_uInt32 value):
        type(TYPE_UNSIGNED_LONG), unsignedLongValue(value)
    {}

    ConstantValue(sal_Int64 value): type(TYPE_HYPER), hyperValue(value) {}

    ConstantValue(sal_uInt64 value):
        type(TYPE_UNSIGNED_HYPER), unsignedHyperValue(value)
    {}

    ConstantValue(float value): type(TYPE_FLOAT), floatValue(value) {}

    ConstantValue(double value): type(TYPE_DOUBLE), doubleValue(value) {}

    Type type;

    union {
        bool booleanValue;
        sal_Int8 byteValue;
        sal_Int16 shortValue;
        sal_uInt16 unsignedShortValue;
        sal_Int32 longValue;
        sal_uInt32 unsignedLongValue;
        sal_Int64 hyperValue;
        sal_uInt64 unsignedHyperValue;
        float floatValue;
        double doubleValue;
    };
};

class SAL_WARN_UNUSED LO_DLLPUBLIC_UNOIDL ConstantGroupEntity final : public PublishableEntity {
public:
    struct Member {
        Member(
            OUString theName, ConstantValue const & theValue,
            std::vector< OUString >&& theAnnotations):
            name(std::move(theName)), value(theValue), annotations(std::move(theAnnotations))
        {}

        OUString name;

        ConstantValue value;

        std::vector< OUString > annotations;
    };

    SAL_DLLPRIVATE ConstantGroupEntity(
        bool published, std::vector< Member >&& members,
        std::vector< OUString >&& annotations):
        PublishableEntity(SORT_CONSTANT_GROUP, published, std::move(annotations)),
        members_(std::move(members))
    {}

    std::vector< Member > const & getMembers() const { return members_; }

private:
    virtual SAL_DLLPRIVATE ~ConstantGroupEntity() noexcept override;

    std::vector< Member > members_;
};

class SAL_WARN_UNUSED LO_DLLPUBLIC_UNOIDL SingleInterfaceBasedServiceEntity final :
    public PublishableEntity
{
public:
    struct Constructor {
        struct Parameter {
            Parameter(
                OUString theName, OUString theType,
                bool theRest):
                name(std::move(theName)), type(std::move(theType)), rest(theRest)
            {}

            OUString name;

            OUString type;

            bool rest;
        };

        Constructor():
            defaultConstructor(true) {}

        Constructor(
            OUString theName,
            std::vector< Parameter >&& theParameters,
            std::vector< OUString >&& theExceptions,
            std::vector< OUString >&& theAnnotations):
            name(std::move(theName)), parameters(std::move(theParameters)),
            exceptions(std::move(theExceptions)),
            annotations(std::move(theAnnotations)),
            defaultConstructor(false)
        {}

        OUString name;

        std::vector< Parameter > parameters;

        std::vector< OUString > exceptions;

        std::vector< OUString > annotations;

        bool defaultConstructor;
    };

    SAL_DLLPRIVATE SingleInterfaceBasedServiceEntity(
        bool published, OUString base,
        std::vector< Constructor >&& constructors,
        std::vector< OUString >&& annotations):
        PublishableEntity(
            SORT_SINGLE_INTERFACE_BASED_SERVICE, published, std::move(annotations)),
        base_(std::move(base)), constructors_(std::move(constructors))
    {}

    const OUString& getBase() const { return base_; }

    std::vector< Constructor > const & getConstructors() const
    { return constructors_; }

private:
    virtual SAL_DLLPRIVATE ~SingleInterfaceBasedServiceEntity() noexcept override;

    OUString base_;
    std::vector< Constructor > constructors_;
};

class SAL_WARN_UNUSED LO_DLLPUBLIC_UNOIDL AccumulationBasedServiceEntity final :
    public PublishableEntity
{
public:
    struct Property {
        enum Attributes {
            ATTRIBUTE_MAYBE_VOID = 0x001,
            ATTRIBUTE_BOUND = 0x002,
            ATTRIBUTE_CONSTRAINED = 0x004,
            ATTRIBUTE_TRANSIENT = 0x008,
            ATTRIBUTE_READ_ONLY = 0x010,
            ATTRIBUTE_MAYBE_AMBIGUOUS = 0x020,
            ATTRIBUTE_MAYBE_DEFAULT = 0x040,
            ATTRIBUTE_REMOVABLE = 0x080,
            ATTRIBUTE_OPTIONAL = 0x100
        };

        Property(
            OUString theName, OUString theType,
            Attributes theAttributes,
            std::vector< OUString >&& theAnnotations):
            name(std::move(theName)), type(std::move(theType)), attributes(theAttributes),
            annotations(std::move(theAnnotations))
        {}

        OUString name;

        OUString type;

        Attributes attributes;

        std::vector< OUString > annotations;
    };

    SAL_DLLPRIVATE AccumulationBasedServiceEntity(
        bool published,
        std::vector< AnnotatedReference >&& directMandatoryBaseServices,
        std::vector< AnnotatedReference >&& directOptionalBaseServices,
        std::vector< AnnotatedReference >&& directMandatoryBaseInterfaces,
        std::vector< AnnotatedReference >&& directOptionalBaseInterfaces,
        std::vector< Property >&& directProperties,
        std::vector< OUString >&& annotations):
        PublishableEntity(
            SORT_ACCUMULATION_BASED_SERVICE, published, std::move(annotations)),
        directMandatoryBaseServices_(std::move(directMandatoryBaseServices)),
        directOptionalBaseServices_(std::move(directOptionalBaseServices)),
        directMandatoryBaseInterfaces_(std::move(directMandatoryBaseInterfaces)),
        directOptionalBaseInterfaces_(std::move(directOptionalBaseInterfaces)),
        directProperties_(std::move(directProperties))
        {}

    std::vector< AnnotatedReference > const & getDirectMandatoryBaseServices()
        const
    { return directMandatoryBaseServices_; }

    std::vector< AnnotatedReference > const & getDirectOptionalBaseServices()
        const
    { return directOptionalBaseServices_; }

    std::vector< AnnotatedReference > const & getDirectMandatoryBaseInterfaces()
        const
    { return directMandatoryBaseInterfaces_; }

    std::vector< AnnotatedReference > const & getDirectOptionalBaseInterfaces()
        const
    { return directOptionalBaseInterfaces_; }

    std::vector< Property > const & getDirectProperties() const
    { return directProperties_; }

private:
    virtual SAL_DLLPRIVATE ~AccumulationBasedServiceEntity() noexcept override;

    std::vector< AnnotatedReference > directMandatoryBaseServices_;
    std::vector< AnnotatedReference > directOptionalBaseServices_;
    std::vector< AnnotatedReference > directMandatoryBaseInterfaces_;
    std::vector< AnnotatedReference > directOptionalBaseInterfaces_;
    std::vector< Property > directProperties_;
};

class LO_DLLPUBLIC_UNOIDL InterfaceBasedSingletonEntity final :
    public PublishableEntity
{
public:
    SAL_DLLPRIVATE InterfaceBasedSingletonEntity(
        bool published, OUString base,
        std::vector< OUString >&& annotations):
        PublishableEntity(
            SORT_INTERFACE_BASED_SINGLETON, published, std::move(annotations)),
        base_(std::move(base))
    {}

    const OUString& getBase() const { return base_; }

private:
    virtual SAL_DLLPRIVATE ~InterfaceBasedSingletonEntity() noexcept override;

    OUString base_;
};

class SAL_WARN_UNUSED LO_DLLPUBLIC_UNOIDL ServiceBasedSingletonEntity final : public PublishableEntity
{
public:
    SAL_DLLPRIVATE ServiceBasedSingletonEntity(
        bool published, OUString base,
        std::vector< OUString >&& annotations):
        PublishableEntity(SORT_SERVICE_BASED_SINGLETON, published, std::move(annotations)),
        base_(std::move(base))
    {}

    const OUString& getBase() const { return base_; }

private:
    virtual SAL_DLLPRIVATE ~ServiceBasedSingletonEntity() noexcept override;

    OUString base_;
};

class SAL_WARN_UNUSED LO_DLLPUBLIC_UNOIDL Provider: public salhelper::SimpleReferenceObject {
public:
    // throws FileFormatException:
    virtual rtl::Reference< MapCursor > createRootCursor() const = 0;

    // throws FileFormatException:
    virtual rtl::Reference< Entity > findEntity(OUString const & name)
        const = 0;

protected:
    SAL_DLLPRIVATE Provider() {}

    virtual SAL_DLLPRIVATE ~Provider() noexcept override;
};

class SAL_WARN_UNUSED LO_DLLPUBLIC_UNOIDL Manager final : public salhelper::SimpleReferenceObject {
public:
    Manager() {}

    // throws FileFormatException, NoSuchFileException:
    rtl::Reference< Provider > addProvider(OUString const & uri);

    // throws FileFormatException:
    rtl::Reference< Entity > findEntity(OUString const & name) const;

    // throws FileFormatException:
    rtl::Reference< MapCursor > createCursor(OUString const & name) const;

private:
    virtual SAL_DLLPRIVATE ~Manager() noexcept override;

    SAL_DLLPRIVATE rtl::Reference< Provider > loadProvider(
        OUString const & uri);

    mutable osl::Mutex mutex_;
    std::vector< rtl::Reference< Provider > > providers_;
};

}

#endif

/* vim:set shiftwidth=4 softtabstop=4 expandtab: */