1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
10 #ifndef INCLUDED_UNOIDL_UNOIDL_HXX
11 #define INCLUDED_UNOIDL_UNOIDL_HXX
13 #include <sal/config.h>
18 #include <osl/mutex.hxx>
19 #include <rtl/ref.hxx>
20 #include <rtl/ustring.hxx>
21 #include <sal/types.h>
22 #include <salhelper/simplereferenceobject.hxx>
23 #include <unoidl/detail/dllapi.hxx>
27 class LO_DLLPUBLIC_UNOIDL NoSuchFileException
{
29 SAL_DLLPRIVATE
NoSuchFileException(rtl::OUString
const & uri
): uri_(uri
) {}
31 SAL_DLLPRIVATE
NoSuchFileException(NoSuchFileException
const & other
):
34 virtual SAL_DLLPRIVATE
~NoSuchFileException() throw ();
36 rtl::OUString
getUri() const { return uri_
; }
39 void operator =(NoSuchFileException
) SAL_DELETED_FUNCTION
;
44 class LO_DLLPUBLIC_UNOIDL FileFormatException
{
46 SAL_DLLPRIVATE
FileFormatException(
47 rtl::OUString
const & uri
, rtl::OUString
const & detail
):
48 uri_(uri
), detail_(detail
)
51 SAL_DLLPRIVATE
FileFormatException(FileFormatException
const & other
):
52 uri_(other
.uri_
), detail_(other
.detail_
)
55 virtual SAL_DLLPRIVATE
~FileFormatException() throw ();
57 rtl::OUString
getUri() const { return uri_
; }
59 rtl::OUString
getDetail() const { return detail_
; }
62 void operator =(FileFormatException
) SAL_DELETED_FUNCTION
;
65 rtl::OUString detail_
;
68 struct AnnotatedReference
{
70 rtl::OUString
const & theName
,
71 std::vector
< rtl::OUString
> const & theAnnotations
):
72 name(theName
), annotations(theAnnotations
)
77 std::vector
< rtl::OUString
> annotations
;
80 class LO_DLLPUBLIC_UNOIDL Entity
: public salhelper::SimpleReferenceObject
{
83 SORT_MODULE
, SORT_ENUM_TYPE
, SORT_PLAIN_STRUCT_TYPE
,
84 SORT_POLYMORPHIC_STRUCT_TYPE_TEMPLATE
, SORT_EXCEPTION_TYPE
,
85 SORT_INTERFACE_TYPE
, SORT_TYPEDEF
, SORT_CONSTANT_GROUP
,
86 SORT_SINGLE_INTERFACE_BASED_SERVICE
, SORT_ACCUMULATION_BASED_SERVICE
,
87 SORT_INTERFACE_BASED_SINGLETON
, SORT_SERVICE_BASED_SINGLETON
90 Sort
getSort() const { return sort_
; }
93 explicit SAL_DLLPRIVATE
Entity(Sort sort
): sort_(sort
) {}
95 virtual SAL_DLLPRIVATE
~Entity() throw ();
101 class LO_DLLPUBLIC_UNOIDL MapCursor
: public salhelper::SimpleReferenceObject
{
103 // throws FileFormatException:
104 virtual rtl::Reference
< Entity
> getNext(rtl::OUString
* name
) = 0;
107 SAL_DLLPRIVATE
MapCursor() {}
109 virtual SAL_DLLPRIVATE
~MapCursor() throw();
112 class LO_DLLPUBLIC_UNOIDL ModuleEntity
: public Entity
{
114 // throws FileFormatException:
115 virtual std::vector
< rtl::OUString
> getMemberNames() const = 0;
117 // throws FileFormatException:
118 virtual rtl::Reference
< MapCursor
> createCursor() const = 0;
121 SAL_DLLPRIVATE
ModuleEntity(): Entity(SORT_MODULE
) {}
123 virtual SAL_DLLPRIVATE
~ModuleEntity() throw ();
126 class LO_DLLPUBLIC_UNOIDL PublishableEntity
: public Entity
{
128 bool isPublished() const { return published_
; }
130 std::vector
< rtl::OUString
> const & getAnnotations() const
131 { return annotations_
; }
134 SAL_DLLPRIVATE
PublishableEntity(
135 Sort sort
, bool published
,
136 std::vector
< rtl::OUString
> const & annotations
):
137 Entity(sort
), published_(published
), annotations_(annotations
)
140 virtual SAL_DLLPRIVATE
~PublishableEntity() throw ();
145 std::vector
< rtl::OUString
> annotations_
;
148 class LO_DLLPUBLIC_UNOIDL EnumTypeEntity
: public PublishableEntity
{
152 rtl::OUString
const & theName
, sal_Int32 theValue
,
153 std::vector
< rtl::OUString
> const & theAnnotations
):
154 name(theName
), value(theValue
), annotations(theAnnotations
)
161 std::vector
< rtl::OUString
> annotations
;
164 SAL_DLLPRIVATE
EnumTypeEntity(
165 bool published
, std::vector
< Member
> const & members
,
166 std::vector
< rtl::OUString
> const & annotations
):
167 PublishableEntity(SORT_ENUM_TYPE
, published
, annotations
),
169 { assert(!members
.empty()); }
171 std::vector
< Member
> const & getMembers() const { return members_
; }
174 virtual SAL_DLLPRIVATE
~EnumTypeEntity() throw ();
176 std::vector
< Member
> members_
;
179 class LO_DLLPUBLIC_UNOIDL PlainStructTypeEntity
: public PublishableEntity
{
182 Member(rtl::OUString
const & theName
, rtl::OUString
const & theType
,
183 std::vector
< rtl::OUString
> const & theAnnotations
):
184 name(theName
), type(theType
), annotations(theAnnotations
)
191 std::vector
< rtl::OUString
> annotations
;
194 SAL_DLLPRIVATE
PlainStructTypeEntity(
195 bool published
, rtl::OUString
const & directBase
,
196 std::vector
< Member
> const & directMembers
,
197 std::vector
< rtl::OUString
> const & annotations
):
198 PublishableEntity(SORT_PLAIN_STRUCT_TYPE
, published
, annotations
),
199 directBase_(directBase
), directMembers_(directMembers
)
202 rtl::OUString
getDirectBase() const { return directBase_
; }
204 std::vector
< Member
> const & getDirectMembers() const
205 { return directMembers_
; }
208 virtual SAL_DLLPRIVATE
~PlainStructTypeEntity() throw ();
210 rtl::OUString directBase_
;
211 std::vector
< Member
> directMembers_
;
214 class LO_DLLPUBLIC_UNOIDL PolymorphicStructTypeTemplateEntity
:
215 public PublishableEntity
220 rtl::OUString
const & theName
, rtl::OUString
const & theType
,
221 bool theParameterized
,
222 std::vector
< rtl::OUString
> const & theAnnotations
):
223 name(theName
), type(theType
), parameterized(theParameterized
),
224 annotations(theAnnotations
)
233 std::vector
< rtl::OUString
> annotations
;
236 SAL_DLLPRIVATE
PolymorphicStructTypeTemplateEntity(
237 bool published
, std::vector
< rtl::OUString
> const & typeParameters
,
238 std::vector
< Member
> const & members
,
239 std::vector
< rtl::OUString
> const & annotations
):
241 SORT_POLYMORPHIC_STRUCT_TYPE_TEMPLATE
, published
, annotations
),
242 typeParameters_(typeParameters
), members_(members
)
245 std::vector
< rtl::OUString
> const & getTypeParameters() const
246 { return typeParameters_
; }
248 std::vector
< Member
> const & getMembers() const { return members_
; }
251 virtual SAL_DLLPRIVATE
~PolymorphicStructTypeTemplateEntity() throw ();
253 std::vector
< rtl::OUString
> typeParameters_
;
254 std::vector
< Member
> members_
;
257 class LO_DLLPUBLIC_UNOIDL ExceptionTypeEntity
: public PublishableEntity
{
261 rtl::OUString
const & theName
, rtl::OUString
const & theType
,
262 std::vector
< rtl::OUString
> const & theAnnotations
):
263 name(theName
), type(theType
), annotations(theAnnotations
)
270 std::vector
< rtl::OUString
> annotations
;
273 SAL_DLLPRIVATE
ExceptionTypeEntity(
274 bool published
, rtl::OUString
const & directBase
,
275 std::vector
< Member
> const & directMembers
,
276 std::vector
< rtl::OUString
> const & annotations
):
277 PublishableEntity(SORT_EXCEPTION_TYPE
, published
, annotations
),
278 directBase_(directBase
), directMembers_(directMembers
)
281 rtl::OUString
getDirectBase() const { return directBase_
; }
283 std::vector
< Member
> const & getDirectMembers() const
284 { return directMembers_
; }
287 virtual SAL_DLLPRIVATE
~ExceptionTypeEntity() throw ();
289 rtl::OUString directBase_
;
290 std::vector
< Member
> directMembers_
;
293 class LO_DLLPUBLIC_UNOIDL InterfaceTypeEntity
: public PublishableEntity
{
297 rtl::OUString
const & theName
, rtl::OUString
const & theType
,
298 bool theBound
, bool theReadOnly
,
299 std::vector
< rtl::OUString
> const & theGetExceptions
,
300 std::vector
< rtl::OUString
> const & theSetExceptions
,
301 std::vector
< rtl::OUString
> const & theAnnotations
):
302 name(theName
), type(theType
), bound(theBound
),
303 readOnly(theReadOnly
), getExceptions(theGetExceptions
),
304 setExceptions(theSetExceptions
), annotations(theAnnotations
)
305 { assert(!theReadOnly
|| theSetExceptions
.empty()); }
315 std::vector
< rtl::OUString
> getExceptions
;
317 std::vector
< rtl::OUString
> setExceptions
;
319 std::vector
< rtl::OUString
> annotations
;
324 enum Direction
{ DIRECTION_IN
, DIRECTION_OUT
, DIRECTION_IN_OUT
};
327 rtl::OUString
const & theName
, rtl::OUString
const & theType
,
328 Direction theDirection
):
329 name(theName
), type(theType
), direction(theDirection
)
340 rtl::OUString
const & theName
, rtl::OUString
const & theReturnType
,
341 std::vector
< Parameter
> const & theParameters
,
342 std::vector
< rtl::OUString
> const & theExceptions
,
343 std::vector
< rtl::OUString
> const & theAnnotations
):
344 name(theName
), returnType(theReturnType
), parameters(theParameters
),
345 exceptions(theExceptions
), annotations(theAnnotations
)
350 rtl::OUString returnType
;
352 std::vector
< Parameter
> parameters
;
354 std::vector
< rtl::OUString
> exceptions
;
356 std::vector
< rtl::OUString
> annotations
;
359 SAL_DLLPRIVATE
InterfaceTypeEntity(
361 std::vector
< AnnotatedReference
> const & directMandatoryBases
,
362 std::vector
< AnnotatedReference
> const & directOptionalBases
,
363 std::vector
< Attribute
> const & directAttributes
,
364 std::vector
< Method
> const & directMethods
,
365 std::vector
< rtl::OUString
> const & annotations
):
366 PublishableEntity(SORT_INTERFACE_TYPE
, published
, annotations
),
367 directMandatoryBases_(directMandatoryBases
),
368 directOptionalBases_(directOptionalBases
),
369 directAttributes_(directAttributes
), directMethods_(directMethods
)
372 std::vector
< AnnotatedReference
> const & getDirectMandatoryBases() const
373 { return directMandatoryBases_
; }
375 std::vector
< AnnotatedReference
> const & getDirectOptionalBases() const
376 { return directOptionalBases_
; }
378 std::vector
< Attribute
> const & getDirectAttributes() const
379 { return directAttributes_
; }
381 std::vector
< Method
> const & getDirectMethods() const
382 { return directMethods_
; }
385 virtual SAL_DLLPRIVATE
~InterfaceTypeEntity() throw ();
387 std::vector
< AnnotatedReference
> directMandatoryBases_
;
388 std::vector
< AnnotatedReference
> directOptionalBases_
;
389 std::vector
< Attribute
> directAttributes_
;
390 std::vector
< Method
> directMethods_
;
393 class LO_DLLPUBLIC_UNOIDL TypedefEntity
: public PublishableEntity
{
395 SAL_DLLPRIVATE
TypedefEntity(
396 bool published
, rtl::OUString
const & type
,
397 std::vector
< rtl::OUString
> const & annotations
):
398 PublishableEntity(SORT_TYPEDEF
, published
, annotations
), type_(type
)
401 rtl::OUString
getType() const { return type_
; }
404 virtual SAL_DLLPRIVATE
~TypedefEntity() throw ();
409 struct LO_DLLPUBLIC_UNOIDL ConstantValue
{
411 TYPE_BOOLEAN
, TYPE_BYTE
, TYPE_SHORT
, TYPE_UNSIGNED_SHORT
, TYPE_LONG
,
412 TYPE_UNSIGNED_LONG
, TYPE_HYPER
, TYPE_UNSIGNED_HYPER
, TYPE_FLOAT
,
415 ConstantValue(bool value
): type(TYPE_BOOLEAN
), booleanValue(value
) {}
417 ConstantValue(sal_Int8 value
): type(TYPE_BYTE
), byteValue(value
) {}
419 ConstantValue(sal_Int16 value
): type(TYPE_SHORT
), shortValue(value
) {}
421 ConstantValue(sal_uInt16 value
):
422 type(TYPE_UNSIGNED_SHORT
), unsignedShortValue(value
)
425 ConstantValue(sal_Int32 value
): type(TYPE_LONG
), longValue(value
) {}
427 ConstantValue(sal_uInt32 value
):
428 type(TYPE_UNSIGNED_LONG
), unsignedLongValue(value
)
431 ConstantValue(sal_Int64 value
): type(TYPE_HYPER
), hyperValue(value
) {}
433 ConstantValue(sal_uInt64 value
):
434 type(TYPE_UNSIGNED_HYPER
), unsignedHyperValue(value
)
437 ConstantValue(float value
): type(TYPE_FLOAT
), floatValue(value
) {}
439 ConstantValue(double value
): type(TYPE_DOUBLE
), doubleValue(value
) {}
446 sal_Int16 shortValue
;
447 sal_uInt16 unsignedShortValue
;
449 sal_uInt32 unsignedLongValue
;
450 sal_Int64 hyperValue
;
451 sal_uInt64 unsignedHyperValue
;
457 class LO_DLLPUBLIC_UNOIDL ConstantGroupEntity
: public PublishableEntity
{
461 rtl::OUString
const & theName
, ConstantValue
const & theValue
,
462 std::vector
< rtl::OUString
> const & theAnnotations
):
463 name(theName
), value(theValue
), annotations(theAnnotations
)
470 std::vector
< rtl::OUString
> annotations
;
473 SAL_DLLPRIVATE
ConstantGroupEntity(
474 bool published
, std::vector
< Member
> const & members
,
475 std::vector
< rtl::OUString
> const & annotations
):
476 PublishableEntity(SORT_CONSTANT_GROUP
, published
, annotations
),
480 std::vector
< Member
> const & getMembers() const { return members_
; }
483 virtual SAL_DLLPRIVATE
~ConstantGroupEntity() throw ();
485 std::vector
< Member
> members_
;
488 class LO_DLLPUBLIC_UNOIDL SingleInterfaceBasedServiceEntity
:
489 public PublishableEntity
495 rtl::OUString
const & theName
, rtl::OUString
const & theType
,
497 name(theName
), type(theType
), rest(theRest
)
507 Constructor(): defaultConstructor(true) {}
510 rtl::OUString
const & theName
,
511 std::vector
< Parameter
> const & theParameters
,
512 std::vector
< rtl::OUString
> const & theExceptions
,
513 std::vector
< rtl::OUString
> const & theAnnotations
):
514 name(theName
), parameters(theParameters
), exceptions(theExceptions
),
515 annotations(theAnnotations
), defaultConstructor(false)
520 std::vector
< Parameter
> parameters
;
522 std::vector
< rtl::OUString
> exceptions
;
524 std::vector
< rtl::OUString
> annotations
;
526 bool defaultConstructor
;
529 SAL_DLLPRIVATE
SingleInterfaceBasedServiceEntity(
530 bool published
, rtl::OUString
const & base
,
531 std::vector
< Constructor
> const & constructors
,
532 std::vector
< rtl::OUString
> const & annotations
):
534 SORT_SINGLE_INTERFACE_BASED_SERVICE
, published
, annotations
),
535 base_(base
), constructors_(constructors
)
538 rtl::OUString
getBase() const { return base_
; }
540 std::vector
< Constructor
> const & getConstructors() const
541 { return constructors_
; }
544 virtual SAL_DLLPRIVATE
~SingleInterfaceBasedServiceEntity() throw ();
547 std::vector
< Constructor
> constructors_
;
550 class LO_DLLPUBLIC_UNOIDL AccumulationBasedServiceEntity
:
551 public PublishableEntity
556 ATTRIBUTE_MAYBE_VOID
= 0x001,
557 ATTRIBUTE_BOUND
= 0x002,
558 ATTRIBUTE_CONSTRAINED
= 0x004,
559 ATTRIBUTE_TRANSIENT
= 0x008,
560 ATTRIBUTE_READ_ONLY
= 0x010,
561 ATTRIBUTE_MAYBE_AMBIGUOUS
= 0x020,
562 ATTRIBUTE_MAYBE_DEFAULT
= 0x040,
563 ATTRIBUTE_REMOVABLE
= 0x080,
564 ATTRIBUTE_OPTIONAL
= 0x100
568 rtl::OUString
const & theName
, rtl::OUString
const & theType
,
569 Attributes theAttributes
,
570 std::vector
< rtl::OUString
> const & theAnnotations
):
571 name(theName
), type(theType
), attributes(theAttributes
),
572 annotations(theAnnotations
)
579 Attributes attributes
;
581 std::vector
< rtl::OUString
> annotations
;
584 SAL_DLLPRIVATE
AccumulationBasedServiceEntity(
586 std::vector
< AnnotatedReference
> const & directMandatoryBaseServices
,
587 std::vector
< AnnotatedReference
> const & directOptionalBaseServices
,
588 std::vector
< AnnotatedReference
> const & directMandatoryBaseInterfaces
,
589 std::vector
< AnnotatedReference
> const & directOptionalBaseInterfaces
,
590 std::vector
< Property
> const & directProperties
,
591 std::vector
< rtl::OUString
> const & annotations
):
593 SORT_ACCUMULATION_BASED_SERVICE
, published
, annotations
),
594 directMandatoryBaseServices_(directMandatoryBaseServices
),
595 directOptionalBaseServices_(directOptionalBaseServices
),
596 directMandatoryBaseInterfaces_(directMandatoryBaseInterfaces
),
597 directOptionalBaseInterfaces_(directOptionalBaseInterfaces
),
598 directProperties_(directProperties
)
601 std::vector
< AnnotatedReference
> const & getDirectMandatoryBaseServices()
603 { return directMandatoryBaseServices_
; }
605 std::vector
< AnnotatedReference
> const & getDirectOptionalBaseServices()
607 { return directOptionalBaseServices_
; }
609 std::vector
< AnnotatedReference
> const & getDirectMandatoryBaseInterfaces()
611 { return directMandatoryBaseInterfaces_
; }
613 std::vector
< AnnotatedReference
> const & getDirectOptionalBaseInterfaces()
615 { return directOptionalBaseInterfaces_
; }
617 std::vector
< Property
> const & getDirectProperties() const
618 { return directProperties_
; }
621 virtual SAL_DLLPRIVATE
~AccumulationBasedServiceEntity() throw ();
623 std::vector
< AnnotatedReference
> directMandatoryBaseServices_
;
624 std::vector
< AnnotatedReference
> directOptionalBaseServices_
;
625 std::vector
< AnnotatedReference
> directMandatoryBaseInterfaces_
;
626 std::vector
< AnnotatedReference
> directOptionalBaseInterfaces_
;
627 std::vector
< Property
> directProperties_
;
630 class LO_DLLPUBLIC_UNOIDL InterfaceBasedSingletonEntity
:
631 public PublishableEntity
634 SAL_DLLPRIVATE
InterfaceBasedSingletonEntity(
635 bool published
, rtl::OUString
const & base
,
636 std::vector
< rtl::OUString
> const & annotations
):
638 SORT_INTERFACE_BASED_SINGLETON
, published
, annotations
),
642 rtl::OUString
getBase() const { return base_
; }
645 virtual SAL_DLLPRIVATE
~InterfaceBasedSingletonEntity() throw ();
650 class LO_DLLPUBLIC_UNOIDL ServiceBasedSingletonEntity
: public PublishableEntity
653 SAL_DLLPRIVATE
ServiceBasedSingletonEntity(
654 bool published
, rtl::OUString
const & base
,
655 std::vector
< rtl::OUString
> const & annotations
):
656 PublishableEntity(SORT_SERVICE_BASED_SINGLETON
, published
, annotations
),
660 rtl::OUString
getBase() const { return base_
; }
663 virtual SAL_DLLPRIVATE
~ServiceBasedSingletonEntity() throw ();
668 class LO_DLLPUBLIC_UNOIDL Provider
: public salhelper::SimpleReferenceObject
{
670 // throws FileFormatException:
671 virtual rtl::Reference
< MapCursor
> createRootCursor() const = 0;
673 // throws FileFormatException:
674 virtual rtl::Reference
< Entity
> findEntity(rtl::OUString
const & name
)
678 SAL_DLLPRIVATE
Provider() {}
680 virtual SAL_DLLPRIVATE
~Provider() throw ();
683 class LO_DLLPUBLIC_UNOIDL Manager
: public salhelper::SimpleReferenceObject
{
687 // throws FileFormatException, NoSuchFileException:
688 rtl::Reference
< Provider
> addProvider(rtl::OUString
const & uri
);
690 // throws FileFormatException:
691 rtl::Reference
< Entity
> findEntity(rtl::OUString
const & name
) const;
693 // throws FileFormatException:
694 rtl::Reference
< MapCursor
> createCursor(rtl::OUString
const & name
) const;
697 virtual SAL_DLLPRIVATE
~Manager() throw ();
699 SAL_DLLPRIVATE
rtl::Reference
< Provider
> loadProvider(
700 rtl::OUString
const & uri
);
702 mutable osl::Mutex mutex_
;
703 std::vector
< rtl::Reference
< Provider
> > providers_
;
710 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */