Version 6.4.0.0.beta1, tag libreoffice-6.4.0.0.beta1
[LibreOffice.git] / cli_ure / source / uno_bridge / cli_environment.h
blobdb220d32d1fc23ce41e92f6af443b5245b84892d
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #ifndef INCLUDED_CLI_URE_SOURCE_UNO_BRIDGE_CLI_ENVIRONMENT_H
21 #define INCLUDED_CLI_URE_SOURCE_UNO_BRIDGE_CLI_ENVIRONMENT_H
23 #include "cli_base.h"
25 using namespace System;
26 using namespace System::Collections;
27 using namespace System::Runtime::Serialization;
29 namespace cli_uno
32 public ref class Cli_environment
34 static System::String^ sOidPart;
35 static Hashtable^ m_objects;
36 static System::Runtime::Serialization::ObjectIDGenerator^ m_IDGen;
37 inline static System::String^ createKey(System::String^ oid, System::Type^ t);
39 #if OSL_DEBUG_LEVEL >= 1
40 int _numRegisteredObjects;
41 #endif
43 static Cli_environment()
45 m_objects = Hashtable::Synchronized(gcnew Hashtable());
46 m_IDGen = gcnew System::Runtime::Serialization::ObjectIDGenerator();
47 System::Text::StringBuilder^ buffer = gcnew System::Text::StringBuilder(256);
48 Guid gd = Guid::NewGuid();
49 buffer->Append(";cli[0];");
50 buffer->Append(gd.ToString());
51 sOidPart = buffer->ToString();
54 public:
56 inline Cli_environment();
58 ~Cli_environment();
59 !Cli_environment();
61 /**
62 Registers a UNO object as being mapped by this bridge. The resulting
63 cli object is represents all interfaces of the UNO object. Therefore the
64 object can be registered only with its OID; a type is not necessary.
66 Object^ registerInterface(Object^ obj, System::String^ oid);
67 /**
68 Registers a CLI object as being mapped by this bridge. The resulting
69 object represents exactly one UNO interface.
71 Object^ registerInterface(Object^ obj, System::String^ oid, System::Type^ type);
73 /**
74 By revoking an interface it is declared that the respective interface has
75 not been mapped. The proxy implementations call revoke interface in their
76 destructors.
78 inline void revokeInterface(System::String^ oid);
80 void revokeInterface(System::String^ oid, System::Type^ type);
81 /**
82 * Retrieves an interface identified by its object id and type from this
83 * environment.
85 * @param oid object id of interface to be retrieved
86 * @param type the type description of the interface to be retrieved
87 * @see com.sun.star.uno.IEnvironment#getRegisteredInterface
89 Object^ getRegisteredInterface(System::String^ oid, System::Type^ type);
91 /**
92 * Generates a worldwide unique object identifier (oid) for the given object. It is
93 * guaranteed, that subsequent calls to the method with the same object
94 * will give the same id.
95 * <p>
96 * @return the generated oid.
97 * @param object the object for which an Oid should be generated.
99 static System::String^ getObjectIdentifier(Object^ obj);
103 } //namespace cli_uno
106 #endif
108 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */