Document/View Architecture
Brad Smith -- smithb@zeus.fanshawec.on.ca
Tuesday, June 18, 1996
I am having some difficulty trying to incorporate the DOC/VIEW
architecture into my application. I do not have MSDN yet! I do have
Inside Visual C++ and a copy of MSJ's article in Vol. 11 No. 2. These
provide simple examples but I am in need of help developing a 'Doc'
that encompasses several of my own classes in separate source files.
I am currently developing a Simulator for small microcontrollers such
as the 68hc11. I wish to incorporate some classes from an old
simulator I developed with Borland's compiler. I am now using VC++
4.0 / NT 3.51 :)
My classes are as follows:
CPU-
|_Memory (simulate RAM & ROM)
|_Registers ( simulate CPU's registers )
|_Opcode_ (simulate CPU's internal functions )
|_ Opcode_Add
|_ Opcode_Mov
|_ Opcode_Inr
|_ etc...
My program needs to load an object file( machine code for the
microcontroller) and simulate the microtrollers actions.
Any help or suggestions are greatly appreciated. :)
Jim Tannenbaum -- jimt1@voicenet.com
Saturday, June 22, 1996
[Mini-digest: 2 responses]
I recently finished working on two projects using VC++ 1.52C / Win 3.11.
One project involved displaying radar frame data and the other involved a
ship board EW system. In both cases, data was collected by pre-existing
(and pre-windows based) s/w. The best advice I can offer is to ignore
trying to serialize the data. Instead, override the OnOpenDocument function
in CDocument. This will allow you to "roll your own" file i/o routine. Use
either CFile or FILE to open the file. CFile eventually provides the C File
i/o routines I have grown to know and love. Data structures to handle the
data belong in the DOC. Use the view to show the user what's happening to
your data after it was read in. You can overide CView::OnInitialUpdate to
do a one time init of your variables and overide CView::OnUpdate to do the
rest. You might consider using a CFrameView to display status rather than a
regular view. While this may seem like a paradign shift, the CFrameView
gives you the advantages of a dialog box without using DoModal() to get it.
Good Luck,
Jet
JJM Systems, Inc Phone: (215) 672-3660
1 Ivybrook Blvd, Suite 190 Fax: (215) 672-5702
Ivyland, PA 19874 Net: jimt1@voicenet.com
-----From: Roger Onslow/Newcastle/Computer Systems Australia/AU
>I am currently developing a Simulator for small microcontrollers such
>as the 68hc11. I wish to incorporate some classes from an old
>simulator I developed with Borland's compiler. I am now using VC++
>4.0 / NT 3.51 :)
>
>My classes are as follows:
> CPU-
> |_Memory (simulate RAM & ROM)
> |_Registers ( simulate CPU's registers )
> |_Opcode_ (simulate CPU's internal functions )
> |_ Opcode_Add
> |_ Opcode_Mov
> |_ Opcode_Inr
> |_ etc...
>
>My program needs to load an object file( machine code for the
>microcontroller) and simulate the microtrollers actions.
>Any help or suggestions are greatly appreciated. :)
I would suggest that your document simply contain an instance of your CPU
class, and possibly also and instance containing whatever data is neede to
store the "object file" that your program loads. Really hard to say without
(lots) more info.
There is nothing realy trick about doc/view architecture... The Document
contains the data and the View the code of representing it visually (ie it
draws it and handles mouse events for interaction with it). A View has one and
only one Document (and so it can call GetDocument() to get at the document it
is viewing); a Document may have multiple Views (and calls (usually)
UpdateAllViews() to notify the View(s) that the data has changed).
Just to complicate things a little, their are also frames (a window in which to
place the View) and doc-templates which synchronise the creation of
documents/views/frames.
Hope this helps.
Dan L. Pierson -- dan@cthulhu.control.com
Monday, June 24, 1996
I would put all of your existing classes and all other parts of the =
simulation engine in the document. Note that: (1) you can use multiple =
source files to implement the document class, (2) the document class can =
and should include member variables for your own, application specific, =
classes.
IMHO, the view should be reserved for displaying the simulation results, =
progress, etc.
I.E. document has the data (or computation), view displays it.
----------
From: Brad Smith
Sent: Tuesday, June 18, 1996 8:39 AM
To: mfc-l@netcom.com
Subject: Document/View Architecture
I am having some difficulty trying to incorporate the DOC/VIEW=20
architecture into my application. I do not have MSDN yet! I do have=20
Inside Visual C++ and a copy of MSJ's article in Vol. 11 No. 2. These=20
provide simple examples but I am in need of help developing a 'Doc'=20
that encompasses several of my own classes in separate source files.
I am currently developing a Simulator for small microcontrollers such=20
as the 68hc11. I wish to incorporate some classes from an old=20
simulator I developed with Borland's compiler. I am now using VC++=20
4.0 / NT 3.51 :)
My classes are as follows:
CPU-
|_Memory (simulate RAM & ROM)
|_Registers ( simulate CPU's registers )
|_Opcode_ (simulate CPU's internal functions )
|_ Opcode_Add
|_ Opcode_Mov
|_ Opcode_Inr
|_ etc...
My program needs to load an object file( machine code for the=20
microcontroller) and simulate the microtrollers actions.
Any help or suggestions are greatly appreciated. :)
| Вернуться в корень Архива
|