Difference between revisions of "Console UI Core Classes - OOP344 20121"

From CDOT Wiki
Jump to: navigation, search
(R0.1)
(Tester)
Line 45: Line 45:
 
this tester is already in your trunk:<br />
 
this tester is already in your trunk:<br />
 
[svn://zenit.senecac.on.ca/oop344/trunk/cioTesters/Test1Frame.cpp Test1Frame.cpp]
 
[svn://zenit.senecac.on.ca/oop344/trunk/cioTesters/Test1Frame.cpp Test1Frame.cpp]
 +
==CField==
 +
Note: The code for this class is provided. You must understand and use it to develop your core classes.
 +
 +
CField is an abstract base class that encapsulates the commonalities of all Input Outputs Console Fields which are placeable on a CDialog. All Fields could be Framed, therefore a CField is inherited from CFrame.
 +
<big><syntaxhighlight lang="cpp">
 +
#include "cframe.h"
 +
class CDialog;
 +
class CField : public CFrame{
 +
protected:
 +
  void* _data;
 +
public:
 +
  CField(int Row = 0, int Col = 0,
 +
        int Width = 0, int Height =0,
 +
        void* Data = (void*) 0,
 +
        bool Bordered = false,
 +
        const char* Border=C_BORDER_CHARS);
 +
  ~CField();
 +
  virtual int edit() = 0;
 +
  virtual bool editable() const = 0;
 +
 +
 +
  virtual void set(const void* data) = 0;
 +
  virtual void* data();
 +
 +
  void container(CDialog* theContainer);
 +
  CDialog* container();
 +
};
 +
</syntaxhighlight></big>
 +
===Attributes===
 +
<big><syntaxhighlight lang="cpp">
 +
  void* _data;
 +
</syntaxhighlight></big>
 +
Will hold the address of any type of data a CField can hold.
 +
===Constructors and Methods===
 +
<big><syntaxhighlight lang="cpp">
 +
  CField(int Row = 0, int Col = 0,
 +
        int Width = 0, int Height =0,
 +
        void* Data = (void*) 0,
 +
        bool Bordered = false,
 +
        const char* Border=C_BORDER_CHARS);
 +
</syntaxhighlight></big>
 +
Passes the corresponding attributes to it's parents constructor and then sets the _data attribute to the incoming Data argument.
 +
<big><syntaxhighlight lang="cpp">
 +
  ~CField();
 +
</syntaxhighlight></big>
 +
Empty Destructor
 +
<big><syntaxhighlight lang="cpp">
 +
  virtual int edit() = 0;
 +
  virtual bool editable() const = 0;
 +
  virtual void set(const void* data) = 0;
 +
</syntaxhighlight></big>
 +
Enforce the children to implement;
 +
* an edit() method
 +
* an editable() method that returns true if the class is to edit data and false if the class is to only display data.
 +
* a set() method to set the _data attribute to the data the class is to work with.
 +
<big><syntaxhighlight lang="cpp">
 +
  virtual void* data();
 +
</syntaxhighlight></big>
 +
Returns _data.
 +
<big><syntaxhighlight lang="cpp">
 +
  void container(CDialog* theContainer);
 +
  CDialog* container();
 +
</syntaxhighlight></big>
 +
Sets and Gets the _frame attribute of CFrame by calling CFrame::frame() method. Make sure to cast The CDialog to CFrame when setting and cast CFrame to CDialog when getting!

Revision as of 15:47, 15 February 2012

Objective

Your objective at this stage is to create series of core classes designed to interact with the user. These Core Classes then can be used in development of any interactive application.

Please note that the class definitions here are minimum requirement for the Core Classes and you are free to add any enhancements or features you find useful. However make sure that you discuss these enhancements with your professor to make sure they are feasible before implementation.

It is highly recommended to develop the classes in the order they are stated here. You must create your own tester programs for each class (if possible); However, close to due date of each release, a tester program may be provided to help you verify the functionality of your classes. If tester programs are provided, then executables of the test programs will be available on matrix to show you how it is supposed to run.

Start by creating mock-up classes (class declaration and definition with empty methods that only compiles and don't do anything). Each class MUST have its own header file to hold its declaration and "cpp" file to hold its implementation. To make sure you do not do circular includes follow these simple guidelines:

  • Add recompilation safeguards to all your header files.
  • Always use forward declaration if possible instead of including a class header-file.
  • Use includes only in files in which the actual header file code is used.
  • Avoid "just in case" includes.

Student Resources

Help/Question

  • N/A

Releases and Due Dates

R0.1

To Do

checkout your repository using userids and passwords received through your learn.senecac.on.ca email
Note that the trunk holds several files that are the base of your project.
Then in the Checked out directory:

  1. Create a directory in branches. Name of this directory must be your seneca email id (NOT YOUR WHOLE EMAIL ADDRESS, ONLY THE ID) (done in lab)
    From now on, this directory will be called Your Workspace
  2. In your workspace create a direcotry called console and add the files you submitted for your console assignment to it. (done in lab)
  3. using svn command, add, add all the newly created directories and their files to svn (done in lab)
  4. commit the repository with the message (comment) "Initial branch creation" (done in lab)
  5. After doing this with all your team members present (Online or face to face), Browse your Console code as a group and choose the best version from them and manually copy and add it to trunk
    Any of the group members can do this, but it would be nice if you do this when everyone is present (only one copy of console.cpp and console.h should get copied in trunk)
  6. If further changes to console.cpp or console.h are needed, apply them too
  7. Compile your code with Test1Frame.cpp and make sure it works properly
  8. After fixing possible bugs recompile and make sure everything is ok and runs properly
  9. tag the trunk under R0.1 in tags directory

Due Date

Fri Feb 17, 11:59

Exercise

To prepare and learn how to contribute and also gain mark for your next release do the following exercise.

Tester

this tester is already in your trunk:
Test1Frame.cpp

CField

Note: The code for this class is provided. You must understand and use it to develop your core classes.

CField is an abstract base class that encapsulates the commonalities of all Input Outputs Console Fields which are placeable on a CDialog. All Fields could be Framed, therefore a CField is inherited from CFrame.

#include "cframe.h"
class CDialog;
class CField : public CFrame{
protected:
  void* _data;
public:
  CField(int Row = 0, int Col = 0,
         int Width = 0, int Height =0,
         void* Data = (void*) 0,
         bool Bordered = false,
         const char* Border=C_BORDER_CHARS);
  ~CField();
  virtual int edit() = 0;
  virtual bool editable() const = 0;
 
 
  virtual void set(const void* data) = 0;
  virtual void* data();
 
  void container(CDialog* theContainer);
  CDialog* container();
};

Attributes

  void* _data;

Will hold the address of any type of data a CField can hold.

Constructors and Methods

  CField(int Row = 0, int Col = 0,
         int Width = 0, int Height =0,
         void* Data = (void*) 0,
         bool Bordered = false,
         const char* Border=C_BORDER_CHARS);

Passes the corresponding attributes to it's parents constructor and then sets the _data attribute to the incoming Data argument.

  ~CField();

Empty Destructor

  virtual int edit() = 0;
  virtual bool editable() const = 0;
  virtual void set(const void* data) = 0;

Enforce the children to implement;

  • an edit() method
  • an editable() method that returns true if the class is to edit data and false if the class is to only display data.
  • a set() method to set the _data attribute to the data the class is to work with.
  virtual void* data();

Returns _data.

  void container(CDialog* theContainer);
  CDialog* container();

Sets and Gets the _frame attribute of CFrame by calling CFrame::frame() method. Make sure to cast The CDialog to CFrame when setting and cast CFrame to CDialog when getting!