[CONNECT C++] ElementAgenda, IElementSet

ElementAgenda.BuildFromElementSet (IElementSetP elementSet, ModifyElementSource source) accepts an IElementSet.

The documentation for IElementSet reveals only ways to enumerate its contents, not ways to built the set.  How does one create an ElementSet?  IElementSet and ElementAgenda appear to serve the same purpose: what are the pros and cons of one over the other?

Parents
  • > IElementSet and ElementAgenda appear to serve the same purpose

    They don't.
    ElementAgenda gives you EditElementHandles; IElementSet gives you ElementHandles.
    IElementSet is purposely opaque (user need neither know nor care how the elements are supplied); ElementAgenda is not.
    In fact ElementAgenda's *iterator* is an implementation of IElementSet.
    You build an IElementSet by implementing the interface on some collection of element(s).

    Answer Verified By: Jon Summers 

  • Unknown said:
    Build an IElementSet by implementing the interface on some collection of element(s)

    Something like this?

    struct MyCollection : IElementSet
    {
       size_t index;
       bvector<MyClassInheritsFromElementHandle> data;
       MyCollection () : index (0) {}
       virtual bool GetFirst (ElementHandleR eh) override { index= 0; eh = data [index]; }
       virtual bool GetNext  (ElementHandleR eh) override { eh = data [++index]; }
    };

     
    Regards, Jon Summers
    LA Solutions

  • sure, assuming some bounds-checking and return statements.

    or simpler example:

    struct OneElement : IElementSet
    {
        ElementHandle m_eh;
        size_t GetCount() override { return 1; }
        bool GetFirst(ElementHandleR eh) override { eh=m_eh; return true; }
        bool GetNext(ElementHandleR) override { return false; }
    };

    Answer Verified By: Jon Summers 

Reply Children
No Data