#region CPL License /* Nuclex Framework Copyright (C) 2002-2009 Nuclex Development Labs This library is free software; you can redistribute it and/or modify it under the terms of the IBM Common Public License as published by the IBM Corporation; either version 1.0 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the IBM Common Public License for more details. You should have received a copy of the IBM Common Public License along with this library */ #endregion using System; using Microsoft.Xna.Framework; namespace Nuclex.Geometry.Areas { /// Base class for area visitors /// /// See the visitor pattern. /// /// If you need to perform work on a area whose type you do not know, you could /// of course just create a set of if(area is ...) queries. However, you would /// have to manually track down all these queries should a future version of this /// library provide a new type of volume. /// /// /// Your other option is to create a special class that does your work which derives /// from this AreaVisitor class. It will elegantly resolve the area type by /// calling into the area (resolving the type via the vtable) which then calls /// the visitor's distinctive method for the exact kind of area. If a new area /// is introduced to the library, it will be added to the AreaVisitor class and /// your compiler will point out to you where you need to extend your code for the /// new kind of area because the abstract method will not yet be implemented there. /// /// public interface IArea2Visitor { /// Visit an axis aligned rectangle /// Axis aligned rectangle to visit void Visit(AxisAlignedRectangle2 rectangle); /// Visit a rectangle /// Rectangle to visit void Visit(Rectangle2 rectangle); /// Visit a triangle /// Triangle to visit void Visit(Triangle2 triangle); /// Visit a disc /// Disc to visit void Visit(Disc2 disc); } } // namespace Nuclex.Geometry.Areas