home *** CD-ROM | disk | FTP | other *** search
/ io Programmo 21 / IOPROG_21.ISO / SOFT / LIBMAT.ZIP / MATOBJ.CPP < prev    next >
Encoding:
C/C++ Source or Header  |  1992-10-16  |  3.8 KB  |  143 lines

  1. /*****************************************************/
  2. /*        matobj.c source for matObject class        */
  3. /*****************************************************/
  4.  
  5.  
  6. /**************************************************/
  7. /*            MatClass Source File                */
  8. /*       Copyright of C. R. Birchenhall           */
  9. /*       University of Manchester, UK.            */
  10. /*   MatClass is freeware. This file should be    */
  11. /* made freely available to users of any software */
  12. /* whose creation is wholly or partly dependent   */
  13. /*                on this file.                   */
  14. /**************************************************/
  15.  
  16. #include "matbox.hpp"
  17.  
  18. static matObjList mainObjList ;
  19.  
  20. /************** object functions ****************/
  21.  
  22. #ifndef NO_STATIC_DEC
  23. #ifdef __cplusplus
  24. INDEX       matObject::count ;
  25. int         matObject::listCtrl ;
  26. #endif
  27. #endif
  28.  
  29. void matObjectInitial( void )
  30. {
  31.    matObject::count = 0 ;
  32.    matObject::listCtrl = 0 ;
  33. } // matObjectInitial
  34.  
  35. matObject::matObject( void )
  36. {
  37.    id = ++count ;
  38.    mainObjList.append( this ) ;
  39. } // matObject::matObject
  40.  
  41. matObject::~matObject( void )
  42. {
  43.    mainObjList.remove( this ) ;
  44. } // matObject::matObject
  45.  
  46. matObject::matObject( const matObject& obj )
  47. {
  48.    if ( obj.identity() ) {
  49.       id = ++count ;
  50.       mainObjList.append( this ) ;
  51.    } // if
  52. } // matObject copy constructor
  53.  
  54. matObject& matObject::operator = ( const matObject& obj )
  55. {
  56.    if ( id == obj.identity() )
  57.       errorExit( "op =", OVPAR ) ;
  58.    return *this ;
  59. } // matObject op =
  60.  
  61. outFile& matObject::info( outFile& f ) M_CONST
  62. {
  63.    f.write( "Unknown Object" ).newLine() ;
  64.    return f ;
  65. } // matObject::info
  66.  
  67. outFile& matObject::put( outFile& f ) M_CONST
  68. {
  69.    f.write( "Unknown Object" ).newLine() ;
  70.    return f ;
  71. } // matObject::put
  72.  
  73. inFile& matObject::get( inFile& f )
  74. {
  75.    f.nextLine() ;
  76.    return f ;
  77. } // matObject::get
  78.  
  79. static const int INFOWIDTH = 6 ;
  80.  
  81. outFile& matObject::putName( const char* name, outFile& f ) M_CONST
  82. {
  83.    f.put( name, INFOWIDTH + 2 ).write( " " ) ;
  84.    return f ;
  85. } // matObject::putField
  86.  
  87. outFile& matObject::putField( INDEX i, outFile& f ) M_CONST
  88. {
  89.    f.putIndex( i, INFOWIDTH ).write( " " ) ;
  90.    return f ;
  91. } // matObject::putField
  92.  
  93. outFile& matObject::putField( const char* label, outFile& f ) M_CONST
  94. {
  95.    f.put( label, INFOWIDTH ).write( " " ) ;
  96.    return f ;
  97. } // matObject::putField
  98.  
  99. outFile& matObject::objectInfo( outFile& f ) M_CONST
  100. {
  101.    putField( identity(), f ) ;
  102.    return f ;
  103. } // matObject::objectInfo
  104.  
  105. int matListCtrl( int newCtrl )
  106. {
  107.    int oldCtrl = matObject::listCtrl ;
  108.    if ( newCtrl >= 0 )
  109.       matObject::listCtrl = newCtrl ;
  110.    return oldCtrl ;
  111. } // matListCtrl
  112.  
  113. void matObjectList( outFile& f, int ctrl )
  114. {
  115.    int oldCtrl = matListCtrl( ctrl ) ;
  116.    f.newLine() ;
  117.    f.put( "Object", INFOWIDTH ).write( " " ) ;
  118.    f.put( "  Name  ", INFOWIDTH + 2 ).write( " " ) ;
  119.    f.put( "  Type  ", INFOWIDTH + 2 ).write( " " ) ;
  120.    f.put( "Field1", INFOWIDTH ).write( " " ) ;
  121.    f.put( "Field2", INFOWIDTH ).write( " " ) ;
  122.    f.put( "Field3", INFOWIDTH ).write( " " ) ;
  123.    f.put( "Field4", INFOWIDTH ).write( " " ) ;
  124.    f.put( "Field5", INFOWIDTH ).write( " " ) ;
  125.    f.newLine() ;
  126.    f.put( "------", INFOWIDTH ).write( " " ) ;
  127.    f.put( "--------", INFOWIDTH + 2 ).write( " " ) ;
  128.    f.put( "--------", INFOWIDTH + 2 ).write( " " ) ;
  129.    f.put( "------", INFOWIDTH ).write( " " ) ;
  130.    f.put( "------", INFOWIDTH ).write( " " ) ;
  131.    f.put( "------", INFOWIDTH ).write( " " ) ;
  132.    f.put( "------", INFOWIDTH ).write( " " ) ;
  133.    f.put( "------", INFOWIDTH ).write( " " ) ;
  134.    f.newLine() ;
  135.    mainObjList.print(f) ;
  136.    f.newLine() ;
  137.    matListCtrl( oldCtrl ) ;
  138. } // matObjectList
  139.  
  140. void matObject::clear( void ) {
  141.    matFunc func( "obj clear" ) ;
  142. } // matObject::clear
  143.