Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware API
      • ZBrush GoZ API
      • Code Examples on Github
    • Forum
    • Downloads
    • Support
      • Support Procedures
      • Registered Developer Program
      • Plugin IDs
      • Contact Us
    • Categories
      • Overview
      • News & Information
      • Cinema 4D SDK Support
      • Cineware SDK Support
      • ZBrush 4D SDK Support
      • Bugs
      • General Talk
    • Unread
    • Recent
    • Tags
    • Users
    • Login

    BaseContainer and range-based loop

    Cinema 4D SDK
    r20 r19 c++
    3
    7
    1.2k
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • C4DSC
      C4DS
      last edited by

      Say I am using a BaseContainer to hold a list of Int32 values, I know there exists a BrowseContainer to loop over the content of the BaseContainer's entries.
      But what if I would prefer to use a range-based for-loop for this, how would I go about this?

      I know there are BaseArray or BaseList or even HashMap which would be preferred in order to provide for a native range-based for-loop (as well as native iterator support).

      But let's assume these types don't cut it, and that the BaseContainer is the better approach for holding the data. How would one go about implementing range-based support (or iterator support in general) for this?

      1 Reply Last reply Reply Quote 0
      • r_giganteR
        r_gigante
        last edited by

        Hi @C4DS thanks for reaching out us.

        Just to be sure we're on the same page: are you referring to this, right?

        Cheers, Riccardo

        C4DSC 1 Reply Last reply Reply Quote 0
        • C4DSC
          C4DS @r_gigante
          last edited by

          @r_gigante
          Yes, indeed.
          I already had a look into the technicals for a range-based for-loop, and it requires a begin() and end() method. Both of these would then be related to a pointer to the data.
          Constructing an own custom type or storage-container, I could see myself making use of an allocated block of memory and storing the data in that, allowing to work with the pointer.
          However, for a BaseContainer I don't see any way to interact with its internals.
          The only pointers that can be obtained are GeData* to specific entries (via const GeData* GetDataPointer(Int32 id) const), but that obviously doesn't provide the appropriate pointers to allow begin() and end() to work with.

          I am also looking into extending the functionality of an HashMap, and in both cases I would use the storage (HashMap or BaseContainer) as a data container, encapsulated in my custom " list" type.

          So, in general I am looking for a way to have custom storage containers (e.g. Int32UniqueList, Int32Set, ...) using Int32, Float, Bool, ... as type, but with other functionality than available with the BaseArray, BaseList, HashMap, SortedArray, .... Still being able to iterate over these via index, iterator and range-base.
          And, as such, as a start, I am looking into the possibilities with BaseContainer.

          As the documentation mentions that "base" in BaseArray isn't an indication that one should derive from it, I am looking for possibilities to:

          • or encapsulate the storage-type into a custom list-type
          • or indeed derive from it and provide additional functionality

          I hope I haven't confused you more than I have provided answers.

          1 Reply Last reply Reply Quote 0
          • ManuelM
            Manuel
            last edited by Manuel

            hello,

            I've tried several possibilities but for all of them you need to know how much ID you have and what they are. (doesn't help that much)

            You need to store your data (and maybe your custom data), did you have a look at DataDictionary or other possibilities

            Cheers
            Manuel

            MAXON SDK Specialist

            MAXON Registered Developer

            C4DSC 1 Reply Last reply Reply Quote 1
            • C4DSC
              C4DS @Manuel
              last edited by

              @m_magalhaes
              During all those years since R17 I must have continuously overlooked the maxon::Data and maxon::DataDictionary ...
              Thanks for pointing these out to me!

              I am embarrassed to admit having missed these while browsing and searching through the SDK documentation, over and over again.

              1 Reply Last reply Reply Quote 0
              • ManuelM
                Manuel
                last edited by

                Make sense, because it's available since R20 ^^

                MAXON SDK Specialist

                MAXON Registered Developer

                C4DSC 1 Reply Last reply Reply Quote 1
                • C4DSC
                  C4DS @Manuel
                  last edited by

                  @m_magalhaes
                  Ah!
                  However, I had preferred it was me who had overlooked these all those years. As this means I will still need to find a different solution for pre-R20 compatibility.

                  1 Reply Last reply Reply Quote 0
                  • First post
                    Last post