1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: cli_environment.h,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #if ! defined INCLUDED_CLI_ENVIRONMENT_H
32 #define INCLUDED_CLI_ENVIRONMENT_H
37 using namespace System
;
38 using namespace System::Collections
;
39 using namespace System::Runtime::Serialization
;
44 public __gc
class Cli_environment
46 static System::String
* sOidPart
;
47 static Hashtable
* m_objects
;
48 static System::Runtime::Serialization::ObjectIDGenerator
* m_IDGen
;
49 inline static System::String
* createKey(System::String
* oid
, System::Type
* t
);
51 #if OSL_DEBUG_LEVEL >= 1
52 int _numRegisteredObjects
;
57 static Cli_environment()
59 m_objects
= Hashtable::Synchronized(new Hashtable());
60 m_IDGen
= new System::Runtime::Serialization::ObjectIDGenerator();
61 System::Text::StringBuilder
* buffer
= new System::Text::StringBuilder(256);
62 Guid gd
= Guid::NewGuid();
63 buffer
->Append(S
";cli[0];");
64 buffer
->Append(gd
.ToString());
65 sOidPart
= buffer
->ToString();
68 inline Cli_environment();
73 Registers an UNO object as being mapped by this bridge. The resulting
74 cli object is represents all interfaces of the UNO object. Therefore the
75 object can be registered only with its OID; a type is not necessary.
77 Object
* registerInterface(Object
* obj
, System::String
* oid
);
79 Registers a CLI object as being mapped by this bridge. The resulting
80 object represents exactly one UNO interface.
82 Object
* registerInterface(Object
* obj
, System::String
* oid
, System::Type
* type
);
85 By revoking an interface it is declared that the respective interface has
86 not been mapped. The proxy implementations call revoke interface in their
89 inline void revokeInterface(System::String
* oid
);
91 void revokeInterface(System::String
* oid
, System::Type
* type
);
93 * Retrieves an interface identified by its object id and type from this
96 * @param oid object id of interface to be retrieved
97 * @param type the type description of the interface to be retrieved
98 * @see com.sun.star.uno.IEnvironment#getRegisteredInterface
100 Object
* getRegisteredInterface(System::String
* oid
, System::Type
* type
);
103 * Generates a worldwide unique object identifier (oid) for the given object. It is
104 * guaranteed, that subsequent calls to the method with the same object
105 * will give the same id.
107 * @return the generated oid.
108 * @param object the object for which a Oid should be generated.
110 static System::String
* getObjectIdentifier(Object
* obj
);
114 } //namespace cli_uno