home *** CD-ROM | disk | FTP | other *** search
/ Power GUI Programming with VisualAge C++ / powergui.iso / trialva / ibmcppw / samples / ioc / acdf4 / acdfmdl4.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1996-02-22  |  2.9 KB  |  94 lines

  1. ///////////////////////////////////////////////////////////////////////////////
  2. //                                              SAMPLE CODE
  3. //
  4. // FileName: ACDFMdl4.cpp
  5. //
  6. // ClassName: ACompDocFwkModel
  7. //
  8. // Description: Compound Document Framework (SimpleContainer) Model
  9. //              This sample container model conatins no data of its own
  10. //              Basic functionality is inherited from the base class.
  11. ///////////////////////////////////////////////////////////////////////////////
  12. #include "ACDFMdl4.hpp"
  13. #include "ACDFVw4.hpp"
  14. #include "ACDFSt4.hpp"
  15.  
  16. #include <fstream.h>
  17. #include <iexcept.hpp>
  18. #include <icconst.h>
  19. #include <iframe.hpp>
  20. #include <ibasstrm.hpp>
  21. #include <assert.h>
  22.  
  23. TypeExtensionMacro(ACompDocFwkModel)
  24.  
  25. ACompDocFwkModel::ACompDocFwkModel() 
  26. // Default Constructor
  27. {   IFUNCTRACE_DEVELOP();}
  28.  
  29. ACompDocFwkModel::~ACompDocFwkModel()
  30. // Default Destructor
  31. {   IFUNCTRACE_DEVELOP();}
  32.  
  33. ACompDocFwkModel::ACompDocFwkModel( const ACompDocFwkModel& other ) :
  34.             IEmbedderModel( other )  //Force assert
  35. // Copy Constructor
  36. {   IFUNCTRACE_DEVELOP();}
  37.  
  38. IBaseStream& ACompDocFwkModel::operator>>=(IBaseStream& toWhere) const
  39. // Stream member data out
  40. {   IFUNCTRACE_DEVELOP();
  41.     writeVersion(toWhere,kOriginalVersion);
  42.     IEmbedderModel::operator>>=( toWhere );
  43.     return toWhere;
  44. }
  45.  
  46. IBaseStream& ACompDocFwkModel::operator<<=(IBaseStream& fromWhere)
  47. // Stream member data in
  48. {   IFUNCTRACE_DEVELOP();
  49.     switch (readVersion(fromWhere))
  50.     {
  51.         case kOriginalVersion:
  52.             IEmbedderModel::operator<<=( fromWhere );
  53.             break;
  54.         default:
  55.             ITHROWLIBRARYERROR(IC_STREAM_VERSION_UNSUPPORTED, 
  56.                               IBaseErrorInfo::invalidRequest,
  57.                               IException::recoverable);
  58.     }
  59.     return fromWhere;
  60. }
  61.  
  62. // IComponent Stationery class is created using the model, view
  63.  
  64. ACompDocFwkMyStationery CompDocFwkStationery;
  65.  
  66.  
  67. int main( int argc, char* argv[] )
  68. {
  69.     int ireturn;
  70.     try
  71.     {
  72.         // Stationery run will eventually call the IApplication::current().run()
  73.         ireturn =  CompDocFwkStationery.run( argc, argv );
  74.     }
  75.  
  76.     catch (IException& exc)
  77.     {
  78.         ofstream  errorFile("errormsg.log",ios::app);
  79.         const IExceptionLocation *excLocate = exc.locationAtIndex(0);
  80.  
  81.         errorFile << "Exception on exit " << exc.text() << endl;
  82.         errorFile << "File : " << excLocate->fileName() << endl;
  83.         errorFile << "Function : " << excLocate->functionName() << endl;
  84.         errorFile << "Line : " << excLocate->lineNumber() << endl;
  85.  
  86.         cout << "Exception on exit " << exc.text() << endl;
  87.         cout << "File : " << excLocate->fileName() << endl;
  88.         cout << "Function : " << excLocate->functionName() << endl;
  89.         cout << "Line : " << excLocate->lineNumber() << endl;
  90.     }
  91.     return ireturn;
  92. }
  93.     
  94.