passing void pointer

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

passing void pointer

John Tobe

I’m trying to pass a pointer to a PlotView between plugins using an Any object.  Is there a way to put such a pointer or a void pointer in an Any object?  What would be the best way to accomplish this?

 

thanks,

John


This message and any enclosures are intended only for the addressee.  Please 

notify the sender by email if you are not the intended recipient.  If you are 

not the intended recipient, you may not use, copy, disclose, or distribute this 

message or its contents or enclosures to any other person and any such actions 

may be unlawful.  Ball reserves the right to monitor and review all messages 

and enclosures sent to or from this email address.

------------------------------------------------------------------------------
Try New Relic Now & We'll Send You this Cool Shirt
New Relic is the only SaaS-based application performance monitoring service
that delivers powerful full stack analytics. Optimize and monitor your
browser, app, & servers with just a few lines of code. Try New Relic
and get this awesome Nerd Life shirt! http://p.sf.net/sfu/newrelic_d2d_apr
_______________________________________________
Opticks-devs mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/opticks-devs
Reply | Threaded
Open this post in threaded view
|

Re: passing void pointer

Trevor Clarke
To use an Any you'd need to create an AnyData wrapper for the void*. Something like:

class VoidType : public AnyData
{
public:
  VoidType(void* pData): mpData(pData) {}
  virtual AnyData* copy() const { VoidType* pNew = new VoidType(mpData); return pNew; }
  virtual bool serialize(SesionItemSerializer&) { return false; }
  virtual bool deserialize(SesionItemDeserializer&) { return false; }
  void* mpData;
};


You might be able pass it as an opaque type in a PlugInArg. (I haven't tried this so I don't remember if it will work but I believe so)

foo(PlugInArgList& inargs, void *pData)
{
  PlugInArg* pArg = Service<PlugInManagerServices>()->getPlugInArg();
  pArg->setName("MyArg");
  pArg->setType("void*"); // or better..use the actual type
  inargs.addArg(pArg);
  pArg->setActualValue(pData, false);
}

Finally, you should be able to pass anything that can be stored in a DataVariant so something like this might work: (of course, this is the least safe option since you're hiding the value in an integer)

foo(PlugInArgList& inargs, void *pData)
{
    unsigned long opaque = (unsigned long)pData;
    inargs.setPlugInArgValueLoose("MyArg", *opaque);
}


On Wed, Apr 24, 2013 at 5:16 PM, Tobe, John <[hidden email]> wrote:

I’m trying to pass a pointer to a PlotView between plugins using an Any object.  Is there a way to put such a pointer or a void pointer in an Any object?  What would be the best way to accomplish this?

 

thanks,

John

This message and any enclosures are intended only for the addressee.  Please 

notify the sender by email if you are not the intended recipient.  If you are 

not the intended recipient, you may not use, copy, disclose, or distribute this 

message or its contents or enclosures to any other person and any such actions 

may be unlawful.  Ball reserves the right to monitor and review all messages 

and enclosures sent to or from this email address.

------------------------------------------------------------------------------
Try New Relic Now & We'll Send You this Cool Shirt
New Relic is the only SaaS-based application performance monitoring service
that delivers powerful full stack analytics. Optimize and monitor your
browser, app, & servers with just a few lines of code. Try New Relic
and get this awesome Nerd Life shirt! http://p.sf.net/sfu/newrelic_d2d_apr
_______________________________________________
Opticks-devs mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/opticks-devs




--
Trevor R.H. Clarke
Computer Science House
Rochester Institute of Technology
[hidden email]
http://www.csh.rit.edu/~retrev/

------------------------------------------------------------------------------
Try New Relic Now & We'll Send You this Cool Shirt
New Relic is the only SaaS-based application performance monitoring service
that delivers powerful full stack analytics. Optimize and monitor your
browser, app, & servers with just a few lines of code. Try New Relic
and get this awesome Nerd Life shirt! http://p.sf.net/sfu/newrelic_d2d_apr
_______________________________________________
Opticks-devs mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/opticks-devs