1 ///////////////////////////////////////////////////////////////////////////////
2 // $Source: x:/prj/tech/libsrc/comtools/RCS/comconn.cpp $
4 // $Date: 1996/10/10 14:31:26 $
12 ///////////////////////////////////////////////////////////////////////////////
14 int LGAPI
GetCOMConnectionPriority(const void * p
)
16 return ((sCOMConnection
*)p
)->priority
;
19 ///////////////////////////////////////////////////////////////////////////////
21 BOOL
cCOMConnectionSetBase::Search(IUnknown
* p
)
23 // Because these lists never get very long, and because
24 // insertion/removal is an uncommon event relative
25 // to iteration, we simply use a linear search
26 for (index_t i
= 0; i
< m_Connections
.Size(); i
++)
28 if (m_Connections
[i
].pSink
== p
)
34 ///////////////////////////////////////
36 BOOL
cCOMConnectionSetBase::Insert(IUnknown
* p
, DWORD
* pCookie
)
40 CriticalMsg("Multiple connection point advises are not permitted");
44 sCOMConnection connection
;
46 connection
.priority
= 0;
47 m_Connections
.Append(connection
);
55 ///////////////////////////////////////
57 BOOL
cCOMConnectionSetBase::Insert(IUnknown
* p
, int priority
, DWORD
* pCookie
)
61 CriticalMsg("Multiple connection point advises are not permitted");
65 m_fPrioritized
= TRUE
;
68 sCOMConnection connection
;
70 connection
.priority
= priority
;
71 m_Connections
.Append(connection
);
79 ///////////////////////////////////////
81 BOOL
cCOMConnectionSetBase::Remove(DWORD cookie
)
83 IUnknown
* p
= (IUnknown
*) cookie
;
84 for (index_t i
= 0; i
< m_Connections
.Size(); i
++)
86 if (m_Connections
[i
].pSink
== p
)
88 m_Connections
.DeleteItem(i
);
93 CriticalMsg("Unknown notification sink");
97 ///////////////////////////////////////
99 IUnknown
* cCOMConnectionSetBase::GetFirst(tConnSetHandle
& hIndex
)
101 if (m_Connections
.Size())
103 if (m_fPrioritized
&& !m_fSorted
)
105 m_Connections
.Sort();
107 hIndex
= (tConnSetHandle
)0;
108 return m_Connections
[(index_t
)0].pSink
;
113 ///////////////////////////////////////
115 IUnknown
* cCOMConnectionSetBase::GetNext(tConnSetHandle
& hIndex
)
117 const index_t index
= (index_t
)hIndex
+ 1;
118 if (index
< m_Connections
.Size())
120 hIndex
= (tConnSetHandle
)index
;
121 return m_Connections
[index
].pSink
;
126 ///////////////////////////////////////