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

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