Lesson 9 | Designing methods |
Objective | Design methods for PhBook. |
Designing Methods (COM PhBook)
Now that we have designed the data structures and properties, the next step is to define the methods. IReadPhBook
will have one
method, while IManagePhBook
will have two.
IReadPhBook
IReadPhBook
will have only one method:
HRESULT GetPhoneRec([in] PhRec *pPhRec, [out] BOOL *pOK)
Get the phone record indexed by property CurRec
.
If the call is successful, pPhRec
contains the information in the phone record indexed by CurRec
,
and pOk
is TRUE
. If an error occurs,
for example, there are no records in the phone book, then pOK
is set to FALSE
.
IManagePhBook
IManagePhBook
will have two methods:
HRESULT AddPhoneRec([in] PhRec *pPhRec, [out] BOOL *pOK) |
Adds a phone record to the end of PhBookObj 's array of phone records. If the record is successfully added, pOK is TRUE . If an error occurs (i.e., there is no more room), pOK is FALSE .
|
HRESULT DeletePhoneRec([out] BOOL *pOK) |
Deletes the current record indexed by CurRec .
If the call is successful, pOK is TRUE ; otherwise, it is set to FALSE .
|
IManagePhBook
does not have CurRec
, NumRecs
, and MaxRecs
properties.
We will have to access these through IReadPhBook
. This is OK for now because our goal is to study COM, we are not developing an optimal production phone book application.
Having defined our data structures, properties, and methods, we are ready to start coding. The next lesson will get us started.