GridActor.hpp

00001 #ifndef __FISH_BONE_GRIDACTOR_HPP
00002 #define __FISH_BONE_GRIDACTOR_HPP
00003 
00004 #include "Fish.hpp"
00005 #include <bundle/GridSelector.hpp>
00006 #include <bundle/BundleProperty.hpp>
00007 
00008 namespace Wizt
00009 {
00010 
00011 
00025 template <class GridInspector, class CreativeObject = void>
00026 struct  GridActor : VCreator<CreativeObject, AcceptList<Fiber::Grid> >
00027 {
00028         typedef VCreator<CreativeObject, AcceptList<Fiber::Grid> > Base_t;
00029 
00033         GridActor(const std::string&name, int quality)
00034         : Base_t(name, quality)
00035         {}
00036 
00041         override RefPtr<VAcceptInfo> accept(const RefPtr<VObject>&vobj) const
00042         {
00043 #ifdef  VERBOSE_GRIDACTOR
00044                 printf("----> GridActor::accept() %s looking at %s\n",
00045                        Typename(typeid(CreativeObject)).c_str(), vobj->Name().c_str() );
00046 #endif
00047 
00048         RefPtr<VParameter> GPar = vobj -> getImplementation( typeid(Fiber::GridSelector) );
00049                 if (!GPar)
00050                         return NullPtr();
00051 
00052         Fiber::GridSelector GS;
00053                 if (!GPar->getValue( GS, NullPtr(), "") )
00054                         return NullPtr();
00055 
00056                 if (!GS.BundleSource() )
00057                 {
00058                         //
00059                         // source object exports a GridSelector,
00060                         // but has no bundle object yet.
00061                         // Probably this means that it wants to export
00062                         // a Grid, but its creation has not yet been triggered.
00063                         // Thus, allow accepting this object, such that
00064                         // this rendering object may trigger the creation of
00065                         // an appropriate Grid.
00066                         //
00067 #ifdef  VERBOSE_GRIDACTOR
00068                         printf("GRIDACTOR: NO BUNDLE YET in [%s] -> [%s] - allowing all output objects. "
00069                                "If that is not desirable, object should output an empty bundle.\n",
00070                                vobj->Name().c_str(), GPar->Name().c_str()
00071                                 );
00072 #endif
00073                         return Base_t::accept(vobj);
00074                 } 
00075 
00076                 if (hasProperty(GS, GridInspector::InspectionProperty() ) )
00077                 {
00078 #ifdef  VERBOSE_GRIDACTOR
00079                         puts("OUTPUT BUNDLE HAS REQUESTED PROPERTY - output object permitted");
00080 #endif
00081                         return Base_t::accept(vobj);
00082                 }
00083 
00084                 return NullPtr();
00085         }
00086 };
00087 
00088 template <class CreativeObject>
00089 struct  GridActor<CreativeObject, void> : GridActor<typename CreativeObject::GridInspector, CreativeObject>
00090 {
00091         
00092         GridActor<CreativeObject, void>(const std::string&name, int quality) 
00093         : GridActor<typename CreativeObject::GridInspector, CreativeObject>(name, quality)
00094         {}
00095 };
00096 
00097 } // namespace Wizt
00098 
00099 #endif /* __FISH_BONE_GRIDACTOR_HPP */
00100