GridObject.hpp

00001 #ifndef __FISH_GRIDOBJECT_HPP
00002 #define __FISH_GRIDOBJECT_HPP
00003 
00004 #include "fishboneDllApi.h"
00005 
00006 #include <memcore/stringutil.hpp>
00007 
00008 #include <ocean/plankton/VCreator.hpp>
00009 #include <bundle/Bundle.hpp>
00010 #include "FishBundle.hpp"
00011 #include "FishGrid.hpp"
00012 
00013 namespace Wizt
00014 {
00015 
00032 class fishbone_API GridObject : public virtual VObject, public virtual Fish<Fiber::Bundle>
00033 {
00034 public:
00035         TypedSlot<VStringList>  MyGridNames; 
00036 
00037         VOutput<Fiber::Grid>    theGrid;
00038 
00040         GridObject(const string&name, int p, const RefPtr<VCreationPreferences>&VP); 
00041 
00043         ~GridObject();
00044 
00048 static  bool    HasGrids(const WeakPtr<VCreatorBase>&crec, const RefPtr<VObject>&vobj);
00049 
00050         override bool update(VRequest&R, double precision); 
00051 
00052 };
00053 
00054 
00059 template <class GridVObject>
00060 struct  GridObjectCreator : VCreator<GridVObject, AcceptList<Fiber::BundlePtr> >  
00061 {
00062         GridObjectCreator(const string&name, int quality)
00063         : VCreator<GridVObject, AcceptList<Fiber::BundlePtr> > (name, quality)
00064         {}
00065 
00066         override string createChildname(const string&parent_name) const
00067         {
00068         string  BaseName = right_of( this->Name(), '/'); 
00069 
00070                 return BaseName + "Of" + parent_name;
00071         }
00072 
00073         override RefPtr<VAcceptInfo> accept(const RefPtr<VObject>&vobj) const
00074         {
00075         //      printf("GridObjectCreator<%s>::accept()\n", Typename( typeid(GridVObject) ).c_str() );
00076 #if     0
00077 // accept grids on any object that exports a bundle pointer?
00078                 if (!GridObject::HasGrids(this->self(), vobj) )
00079                 {
00080                         return NullPtr();
00081                 }
00082 #endif
00083 
00084         RefPtr<VAcceptInfo>
00085                 VAI = VCreator<GridVObject, AcceptList<Fiber::BundlePtr> >::accept(vobj); 
00086 
00087                 if (!VAI)
00088                         return NullPtr(); 
00089 
00090                 return VAI;
00091         }
00092 };
00093 
00094 
00095 } // namespace Wizt
00096 
00097 #endif /* __FISH_GRIDOBJECT_HPP */
00098 
00099