1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
11 * OpenOffice.org is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License version 3
13 * only, as published by the Free Software Foundation.
15 * OpenOffice.org is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License version 3 for more details
19 * (a copy is included in the LICENSE file that accompanied this code).
21 * You should have received a copy of the GNU Lesser General Public License
22 * version 3 along with OpenOffice.org. If not, see
23 * <http://www.openoffice.org/license.html>
24 * for a copy of the LGPLv3 License.
26 ************************************************************************/
28 #if ! defined INCLUDED_CLI_ENVIRONMENT_H
29 #define INCLUDED_CLI_ENVIRONMENT_H
34 using namespace System
;
35 using namespace System::Collections
;
36 using namespace System::Runtime::Serialization
;
41 public __gc
class Cli_environment
43 static System::String
* sOidPart
;
44 static Hashtable
* m_objects
;
45 static System::Runtime::Serialization::ObjectIDGenerator
* m_IDGen
;
46 inline static System::String
* createKey(System::String
* oid
, System::Type
* t
);
48 #if OSL_DEBUG_LEVEL >= 1
49 int _numRegisteredObjects
;
54 static Cli_environment()
56 m_objects
= Hashtable::Synchronized(new Hashtable());
57 m_IDGen
= new System::Runtime::Serialization::ObjectIDGenerator();
58 System::Text::StringBuilder
* buffer
= new System::Text::StringBuilder(256);
59 Guid gd
= Guid::NewGuid();
60 buffer
->Append(S
";cli[0];");
61 buffer
->Append(gd
.ToString());
62 sOidPart
= buffer
->ToString();
65 inline Cli_environment();
70 Registers an UNO object as being mapped by this bridge. The resulting
71 cli object is represents all interfaces of the UNO object. Therefore the
72 object can be registered only with its OID; a type is not necessary.
74 Object
* registerInterface(Object
* obj
, System::String
* oid
);
76 Registers a CLI object as being mapped by this bridge. The resulting
77 object represents exactly one UNO interface.
79 Object
* registerInterface(Object
* obj
, System::String
* oid
, System::Type
* type
);
82 By revoking an interface it is declared that the respective interface has
83 not been mapped. The proxy implementations call revoke interface in their
86 inline void revokeInterface(System::String
* oid
);
88 void revokeInterface(System::String
* oid
, System::Type
* type
);
90 * Retrieves an interface identified by its object id and type from this
93 * @param oid object id of interface to be retrieved
94 * @param type the type description of the interface to be retrieved
95 * @see com.sun.star.uno.IEnvironment#getRegisteredInterface
97 Object
* getRegisteredInterface(System::String
* oid
, System::Type
* type
);
100 * Generates a worldwide unique object identifier (oid) for the given object. It is
101 * guaranteed, that subsequent calls to the method with the same object
102 * will give the same id.
104 * @return the generated oid.
105 * @param object the object for which a Oid should be generated.
107 static System::String
* getObjectIdentifier(Object
* obj
);
111 } //namespace cli_uno