#ifndef CPSW_HUB_H #define CPSW_HUB_H #include #include #include #include #include #include #include #include #include using boost::weak_ptr; using boost::make_shared; class Visitor; class CDevImpl; typedef shared_ptr DevImpl; typedef weak_ptr WDevImpl; struct StrCmp { bool operator () (const char *a, const char *b ) const { return strcmp(a , b) < 0 ? true : false; } }; class CDevImpl : public CEntryImpl, public virtual IDev { private: typedef std::map MyChildren; mutable MyChildren children_; // only by 'add' method protected: virtual void add(AddressImpl a, Field child); virtual IAddress::AKey getAKey() { return IAddress::AKey( getSelfAs() ); } CDevImpl(CDevImpl &orig, Key &k):CEntryImpl(orig, k) { throw InternalError("Clone NotImplemented"); } public: CDevImpl(Key &k, const char *name, uint64_t size= 0); virtual ~CDevImpl(); virtual CDevImpl *clone(Key &k) { return new CDevImpl( *this, k ); } // template: each (device-specific) address must be instantiated // by it's creator device and then added. virtual void addAtAddress(Field child, unsigned nelms) { IAddress::AKey k = getAKey(); add( make_shared(k, nelms), child->getSelf() ); } virtual Path findByName(const char *s); virtual Child getChild(const char *name) const { return getAddress( name ); } virtual Address getAddress(const char *name) const; virtual void accept(IVisitor *v, RecursionOrder order, int recursionDepth); virtual Children getChildren() const; virtual Hub isHub() const; }; #define NULLHUB Hub( static_cast(NULL) ) #define NULLDEVIMPL DevImpl( static_cast(NULL) ) #endif