TypeAwareObject.h

Go to the documentation of this file.
00001 /*
00002  * The information in this file is
00003  * Copyright(c) 2007 Ball Aerospace & Technologies Corporation
00004  * and is subject to the terms and conditions of the
00005  * GNU Lesser General Public License Version 2.1
00006  * The license text is available from   
00007  * http://www.gnu.org/licenses/lgpl.html
00008  */
00009 
00010 #ifndef __TYPAWROB_H
00011 #define __TYPAWROB_H
00012 
00013 #include <string>
00014 
00015 /**
00016  *  Base class for objects to store class inheritance hierarchy.
00017  *
00018  *  TypeAwareObject is an interface used to provide RTTI-like
00019  *  capability without having to compile with RTTI overhead. It
00020  *  provides several methods that must be implemented by all
00021  *  classes derived from it, even if intermediate parent classes
00022  *  have already implemented the obligations.
00023  */
00024 class TypeAwareObject
00025 {
00026 public:
00027    /** 
00028     *  Returns a string containing the class name.
00029     *
00030     *  Must be implemented by all subclasses.
00031     *
00032     *  @return  A string containing the name of the class.
00033     */
00034    virtual const std::string& getObjectType() const = 0;
00035 
00036    /**
00037     *  Compares an incoming argument string against either the object's
00038     *  true class name or one of its parent (inherited) class names.
00039     *
00040     *  @param   className
00041     *           Name of the class that is to be searched for in the object's
00042     *           inheritance hierarchy.
00043     *
00044     *  @return  True if the object's class, or something it can safely be
00045     *           cast to, matches the incoming argument.
00046     */
00047    virtual bool isKindOf(const std::string& className) const = 0;
00048 
00049 protected:
00050    /**
00051     * This should not be deleted directly.  It should be deleted according to
00052     * the instructions provided for the relevant subclass.
00053     */
00054    virtual ~TypeAwareObject() {}
00055 };
00056 
00057 #endif

Software Development Kit - Opticks 4.9.0 Build 16218