Main Page | Namespace List | Class Hierarchy | Alphabetical List | Data Structures | Directories | File List | Namespace Members | Data Fields | Globals
common

composite_object.hpp

Go to the documentation of this file.
00001 //
00002 // See license.txt for license information.
00003 //
00004 // composite_object.hpp
00005 //
00006 // 4-Jul-2003 phamilton Created
00007 //
00008 
00009 #ifndef incCOMMON_COMPOSITE_OBJECT
00010 #define incCOMMON_COMPOSITE_OBJECT
00011 
00012 // forwards
00013 #include "object.hpp"
00014 #include "outerable_object.hpp"
00015 #include "comparable_object.hpp"
00016 #include "nameable_object.hpp"
00017 
00018 namespace ph {
00019 namespace common {
00020 
00021 class composite_object_helper
00022 /**
00023  A class which implements equality for composite objects.
00024 */
00025 {
00026 public:
00027 
00028 bool helper_equal(const object_base *obj, 
00029 object_base *outer, const std::string &name) const
00030 {
00031 if (obj->outerable())
00032 {
00033 // use the comparable interface in the object to compare them
00034 // if it's available.
00035 object_base *o = obj->outerable()->outer();
00036 if (o)
00037 {
00038 if (o->comparable())
00039 {
00040 if (!o->comparable()->equal(outer))
00041 return false;
00042 }
00043 else
00044 {
00045 if (o != outer)
00046 return false;
00047 }
00048 }
00049 else if (outer)
00050 return false;
00051 
00052 // if the object can be named, then get it's name.
00053 if (obj->nameable())
00054 return obj->nameable()->name() == name;
00055 else
00056 return false;
00057 }
00058 
00059 return false;
00060 }
00061 };
00062 
00063 }; // common
00064 }; // ph
00065 
00066 #endif // incCOMMON_COMPOSITE_OBJECT

Generated on Wed Apr 5 22:03:23 2006 for cppxmlobj by doxygen 1.4.3

AltStyle によって変換されたページ (->オリジナル) /