COM and common data per instance 
Author Message
 COM and common data per instance

Hey all,

What I would like to do is have a common data object that all instances
would have access to.  This is more of a self tutorial, so if it does not
seem like it has any practical value, then that's okay.  Maybe this is kind
of contradictory to COMs model, but let me give an example.

This is just a stupid example, but bare with me.  Suppose I want a COM
object that supports the following:

SetCommPort(int commport)
SetBufferSize(int size)
ReadBuffer(int* x)

The object communicates with the computer's COMM port, and stores the last X
(set by SetBufferSize() ) number of bytes.  You can get this buffer by
calling ReadBuffer.  Any instance of this object will read the same data at
any given time.

The other more practical example, would be to have each instance have its
own buffer.  Such that if I create an instance of this COM object, a buffer
is created for my instance, and any new data is copied to all buffers.  So
any number of objects can view the data coming from the COMM PORT.  This COM
object is can run remotely such that you can get the data from the COMM PORT
from a remote computer.

How would the declaration look for this?  The code itself shouldn't be that
bad, but the structure is a bit confusing.

Thanx for any help,

Yamin



Sat, 03 Apr 2004 11:42:12 GMT  
 COM and common data per instance
Why bother copying from the COM port to N buffers ? If all threads read the
same input from the COMM port just use one buffer. Copying is overhead and
maintaining which thread has which buffer is overhead too.


Quote:
> Hey all,

> What I would like to do is have a common data object that all instances
> would have access to.  This is more of a self tutorial, so if it does not
> seem like it has any practical value, then that's okay.  Maybe this is
kind
> of contradictory to COMs model, but let me give an example.

> This is just a stupid example, but bare with me.  Suppose I want a COM
> object that supports the following:

> SetCommPort(int commport)
> SetBufferSize(int size)
> ReadBuffer(int* x)

> The object communicates with the computer's COMM port, and stores the last
X
> (set by SetBufferSize() ) number of bytes.  You can get this buffer by
> calling ReadBuffer.  Any instance of this object will read the same data
at
> any given time.

> The other more practical example, would be to have each instance have its
> own buffer.  Such that if I create an instance of this COM object, a
buffer
> is created for my instance, and any new data is copied to all buffers.  So
> any number of objects can view the data coming from the COMM PORT.  This
COM
> object is can run remotely such that you can get the data from the COMM
PORT
> from a remote computer.

> How would the declaration look for this?  The code itself shouldn't be
that
> bad, but the structure is a bit confusing.

> Thanx for any help,

> Yamin



Sun, 04 Apr 2004 16:21:28 GMT  
 COM and common data per instance
Because each client would have a different view of the data.    All of them
would not be reading at the exact same time, so if each client is to get all
the data from the COM port, they would need their own buffers.  Unless there
is another way, like having one really big server-side buffer and using
client indices into it.  Like I said though, this was a self-tutorial, to
see what I could do with COM.

Yamin


Quote:
> Why bother copying from the COM port to N buffers ? If all threads read
the
> same input from the COMM port just use one buffer. Copying is overhead and
> maintaining which thread has which buffer is overhead too.



> > Hey all,

> > What I would like to do is have a common data object that all instances
> > would have access to.  This is more of a self tutorial, so if it does
not
> > seem like it has any practical value, then that's okay.  Maybe this is
> kind
> > of contradictory to COMs model, but let me give an example.

> > This is just a stupid example, but bare with me.  Suppose I want a COM
> > object that supports the following:

> > SetCommPort(int commport)
> > SetBufferSize(int size)
> > ReadBuffer(int* x)

> > The object communicates with the computer's COMM port, and stores the
last
> X
> > (set by SetBufferSize() ) number of bytes.  You can get this buffer by
> > calling ReadBuffer.  Any instance of this object will read the same data
> at
> > any given time.

> > The other more practical example, would be to have each instance have
its
> > own buffer.  Such that if I create an instance of this COM object, a
> buffer
> > is created for my instance, and any new data is copied to all buffers.
So
> > any number of objects can view the data coming from the COMM PORT.  This
> COM
> > object is can run remotely such that you can get the data from the COMM
> PORT
> > from a remote computer.

> > How would the declaration look for this?  The code itself shouldn't be
> that
> > bad, but the structure is a bit confusing.

> > Thanx for any help,

> > Yamin



Mon, 05 Apr 2004 06:30:40 GMT  
 COM and common data per instance
Hello Yamin,

I think to use one single buffer (Maybe write a Singleton COM class in ATL)
is more suitable for presenting one COM port. If you are considering some
client may lose data, we can use a simple connection to notify the clients
data is available or simply use connection to push data to client side
buffers. (Each client has its own buffer.)

Hope this information is useful for you.

Regards,
Woody

This posting is provided 'AS IS' with no warranties, and confers no rights.
You assume all risk for your use. ? 2001 Microsoft Corporation. All rights
reserved.



Thu, 08 Apr 2004 16:01:56 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Common areas/common data/data sharing

2. all COM Server Instances contain the same data

3. Static Instance Members Per-Process?

4. Is it possible to have one instance per machine

5. Per-Instance global variables

6. In-Proc DLL instance per object

7. One threads per each instance of object

8. Create instance of an com object inside a the Com server

9. why Can\'t create COM Instance After registering COM Server Successfully

10. seeking published info / lines-of-code per programmer per day

11. PER USER Singleton COM object, HOW?

12. Detecting single dot on a line: as per the SMTP DATA command

 

 
Powered by phpBB® Forum Software