The Table class was modified to be singleton class (see November 14). This implementation was modified. To be consistent with the Token class, which is initialized with a static initialize() function, the Table class create() function was renamed to initialize() and changed to return nothing instead of a list of errors.
The old initialize() function, a normal private member function, was renamed to setupAndCheck() and still returns a list of errors. Two new static functions were added to access the error list: hasErrors() to report if there were any errors detected and errorList() to return the list of errors. Both fatally abort the program if the initialize function was not called. The initialize function stores the error list returned by setupAndCheck() into a new static error list member variable.
The two static members, one for the pointer to the single instance and the other for the error list are now prefixed with 's_' instead of 'm_' to denote a static member as opposed to a regular member variable. The static member variables to the Token class were also renamed with the 's_' prefix.
The new initialize function also checks if either the instance pointer is not null or if the error list is not empty to determine if the table instance was previously created or at least attempted. When an error is found, the instance is deleted, so the instance pointer alone can't be used to determine if the instance creation was attempted. Similarly, the new error list access functions also check if both the instance pointer is null and error list is empty to determine if there was a creation attempt. The check for a non-empty error list was also added to the instance() access function.
The Token and Table initialize function calls were moved from the Tester run function to the main function. This keeps the initialization in a single location. The Tester run function still contains the check for table errors. The error check was not moved to main because when the GUI is started, any table errors need to be reported in an error dialog box, not to the console output. When the program is started from say an OS start menu or file browser, there is no console for these errors and the program will inexplicably fail to start. Now work on the GUI can begin...
[commit 5c5da1f069] [commit e0474f5144]
Saturday, December 8, 2012
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment
All comments and feedback welcomed, whether positive or negative.
(Anonymous comments are allowed, but comments with URL links or unrelated comments will be removed.)