Mercurial > projects > dwt-addons
diff dwtx/core/runtime/PlatformObject.d @ 122:9d0585bcb7aa
Add core.jobs package
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Tue, 12 Aug 2008 02:34:21 +0200 |
parents | |
children | 3d684126a966 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwtx/core/runtime/PlatformObject.d Tue Aug 12 02:34:21 2008 +0200 @@ -0,0 +1,75 @@ +/******************************************************************************* + * Copyright (c) 2000, 2006 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + * Port to the D programming language: + * Frank Benoit <benoit@tionex.de> + *******************************************************************************/ +module dwtx.core.runtime.PlatformObject; + +import dwt.dwthelper.utils; + +import dwtx.core.runtime.IAdaptable; +// import dwtx.core.internal.runtime.AdapterManager; + +/** + * An abstract superclass implementing the <code>IAdaptable</code> + * interface. <code>getAdapter</code> invocations are directed + * to the platform's adapter manager. + * <p> + * Note: In situations where it would be awkward to subclass this + * class, the same affect can be achieved simply by implementing + * the {@link IAdaptable} interface and explicitly forwarding + * the <code>getAdapter</code> request to an implementation + * of the {@link IAdapterManager} service. The method would look like: + * <pre> + * public Object getAdapter(Class adapter) { + * IAdapterManager manager = ...;//lookup the IAdapterManager service + * return manager.getAdapter(this, adapter); + * } + * </pre> + * </p><p> + * This class can be used without OSGi running. + * </p><p> + * Clients may subclass. + * </p> + * + * @see IAdapterManager + * @see IAdaptable + */ +public abstract class PlatformObject : IAdaptable { + /** + * Constructs a new platform object. + */ + public this() { + super(); + } + + /** + * Returns an object which is an instance of the given class + * associated with this object. Returns <code>null</code> if + * no such object can be found. + * <p> + * This implementation of the method declared by <code>IAdaptable</code> + * passes the request along to the platform's adapter manager; roughly + * <code>Platform.getAdapterManager().getAdapter(this, adapter)</code>. + * Subclasses may override this method (however, if they do so, they + * should invoke the method on their superclass to ensure that the + * Platform's adapter manager is consulted). + * </p> + * + * @param adapter the class to adapt to + * @return the adapted object or <code>null</code> + * @see IAdaptable#getAdapter(Class) + */ + public Object getAdapter(ClassInfo adapter) { + implMissing( __FILE__, __LINE__ ); + return null; +// return AdapterManager.getDefault().getAdapter(this, adapter); + } +}