Version 3.6.0.4, tag libreoffice-3.6.0.4
[LibreOffice.git] / cli_ure / source / uno_bridge / cli_environment.h
bloba10692390c7c4e69f5fb22bcdf0debc1bc1ad791
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
12 * OpenOffice.org is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License version 3
14 * only, as published by the Free Software Foundation.
16 * OpenOffice.org is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Lesser General Public License version 3 for more details
20 * (a copy is included in the LICENSE file that accompanied this code).
22 * You should have received a copy of the GNU Lesser General Public License
23 * version 3 along with OpenOffice.org. If not, see
24 * <http://www.openoffice.org/license.html>
25 * for a copy of the LGPLv3 License.
27 ************************************************************************/
29 #if ! defined INCLUDED_CLI_ENVIRONMENT_H
30 #define INCLUDED_CLI_ENVIRONMENT_H
32 #include "cli_base.h"
33 #using <mscorlib.dll>
35 using namespace System;
36 using namespace System::Collections;
37 using namespace System::Runtime::Serialization;
39 namespace cli_uno
42 public __gc class Cli_environment
44 static System::String* sOidPart;
45 static Hashtable* m_objects;
46 static System::Runtime::Serialization::ObjectIDGenerator* m_IDGen;
47 inline static System::String* createKey(System::String* oid, System::Type* t);
49 #if OSL_DEBUG_LEVEL >= 1
50 int _numRegisteredObjects;
51 #endif
53 public:
55 static Cli_environment()
57 m_objects = Hashtable::Synchronized(new Hashtable());
58 m_IDGen = new System::Runtime::Serialization::ObjectIDGenerator();
59 System::Text::StringBuilder* buffer = new System::Text::StringBuilder(256);
60 Guid gd = Guid::NewGuid();
61 buffer->Append(S";cli[0];");
62 buffer->Append(gd.ToString());
63 sOidPart = buffer->ToString();
66 inline Cli_environment();
68 ~Cli_environment();
70 /**
71 Registers an UNO object as being mapped by this bridge. The resulting
72 cli object is represents all interfaces of the UNO object. Therefore the
73 object can be registered only with its OID; a type is not necessary.
75 Object* registerInterface(Object* obj, System::String* oid);
76 /**
77 Registers a CLI object as being mapped by this bridge. The resulting
78 object represents exactly one UNO interface.
80 Object* registerInterface(Object* obj, System::String* oid, System::Type* type);
82 /**
83 By revoking an interface it is declared that the respective interface has
84 not been mapped. The proxy implementations call revoke interface in their
85 destructors.
87 inline void revokeInterface(System::String* oid);
89 void revokeInterface(System::String* oid, System::Type* type);
90 /**
91 * Retrieves an interface identified by its object id and type from this
92 * environment.
94 * @param oid object id of interface to be retrieved
95 * @param type the type description of the interface to be retrieved
96 * @see com.sun.star.uno.IEnvironment#getRegisteredInterface
98 Object* getRegisteredInterface(System::String* oid, System::Type* type);
101 * Generates a worldwide unique object identifier (oid) for the given object. It is
102 * guaranteed, that subsequent calls to the method with the same object
103 * will give the same id.
104 * <p>
105 * @return the generated oid.
106 * @param object the object for which a Oid should be generated.
108 static System::String* getObjectIdentifier(Object* obj);
112 } //namespace cli_uno
115 #endif
117 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */