1,150c1,81
< // AxsDef.cpp: implementation of the AxsDef class.
< //
< ////////////////////////////////////
< 
< #include <iostream>
< //#include <fstream>
< #include <string>
< #include <cstring> // strcpy
< 
< #include "AxsDef.h"
< 
< #include "Serializer.h"
< #include "init.h"
< 
< using namespace std;
< using namespace tsb; // timber supply branch namespace
< 
< ////////////////////////////////////
< // Construction/Destruction
< ////////////////////////////////////
< 
< 
< /* inlined for speed
< AxsDef::AxsDef(AXSDEF* pAXSDEFStruct, ZONE* pZone, GROUP* pGroup)
<     : m_pStruct(pAXSDEFStruct), m_pZone(pZone), m_pGroup(pGroup)
< {
<     if (0 != m_pZone && 0 == m_pGroup)
<     {
<         m_landUnitType = FssimApp::ZONE_TYPE;
<     }
<     else if(0 != m_pGroup && 0 == m_pZone)
<     {
<         m_landUnitType = FssimApp::GROUP_TYPE;
<     }
<     else if(0 != m_pGroup && 0 != m_pZone)
<     {
<         throw ("Make up your mind: land unit type can't be both zone and group!");
<     }
< }
< */
< 
< AxsDef::~AxsDef()
< {
<     // do nothing yet, but may need to clean up m_pStruct
< }
< 
< // write contents to binary file
< void AxsDef::serialize( Serializer& binaryArchive ) //throw (FileException)
< {
<     if (binaryArchive.isWriting())
<     {
<         // write AXSDEF start_period
<         binaryArchive.write( &(m_pStruct->start_period), sizeof(m_pStruct->start_period) ); // data, size
< 
<         // write last AXSDEF end_period
<         binaryArchive.write( &(m_pStruct->end_period), sizeof(m_pStruct->end_period) ); // data, size
< 
<         // write AXSDEF Percent
<         binaryArchive.write( &(m_pStruct->Percent), sizeof(m_pStruct->Percent) ); // data, size
< 
<         // write last AXSDEF Sign
<         binaryArchive.write( &(m_pStruct->Sign), sizeof(m_pStruct->Sign) ); // data, size
< 
<         // write AXSDEF Age
<         binaryArchive.write( &(m_pStruct->Age), sizeof(m_pStruct->Age) ); // data, size
< 
<         // write last AXSDEF NumAgeAreaElements
<         //binaryArchive.write( &(m_pStruct->NumAgeAreaElements), sizeof(m_pStruct->NumAgeAreaElements) ); // data, size
< 
<         // write last AXSDEF BaseArea
<         //binaryArchive.write( &(m_pStruct->BaseArea), sizeof(m_pStruct->BaseArea) ); // data, size
< 
<         // write last AXSDEF AreaAch
<         //binaryArchive.write( &(m_pStruct->AreaAch), sizeof(m_pStruct->AreaAch) ); // data, size
<     }
<     else // reading archive
<     {
<         // allocate space to read in values
<         AXSDEF tempStruct;
<         m_pStruct = &tempStruct;
< 
<         // read AXSDEF start_period
<         binaryArchive.read( &(m_pStruct->start_period), sizeof(m_pStruct->start_period) ); // data, size
< 
<         // read last AXSDEF end_period
<         binaryArchive.read( &(m_pStruct->end_period), sizeof(m_pStruct->end_period) ); // data, size
< 
<         // read AXSDEF Percent
<         binaryArchive.read( &(m_pStruct->Percent), sizeof(m_pStruct->Percent) ); // data, size
< 
<         // read last AXSDEF Sign
<         binaryArchive.read( &(m_pStruct->Sign), sizeof(m_pStruct->Sign) ); // data, size
< 
<         // read AXSDEF Age
<         binaryArchive.read( &(m_pStruct->Age), sizeof(m_pStruct->Age) ); // data, size
< 
<         // read last AXSDEF NumAgeAreaElements
<         //binaryArchive.read( &(m_pStruct->NumAgeAreaElements), sizeof(m_pStruct->NumAgeAreaElements) ); // data, size
< 
<         // read last AXSDEF BaseArea
<         //binaryArchive.read( &(m_pStruct->BaseArea), sizeof(m_pStruct->BaseArea) ); // data, size
< 
<         // read last AXSDEF AreaAch
<         //binaryArchive.read( &(m_pStruct->AreaAch), sizeof(m_pStruct->AreaAch) ); // data, size
< 
<         this->recreateStruct(m_landUnitType, m_pStruct->start_period, m_pStruct->end_period,
<                              m_pStruct->Percent, m_pStruct->Sign, m_pStruct->Age);
<     }
<     // AgeArea is not serialized (defaults to 0 until simulation)
< }
< 
< 
< void AxsDef::recreateStruct(/*ZONE* zone, GROUP* group,*/ // passed from member variables
<                             int utype, int start, int end, double percent, int sign, int age)
< {
<     /*if (0 != m_pStruct) // clean up memory if overwriting existing struct
<     {
<         tsb::init_delete_axsdef(m_pStruct);
<     }*/
<     AXSDEF* pAXSDEF = 0;
<     if (0 != m_pZone || 0 != m_pGroup) // if axsdef has an owner
<     {
<         pAXSDEF = tsb::init_make_axsdef(m_pZone, m_pGroup, utype, start, end, percent, sign, age);
<     }
<     if (0 == pAXSDEF)
<     {
<         string message = "ERROR: init_make_axsdef() failed in AxsDef::serialize.\n";
<         throw (message);
<     }
<     else
<     {
<         m_pStruct = pAXSDEF;
<     }
< }
< 
< /*int AxsDef::lookupAXSDEFID(const string& label)
< {
<     // lookup AU's index in map by label
<     AConstIndexIterator item = m_labelIndex.find(label);
<     if ( item != m_labelIndex.end() )
<     {
<         return ( (item->second) );
<     }
<     else
<     {
<         throw ("AU not found in labelIndex map");
<     }
< }*/
< 
< 
---
> // AxsDef.cpp: implementation of the AxsDef class
> 
> #include <iostream>
> #include <string>
> #include <cstring> // strcpy
> 
> #include "AxsDef.h"
> 
> #include "init.h"
> 
> #include "ArchiveException.h"
> 
> using namespace std;
> using namespace tsb; // timber supply branch namespace
> 
> 
> // write contents to binary file
> void AxsDef::serialize( Serializer& binaryArchive ) //throw (FileException)
> {
>     if (binaryArchive.isWriting())
>     {
>         // write AxsDefStruct start_period
>         binaryArchive.write( &(m_pStruct->start_period), sizeof(m_pStruct->start_period) ); // data, size
> 
>         // write last AxsDefStruct end_period
>         binaryArchive.write( &(m_pStruct->end_period), sizeof(m_pStruct->end_period) ); // data, size
> 
>         // write AxsDefStruct Percent
>         binaryArchive.write( &(m_pStruct->Percent), sizeof(m_pStruct->Percent) ); // data, size
> 
>         // write last AxsDefStruct Sign
>         binaryArchive.write( &(m_pStruct->Sign), sizeof(m_pStruct->Sign) ); // data, size
> 
>         // write AxsDefStruct Age
>         binaryArchive.write( &(m_pStruct->Age), sizeof(m_pStruct->Age) ); // data, size
>     }
>     else // reading archive
>     {
>         // allocate space to read in values
>         AxsDefStruct tempStruct;
>         m_pStruct = &tempStruct;
> 
>         // read AxsDefStruct start_period
>         binaryArchive.read( &(m_pStruct->start_period), sizeof(m_pStruct->start_period) ); // data, size
> 
>         // read last AxsDefStruct end_period
>         binaryArchive.read( &(m_pStruct->end_period), sizeof(m_pStruct->end_period) ); // data, size
> 
>         // read AxsDefStruct Percent
>         binaryArchive.read( &(m_pStruct->Percent), sizeof(m_pStruct->Percent) ); // data, size
> 
>         // read last AxsDefStruct Sign
>         binaryArchive.read( &(m_pStruct->Sign), sizeof(m_pStruct->Sign) ); // data, size
> 
>         // read AxsDefStruct Age
>         binaryArchive.read( &(m_pStruct->Age), sizeof(m_pStruct->Age) ); // data, size
> 
>         this->recreateStruct(m_pStruct->start_period, m_pStruct->end_period,
>                              m_pStruct->Percent, m_pStruct->Sign, m_pStruct->Age);
>     }
>     // pAgeArea is not serialized (defaults to 0 until simulation)
> }
> 
> 
> void AxsDef::recreateStruct(int start, int end, double percent, int sign, int age)
> {
>     AxsDefStruct* pAXSDEF = 0;
>     if (0 != m_pStandSet) // if axsdef has an owner
>     {
>         pAXSDEF = tsb::init_make_axsdef(m_pStandSet, start, end, percent, sign, age);
>     }
>     if (0 == pAXSDEF)
>     {
>         string message = "ERROR: init_make_axsdef() failed in AxsDef::serialize.\n";
>         throw ArchiveException(message);
>     }
>     else
>     {
>         m_pStruct = pAXSDEF;
>     }
> }
