///////////////////////////////////////////////////////////////////////////// // CRCProc.cpp - process CRC information // // ver 1.0 // // Language: Visual C++, ver 6.0 // // Platform: Del Dimension 8100, Windows 2000, SP1 // // Application: Project #1 Prototype for CSE691/791 - SWM&A, Fall 2000 // // Author: Jim Fawcett, CST 2-187, Syracuse University // // (315) 443-3948, jfawcett@twcny.rr.com // ///////////////////////////////////////////////////////////////////////////// #include "stdafx.h" // server modules must include this in cpp file // when used with MFC interfaces #include "CRCProc.h" //----< private data used to store CRC information >------------------------- static CRCrepType CRCrep; // map static CRCrepType::iterator repIt; // points to current CRC item //----< point to first CRC in rep >------------------------------------------ void top() { repIt = CRCrep.begin(); } //----< point to next CRC in rep >------------------------------------------- bool nextCRC() { CRCrepType::iterator temp = repIt; if(++temp == CRCrep.end()) return false; ++repIt; return true; } //----< given title, find CRC item, if it exists in rep >-------------------- bool find(const std::string &str) { top(); if(str == title()) return true; while(nextCRC()) if(str == title()) return true; return false; } //----< find index of item with given title >-------------------------------- int getCRCindex(const std::string &str) { int i; top(); for(i=0; i---------------------------------- int size() { return CRCrep.size(); } //----< return title of current CRC item >----------------------------------- const std::string& title() { return repIt->first; } //----< return text of current CRC item >------------------------------------ std::string& text() { return repIt->second; } //----< create initial CRC representation >---------------------------------- void initializeCRCs() { // here is where you should add code to read from CRC file, // parse its XML to extract each title and text body, then // create each CRC like this std::string text = "Component: Executive"; text += "\r\n\r\nResponsibilities:"; text += "\r\n - display list of CRCs"; text += "\r\n - display text of selected CRC"; text += "\r\n - create and modify CRCs with the help of CRC processor"; text += "\r\n\r\nCollaborators:"; text += "\r\n - command line handler"; text += "\r\n - CRC processor\r\n"; addCRC("Executive", text); text = "Component: CRC processor"; text += "\r\n\r\nResponsibilities:"; text += "\r\n - manage internal CRC representation"; text += "\r\n - provide CRC management interface for Executive"; text += "\r\n\r\nCollaborators:"; text += "\r\n - Executive"; text += "\r\n - XML parser\r\n"; text += "\r\n\r\nDesign Notes:"; text += "\r\n - Use ASCII template to provide headings for empty CRC."; text += "\r\n Will support other applications"; addCRC("CRC Processor", text); text = "Component: Command line handler"; text += "\r\n\r\nResponsibilities:"; text += "\r\n - extract path to CRC file"; text += "\r\n - if empty look for CRC file in current directory"; text += "\r\n - if empty look in directory holding CRC executable"; text += "\r\n - parse and process switches"; text += "\r\n - option to print each CRC on separate page"; text += "\r\n - option to support design notes"; text += "\r\n\r\nCollaborators:"; text += "\r\n - Executive\r\n"; addCRC("Command line handler", text); text = "Component: XML parser"; text += "\r\n\r\nResponsibilities:"; text += "\r\n"; text += "\r\n\r\nCollaborators:"; text += "\r\n\r\n"; addCRC("XML parser", text); } //----< remove all items from CRC rep >-------------------------------------- void flush() { CRCrep.erase(CRCrep.begin(),CRCrep.end()); } //----< return reference to CRC rep >---------------------------------------- CRCrepType& getCRCs() { return CRCrep; } //----< add a new CRC with given title and text >---------------------------- void addCRC(const std::string &title, const std::string &text) { CRCrep[title] = text; } void delCRC() { CRCrepType::iterator temp = repIt; ++temp; CRCrep.erase(repIt); repIt = temp; } //----< test stub >---------------------------------------------------------- #ifdef TEST_CRCPROC #include using namespace std; void main() { addCRC("first title", "first text"); addCRC("second title", "second text"); addCRC("final title","final text\nwith a second line of text"); cout << "\n Testing CRCProc Module" << "\n ========================\n"; cout << "\nInitialized with " << size() << " CRCs\n"; top(); int i; for(i=0; i