Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. ATL / WTL / STL
  4. Regular methods on the class object

Regular methods on the class object

Scheduled Pinned Locked Moved ATL / WTL / STL
c++comhelpquestion
3 Posts 2 Posters 5 Views 1 Watching
  • 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.
  • M Offline
    M Offline
    Mehdi Mousavi
    wrote on last edited by
    #1

    Dear folks, Consider 2 components, COuter that implements IOuter and CInner that implements IInner. OTOH, CInner is *auto aggregated* within COuter. By auto aggregation I mean it's aggregated within the COuter class using COM_INTERFACE_ENTRY_AUTOAGGREGATE ATL's macro. Moreover, I've got some regular member methods on CInner, say, SetId, SetOrigin, and the like. These method *are not* on my IInner interface, they are placed as member functions of the class (as mentioned above). The IInner contains "Get" accessors, say, GetId, GetOrigin and the like so that the user could *only* obtain some information using the IInner interface. She cannot set anything on the object, since there's no "Set" accessors on IInner. Now, I'm going to use the objects mentioned above, so that I can call those Set accessors within the program and the user could successfully get these values using the Get methods on IInner. I tried the following: IOuterPtr spOuter; HRESULT hRes = COuter::_CreatorClass::CreateInstance(NULL, IID_IOuter, (void **)&spOuter); if(FAILED(hRes)) return FALSE; CComAggObject *pInner; hRes = CComAggObject::CreateInstance(spOuter, &pInner); if(FAILED(hRes)) return FALSE; pInner->m_contained.SetId(24950); IInnerPtr spInner; hRes = pInner->QueryInterface(IID_IInner, (void **)&spInner); if(FAILED(hRes)) return FALSE; But this is basically wrong, since the Inner object is *auto aggregated* ! Do you have any idea how I can create such things? Something like ITCallInfoChangeEvent that gives the user some informaiton via it's Get accessors, (get_Call and get_Cause to name a few) and user cannot set anything on this object, since it's got no Set accessor. Any help would be highly appreciated, Cheers Mehdi Mousavi

    A 1 Reply Last reply
    0
    • M Mehdi Mousavi

      Dear folks, Consider 2 components, COuter that implements IOuter and CInner that implements IInner. OTOH, CInner is *auto aggregated* within COuter. By auto aggregation I mean it's aggregated within the COuter class using COM_INTERFACE_ENTRY_AUTOAGGREGATE ATL's macro. Moreover, I've got some regular member methods on CInner, say, SetId, SetOrigin, and the like. These method *are not* on my IInner interface, they are placed as member functions of the class (as mentioned above). The IInner contains "Get" accessors, say, GetId, GetOrigin and the like so that the user could *only* obtain some information using the IInner interface. She cannot set anything on the object, since there's no "Set" accessors on IInner. Now, I'm going to use the objects mentioned above, so that I can call those Set accessors within the program and the user could successfully get these values using the Get methods on IInner. I tried the following: IOuterPtr spOuter; HRESULT hRes = COuter::_CreatorClass::CreateInstance(NULL, IID_IOuter, (void **)&spOuter); if(FAILED(hRes)) return FALSE; CComAggObject *pInner; hRes = CComAggObject::CreateInstance(spOuter, &pInner); if(FAILED(hRes)) return FALSE; pInner->m_contained.SetId(24950); IInnerPtr spInner; hRes = pInner->QueryInterface(IID_IInner, (void **)&spInner); if(FAILED(hRes)) return FALSE; But this is basically wrong, since the Inner object is *auto aggregated* ! Do you have any idea how I can create such things? Something like ITCallInfoChangeEvent that gives the user some informaiton via it's Get accessors, (get_Call and get_Cause to name a few) and user cannot set anything on this object, since it's got no Set accessor. Any help would be highly appreciated, Cheers Mehdi Mousavi

      A Offline
      A Offline
      AlexO
      wrote on last edited by
      #2

      How about plain old approach of simple object with two interfaces?

      M 1 Reply Last reply
      0
      • A AlexO

        How about plain old approach of simple object with two interfaces?

        M Offline
        M Offline
        Mehdi Mousavi
        wrote on last edited by
        #3

        Well, I finally ended up in having 2 different interface on my inner object, one for initialization and the other one for Get accessors. Cheers, Mehdi Mousavi

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups