//==================================================================================================
// D a t a _ s t r u c t u r e                                                            Interface
// D a t a _ t e m p l a t e
//                                                                                By Bruno Bachelet
//==================================================================================================
// Copyright (c) 1999-2016
// Bruno Bachelet - bruno@nawouak.net - http://www.nawouak.net
//
// This file is part of the B++ Library. This library is free software; you can redistribute it
// and/or modify it under the terms of the GNU Library General Public License as published by the
// Free Software Foundation; either version 2 of the License, or (at your option) any later
// version.
//
// This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
// without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
// the GNU Library General Public License for more details (http://www.gnu.org).

/*DESCRIPTION*/
/* This module provides data templates designed to be carried by a data structure. */

// File Name //-------------------------------------------------------------------------------------
#line __LINE__ "data_structure/data_template.hpp"

// Guardian //--------------------------------------------------------------------------------------
#ifndef guDataStructureDataTemplate
#define guDataStructureDataTemplate

// Headers //---------------------------------------------------------------------------------------
#include <bpp/standard.hpp> /*INCLUDE*/

namespace bpp {

// Importation/Exportation //-----------------------------------------------------------------------
#ifdef DATA_STRUCTURE_DLL
 #define dll_export DLL_EXPORT
#else
 #define dll_export DLL_IMPORT
#endif

// Namespaces //------------------------------------------------------------------------------------
#define public_area  dataStructureDataTemplate
#define private_area dataStructureDataTemplate_private

namespace public_area  { /*NAMESPACE*/ using namespace standard; }
namespace private_area { using namespace public_area; }

extern_module_name;

// Initialization //--------------------------------------------------------------------------------
#define iniDataStructureDataTemplate
has_initializer;

// Macrocommands //---------------------------------------------------------------------------------

// Types & Classes //-------------------------------------------------------------------------------
namespace public_area {
 //------------------------------------------------------------------------------------------Classes
 template <class prData> class clStandardData;

 class clCommodityData;
 class clCostData;
 class clFlowData;
 class clGenericData;
 class clLengthData;
 class clLocationData;
 class clNoData;
 class clRealData;
 class clRealIntervalData;
 //-----------------------------------------------------------------------------------Variable Types
 typedef clStandardData<tyCardinal>  clCardinalData;
 typedef clStandardData<tyCharacter> clCharacterData;
 typedef clStandardData<tyInteger>   clIntegerData;
 //-----------------------------------------------------------------------------------Constant Types
 typedef const clCardinalData     ctCardinalData;
 typedef const clCharacterData    ctCharacterData;
 typedef const clCommodityData    ctCommodityData;
 typedef const clCostData         ctCostData;
 typedef const clFlowData         ctFlowData;
 typedef const clGenericData      ctGenericData;
 typedef const clIntegerData      ctIntegerData;
 typedef const clLengthData       ctLengthData;
 typedef const clLocationData     ctLocationData;
 typedef const clNoData           ctNoData;
 typedef const clRealData         ctRealData;
 typedef const clRealIntervalData ctRealIntervalData;
}

namespace private_area {}

// Functions Interface //---------------------------------------------------------------------------
namespace public_area  {}
namespace private_area {}

// Errors //----------------------------------------------------------------------------------------
namespace public_area {
 /*ERROR*/ extern_error erNegativeFlowCapacity; /* A flow capacity is negative. */
}

// Constants & Variables //-------------------------------------------------------------------------
extern_static_constant(public,tcString,goNegativeInfinityFlag,negativeInfinityStreamFlag);
extern_static_constant(public,tcString,goNoDataFlag,noDataStreamFlag);
extern_static_constant(public,tcString,goPositiveInfinityFlag,positiveInfinityStreamFlag);
extern_static_constant(public,tcString,goUnsolvedValueFlag,unsolvedValueStreamFlag);

// C o m m o d i t y D a t a  Interface //----------------------------------------------------------
namespace public_area {
 /*CLASS clCommodityData */
 /* Represents a commodity in a graph (i.e. a quantity that must be routed from a source
    node to a target node), designed to be carried by a data structure. */
 class clCommodityData {
  //-----------------------------------------------------------------------------------------Friends
  friend class private_area::clInitializer;
  //-----------------------------------------------------------------------------------------Private
  private_property static tyReal atPositiveInfinity;
  //------------------------------------------------------------------------------------------Public
  /*ATTRIBUTE clCommodityData */ /* The number that identifies the source node. */
  read_write_attribute(tyCardinal,atSource,source);

  /*ATTRIBUTE clCommodityData */ /* The number that identifies the target node. */
  read_write_attribute(tyCardinal,atTarget,target);

  /*ATTRIBUTE clCommodityData */ /* The quantity that must be routed. */
  read_write_attribute(tyReal,atQuantity,quantity);

  public_property static tyReal positiveInfinity(void);

  public_property constructor clCommodityData(void);
  public_property constructor clCommodityData(tyCardinal,tyCardinal,tyReal);
  public_property constructor clCommodityData(ctCommodityData &);
  public_property constructor clCommodityData(clInStream &,tyBoolean=true);
  public_property destructor  clCommodityData(void);

  public_property clCommodityData & operator = (ctCommodityData &);

  public_property void out(clOutStream &,tyBoolean=true) const;
 };
}

// C o s t D a t a  Interface //--------------------------------------------------------------------
namespace public_area {
 /*CLASS clCostData */ /* Represents a cost, designed to be carried by a data structure. */
 class clCostData {
  //-----------------------------------------------------------------------------------------Friends
  friend class private_area::clInitializer;
  //-----------------------------------------------------------------------------------------Private
  private_property static tyReal atNegativeInfinity;
  private_property static tyReal atPositiveInfinity;
  //------------------------------------------------------------------------------------------Public
  /*ATTRIBUTE clCostData */ /* The cost value. */
  read_write_attribute(tyReal,atCost,cost);

  public_property static tyReal negativeInfinity(void);
  public_property static tyReal positiveInfinity(void);

  public_property constructor clCostData(void);
  public_property constructor clCostData(tyReal);
  public_property constructor clCostData(ctCostData &);
  public_property constructor clCostData(clInStream &,tyBoolean=true);
  public_property destructor  clCostData(void);

  public_property clCostData & operator = (ctCostData &);

  public_property void out(clOutStream &,tyBoolean=true) const;
 };
}

// F l o w D a t a  Interface //--------------------------------------------------------------------
namespace public_area {
 /*CLASS clFlowData */
 /* Represents a flow, designed to be carried by a data structure. */
 class clFlowData {
  //-----------------------------------------------------------------------------------------Friends
  friend class private_area::clInitializer;
  //-----------------------------------------------------------------------------------------Private
  private_property static tyReal atPositiveInfinity;
  //------------------------------------------------------------------------------------------Public
  /*ATTRIBUTE clFlowData */ /* Maximum flow. */
  read_write_attribute(tyReal,atMaximum,maximum);

  /*ATTRIBUTE clFlowData */ /* Resolved flow. */
  read_write_attribute(tyReal,atFlow,flow);

  public_property static tyReal positiveInfinity(void);

  public_property constructor clFlowData(void);
  public_property constructor clFlowData(ctFlowData &);
  public_property constructor clFlowData(tyReal,tyReal);
  public_property constructor clFlowData(clInStream &,tyBoolean=true);
  public_property destructor  clFlowData(void);

  public_property clFlowData & operator = (ctFlowData &);

  public_property void out(clOutStream &,tyBoolean=true) const;
 };
}

// G e n e r i c D a t a  Interface //--------------------------------------------------------------
namespace public_area {
 /*CLASS clGenericData */
 /* Represents the data carried by a data structure in a generic way. All the data is stored in a
    single string of characters. */
 class clGenericData {
  //------------------------------------------------------------------------------------------Public
  /*ATTRIBUTE clGenericData */ /* The generic data. */
  read_write_attribute(clString,atString,characters);

  public_property constructor clGenericData(void);
  public_property constructor clGenericData(ctString &);
  public_property constructor clGenericData(ctGenericData &);
  public_property constructor clGenericData(clInStream &,tyBoolean=true);
  public_property destructor  clGenericData(void);

  public_property clGenericData & operator = (ctGenericData &);

  public_property void out(clOutStream &,tyBoolean=true) const;
 };
}

// L e n g t h D a t a  Interface //----------------------------------------------------------------
namespace public_area {
 /*CLASS clLengthData */ /* Represents a length, designed to be carried by a data structure. */
 class clLengthData {
  //-----------------------------------------------------------------------------------------Friends
  friend class private_area::clInitializer;
  //-----------------------------------------------------------------------------------------Private
  private_property static tyReal atNegativeInfinity;
  private_property static tyReal atPositiveInfinity;
  //------------------------------------------------------------------------------------------Public
  /*ATTRIBUTE clLengthData */ /* The length value. */
  read_write_attribute(tyReal,atLength,length);

  public_property static tyReal negativeInfinity(void);
  public_property static tyReal positiveInfinity(void);

  public_property constructor clLengthData(void);
  public_property constructor clLengthData(tyReal);
  public_property constructor clLengthData(ctLengthData &);
  public_property constructor clLengthData(clInStream &,tyBoolean=true);
  public_property destructor  clLengthData(void);

  public_property clLengthData & operator = (ctLengthData &);

  public_property void out(clOutStream &,tyBoolean=true) const;
 };
}

// L o c a t i o n D a t a  Interface //-------------------------------------------------------------
namespace public_area {
 /*CLASS clLocationData */
 /* Represents a location (i.e. coordinates in a 3D environment), designed to be carried by a data
    structure. */
 class clLocationData {
  //------------------------------------------------------------------------------------------Public
  /*ATTRIBUTE clLocationData */ /* The X coordinate. */
  read_write_attribute(tyReal,atX,x);

  /*ATTRIBUTE clLocationData */ /* The Y coordinate. */
  read_write_attribute(tyReal,atY,y);

  /*ATTRIBUTE clLocationData */ /* The Z coordinate. */
  read_write_attribute(tyReal,atZ,z);

  public_property constructor clLocationData(void);
  public_property constructor clLocationData(tyReal,tyReal,tyReal=0.0);
  public_property constructor clLocationData(ctLocationData &);
  public_property constructor clLocationData(clInStream &,tyBoolean=true);
  public_property destructor  clLocationData(void);

  public_property clLocationData & operator = (ctLocationData &);

  public_property void out(clOutStream &,tyBoolean=true) const;
 };
}

// N o D a t a  Interface //------------------------------------------------------------------------
namespace public_area {
 /*CLASS clNoData */ /* Represents nothing, designed to be carried by a data structure. */
 class clNoData {
  //------------------------------------------------------------------------------------------Public
  public_property constructor clNoData(void);
  public_property constructor clNoData(ctNoData &);
  public_property constructor clNoData(clInStream &,tyBoolean=true);
  public_property destructor  clNoData(void);

  public_property clNoData & operator = (ctNoData &);

  public_property void out(clOutStream &,tyBoolean=true) const;
 };
}

// R e a l D a t a  Interface //--------------------------------------------------------------------
namespace public_area {
 /*CLASS clRealData */
 /* Represents a real value, designed to be carried by a data structure. */
 class clRealData {
  //-----------------------------------------------------------------------------------------Friends
  friend class private_area::clInitializer;
  //-----------------------------------------------------------------------------------------Private
  private_property static tyReal atNegativeInfinity;
  private_property static tyReal atPositiveInfinity;
  //------------------------------------------------------------------------------------------Public
  /*ATTRIBUTE clRealData */ /* The value. */
  read_write_attribute(tyReal,atValue,value);

  public_property static tyReal negativeInfinity(void);
  public_property static tyReal positiveInfinity(void);

  public_property constructor clRealData(void);
  public_property constructor clRealData(tyReal);
  public_property constructor clRealData(ctRealData &);
  public_property constructor clRealData(clInStream &,tyBoolean=true);
  public_property destructor  clRealData(void);

  public_property clRealData & operator = (ctRealData &);

  public_property void out(clOutStream &,tyBoolean=true) const;
 };
}

// R e a l I n t e r v a l D a t a  Interface //----------------------------------------------------
namespace public_area {
 /*CLASS clRealIntervalData */
 /* Represents an interval of real values and a real value in this interval, designed to be
    carried by a data structure. */
 class clRealIntervalData {
  //-----------------------------------------------------------------------------------------Friends
  friend class private_area::clInitializer;
  //-----------------------------------------------------------------------------------------Private
  private_property static tyReal atNegativeInfinity;
  private_property static tyReal atPositiveInfinity;
  //------------------------------------------------------------------------------------------Public
  /*ATTRIBUTE clRealIntervalData */ /* Minimum value of the interval. */
  read_write_attribute(tyReal,atMinimum,minimum);

  /*ATTRIBUTE clRealIntervalData */ /* Maximum value of the interval. */
  read_write_attribute(tyReal,atMaximum,maximum);

  /*ATTRIBUTE clRealIntervalData */ /* Value in this interval. */
  read_write_attribute(tyReal,atValue,value);

  public_property static tyReal negativeInfinity(void);
  public_property static tyReal positiveInfinity(void);

  public_property constructor clRealIntervalData(void);
  public_property constructor clRealIntervalData(tyReal,tyReal,tyReal);
  public_property constructor clRealIntervalData(ctRealIntervalData &);
  public_property constructor clRealIntervalData(clInStream &,tyBoolean=true);
  public_property destructor  clRealIntervalData(void);

  public_property clRealIntervalData & operator = (ctRealIntervalData &);

  public_property void out(clOutStream &,tyBoolean=true) const;
 };
}

// S t a n d a r d D a t a  Interface //------------------------------------------------------------
namespace public_area {
 /*CLASS clStandardData */
 /* Represents a standard data (like an integer, a character...), designed to be carried
    by a data structure. */
 template <class prData> class clStandardData {
  //------------------------------------------------------------------------------------------Public
  /*ATTRIBUTE clStandardData */ /* The value. */
  read_write_attribute(prData,atValue,value);

  public_property constructor clStandardData(void);
  public_property constructor clStandardData(const prData &);
  public_property constructor clStandardData(const clStandardData<prData> &);
  public_property constructor clStandardData(clInStream &,tyBoolean=true);
  public_property destructor  clStandardData(void);

  public_property clStandardData<prData> & operator = (const clStandardData<prData> &);

  public_property void out(clOutStream &,tyBoolean=true) const;
 };
}

// Functions Inline //------------------------------------------------------------------------------
namespace public_area  {}
namespace private_area {}

// C o m m o d i t y D a t a  Inline //-------------------------------------------------------------
namespace public_area {
 //---------------------------------------------------------------------------------PositiveInfinity
 /*METHOD clCommodityData */
 /* Returns the value that represents the positive infinity. Static method. */
 inline tyReal clCommodityData::positiveInfinity(void) { return (atPositiveInfinity); }
 //--------------------------------------------------------------------------------------Constructor
 /*METHOD clCommodityData */ /* Builds a null value. */
 inline clCommodityData::clCommodityData(void) : atSource(0),atTarget(0),atQuantity(0.0) {}
 //--------------------------------------------------------------------------------------Constructor
 /*METHOD clCommodityData */ /* Builds a data from separated data. */
 inline clCommodityData::clCommodityData(tyCardinal agSource,tyCardinal agTarget,tyReal agQuantity)
 : atSource(agSource),atTarget(agTarget),atQuantity(agQuantity) {}
 //--------------------------------------------------------------------------------------Constructor
 /*METHOD clCommodityData */ /* Builds and copies a data. */
 inline clCommodityData::clCommodityData(ctCommodityData & agData)
 : atSource(agData.atSource),atTarget(agData.atTarget),atQuantity(agData.atQuantity) {}
 //--------------------------------------------------------------------------------------Constructor
 /*METHOD clCommodityData */ /* Builds a data from a stream. */
 inline clCommodityData::clCommodityData(clInStream & agStream,tyBoolean)
 : atSource(),atTarget(),atQuantity() {
  clString lcString;

  agStream >> atSource >> lcString >> atTarget >> lcString >> atQuantity;
  if (agStream.fail()) send_inline_error(erStreamReading,"commodityData::constructor");
 }
 //---------------------------------------------------------------------------------------Destructor
 /*METHOD clCommodityData */ /* Destructs the data. */
 inline clCommodityData::~clCommodityData(void) {}
 //---------------------------------------------------------------------------------------Operator =
 /*METHOD clCommodityData */ /* Copies a data. */
 inline clCommodityData & clCommodityData::operator = (ctCommodityData & agData) {
  atSource=agData.atSource;
  atTarget=agData.atTarget;
  atQuantity=agData.atQuantity;
  return (*this);
 }
 //----------------------------------------------------------------------------------------------Out
 /*METHOD clCommodityData */ /* Writes the data into a stream. */
 inline void clCommodityData::out(clOutStream & agStream,tyBoolean) const {
  agStream << atSource << " , " << atTarget << " ; " << atQuantity;
  if (agStream.fail()) send_inline_error(erStreamWriting,"commodityData::out");
 }
}

// C o s t D a t a  Inline //-----------------------------------------------------------------------
namespace public_area {
 //---------------------------------------------------------------------------------NegativeInfinity
 /*METHOD clCostData */
 /* Returns the value that represents the negative infinity. Static method. */
 inline tyReal clCostData::negativeInfinity(void) { return (atNegativeInfinity); }
 //---------------------------------------------------------------------------------PositiveInfinity
 /*METHOD clCostData */
 /* Returns the value that represents the positive infinity. Static method. */
 inline tyReal clCostData::positiveInfinity(void) { return (atPositiveInfinity); }
 //--------------------------------------------------------------------------------------Constructor
 /*METHOD clCostData */ /* Builds a null value. */
 inline clCostData::clCostData(void) : atCost(0.0) {}
 //--------------------------------------------------------------------------------------Constructor
 /*METHOD clCostData */ /* Builds a data from a real number. */
 inline clCostData::clCostData(tyReal agCost) : atCost(agCost) {}
 //--------------------------------------------------------------------------------------Constructor
 /*METHOD clCostData */ /* Builds and copies a data. */
 inline clCostData::clCostData(ctCostData & agData) : atCost(agData.atCost) {}
 //--------------------------------------------------------------------------------------Constructor
 /*METHOD clCostData */ /* Builds a data from a stream. */
 inline clCostData::clCostData(clInStream & agStream,tyBoolean) : atCost() {
  agStream >> atCost;
  if (agStream.fail()) send_inline_error(erStreamReading,"costData::constructor");
 }
 //---------------------------------------------------------------------------------------Destructor
 /*METHOD clCostData */ /* Destructs the data. */
 inline clCostData::~clCostData(void) {}
 //---------------------------------------------------------------------------------------Operator =
 /*METHOD clCostData */ /* Copies a data. */
 inline clCostData & clCostData::operator = (ctCostData & agData) {
  atCost=agData.atCost;
  return (*this);
 }
 //----------------------------------------------------------------------------------------------Out
 /*METHOD clCostData */ /* Writes the data into a stream. */
 inline void clCostData::out(clOutStream & agStream,tyBoolean) const {
  agStream << atCost;
  if (agStream.fail()) send_inline_error(erStreamWriting,"costData::out");
 }
}

// F l o w D a t a  Inline //-----------------------------------------------------------------------
namespace public_area {
 //---------------------------------------------------------------------------------PositiveInfinity
 /*METHOD clFlowData */
 /* Returns the value that represents the positive infinity for the flow. Static method. */
 inline tyReal clFlowData::positiveInfinity(void) { return (atPositiveInfinity); }
 //--------------------------------------------------------------------------------------Constructor
 /*METHOD clFlowData */ /* Builds a null flow. */
 inline clFlowData::clFlowData(void) : atMaximum(positiveInfinity()),atFlow(0.0) {}
 //--------------------------------------------------------------------------------------Constructor
 /*METHOD clFlowData */ /* Builds a data from another one. */
 inline clFlowData::clFlowData(ctFlowData & agData)
 : atMaximum(agData.atMaximum),atFlow(agData.atFlow) {}
 //--------------------------------------------------------------------------------------Constructor
 /*METHOD clFlowData */ /* Builds a data from separated data. */
 inline clFlowData::clFlowData(tyReal agMaximum,tyReal agFlow)
 : atMaximum(agMaximum),atFlow(agFlow) {}
 //---------------------------------------------------------------------------------------Destructor
 /*METHOD clFlowData */ /* Destructs the data. */
 inline clFlowData::~clFlowData(void) {}
 //---------------------------------------------------------------------------------------Operator =
 /*METHOD clFlowData */ /* Copies a data. */
 inline clFlowData & clFlowData::operator = (ctFlowData & agData) {
  atMaximum=agData.atMaximum;
  atFlow=agData.atFlow;
  return (*this);
 }
}

// G e n e r i c D a t a  Inline //-----------------------------------------------------------------
namespace public_area {
 //--------------------------------------------------------------------------------------Constructor
 /*METHOD clGenericData */ /* Builds an empty data. */
 inline clGenericData::clGenericData(void) : atString(private_area::goNoDataFlag) {}
 //--------------------------------------------------------------------------------------Constructor
 /*METHOD clGenericData */ /* Builds a data from a string. */
 inline clGenericData::clGenericData(ctString & agString) : atString(agString) {}
 //--------------------------------------------------------------------------------------Constructor
 /*METHOD clGenericData */ /* Builds and copies a data. */
 inline clGenericData::clGenericData(ctGenericData & agData)
 : atString(agData.atString) {}
 //---------------------------------------------------------------------------------------Destructor
 /*METHOD clGenericData */ /* Destructs the data. */
 inline clGenericData::~clGenericData(void) {}
 //---------------------------------------------------------------------------------------Operator =
 /*METHOD clGenericData */ /* Copies a data. */
 inline clGenericData & clGenericData::operator = (ctGenericData & agData) {
  atString=agData.atString;
  return (*this);
 }
 //----------------------------------------------------------------------------------------------Out
 /*METHOD clGenericData */ /* Writes the data into a stream. */
 inline void clGenericData::out(clOutStream & agStream,tyBoolean) const {
  agStream << atString;
  if (agStream.fail()) send_inline_error(erStreamWriting,"genericData::out");
 }
}

// L e n g t h D a t a  Inline //-------------------------------------------------------------------
namespace public_area {
 //---------------------------------------------------------------------------------NegativeInfinity
 /*METHOD clLengthData */
 /* Returns the value that represents the negative infinity. Static method. */
 inline tyReal clLengthData::negativeInfinity(void) { return (atNegativeInfinity); }
 //---------------------------------------------------------------------------------PositiveInfinity
 /*METHOD clLengthData */
 /* Returns the value that represents the positive infinity. Static method. */
 inline tyReal clLengthData::positiveInfinity(void) { return (atPositiveInfinity); }
 //--------------------------------------------------------------------------------------Constructor
 /*METHOD clLengthData */ /* Builds a null value. */
 inline clLengthData::clLengthData(void) : atLength(0.0) {}
 //--------------------------------------------------------------------------------------Constructor
 /*METHOD clLengthData */ /* Builds a data from a real number. */
 inline clLengthData::clLengthData(tyReal agLength) : atLength(agLength) {}
 //--------------------------------------------------------------------------------------Constructor
 /*METHOD clLengthData */ /* Builds and copies a data. */
 inline clLengthData::clLengthData(ctLengthData & agData) : atLength(agData.atLength) {}
 //--------------------------------------------------------------------------------------Constructor
 /*METHOD clLengthData */ /* Builds a data from a stream. */
 inline clLengthData::clLengthData(clInStream & agStream,tyBoolean) : atLength() {
  agStream >> atLength;
  if (agStream.fail()) send_inline_error(erStreamReading,"lengthData::constructor");
 }
 //---------------------------------------------------------------------------------------Destructor
 /*METHOD clLengthData */ /* Destructs the data. */
 inline clLengthData::~clLengthData(void) {}
 //---------------------------------------------------------------------------------------Operator =
 /*METHOD clLengthData */ /* Copies a data. */
 inline clLengthData & clLengthData::operator = (ctLengthData & agData) {
  atLength=agData.atLength;
  return (*this);
 }
 //----------------------------------------------------------------------------------------------Out
 /*METHOD clLengthData */ /* Writes the data into a stream. */
 inline void clLengthData::out(clOutStream & agStream,tyBoolean) const {
  agStream << atLength;
  if (agStream.fail()) send_inline_error(erStreamWriting,"lengthData::out");
 }
}

// L o c a t i o n D a t a  Inline //---------------------------------------------------------------
namespace public_area {
 //--------------------------------------------------------------------------------------Constructor
 /*METHOD clLocationData */ /* Builds a null value. */
 inline clLocationData::clLocationData(void) : atX(0.0),atY(0.0),atZ(0.0) {}
 //--------------------------------------------------------------------------------------Constructor
 /*METHOD clLocationData */ /* Builds a data from a coordinate. */
 inline clLocationData::clLocationData(tyReal agX,tyReal agY,tyReal agZ)
 : atX(agX),atY(agY),atZ(agZ) {}
 //--------------------------------------------------------------------------------------Constructor
 /*METHOD clLocationData */ /* Builds and copies a data. */
 inline clLocationData::clLocationData(ctLocationData & agData)
 : atX(agData.atX),atY(agData.atY),atZ(agData.atZ) {}
 //--------------------------------------------------------------------------------------Constructor
 /*METHOD clLocationData */ /* Builds a data from a stream. */
 inline clLocationData::clLocationData(clInStream & agStream,tyBoolean) : atX(),atY(),atZ() {
  clString lcString;

  agStream >> atX >> lcString >> atY >> lcString >> atZ;
  if (agStream.fail()) send_inline_error(erStreamReading,"locationData::constructor");
 }
 //---------------------------------------------------------------------------------------Destructor
 /*METHOD clLocationData */ /* Destructs the data. */
 inline clLocationData::~clLocationData(void) {}
 //---------------------------------------------------------------------------------------Operator =
 /*METHOD clLocationData */ /* Copies a data. */
 inline clLocationData & clLocationData::operator = (ctLocationData & agData) {
  atX=agData.atX;
  atY=agData.atY;
  atZ=agData.atZ;
  return (*this);
 }
 //----------------------------------------------------------------------------------------------Out
 /*METHOD clLocationData */ /* Writes the data into a stream. */
 inline void clLocationData::out(clOutStream & agStream,tyBoolean) const {
  agStream << atX << " , " << atY << " , " << atZ;
  if (agStream.fail()) send_inline_error(erStreamWriting,"locationData::out");
 }
}

// N o D a t a  Inline //---------------------------------------------------------------------------
namespace public_area {
 //--------------------------------------------------------------------------------------Constructor
 /*METHOD clNoData */ /* Builds an object. */
 inline clNoData::clNoData(void) {}
 //--------------------------------------------------------------------------------------Constructor
 /*METHOD clNoData */ /* Builds and copies an object. */
 inline clNoData::clNoData(ctNoData &) {}
 //--------------------------------------------------------------------------------------Constructor
 /*METHOD clNoData */ /* Builds an object from a stream. */
 inline clNoData::clNoData(clInStream & agStream,tyBoolean) {
  clString lcString;
  agStream >> lcString;
  if (agStream.fail()) send_inline_error(erStreamReading,"noData::constructor");
 }
 //---------------------------------------------------------------------------------------Destructor
 /*METHOD clNoData */ /* Destructs the object. */
 inline clNoData::~clNoData(void) {}
 //---------------------------------------------------------------------------------------Operator =
 /*METHOD clNoData */ /* Copies an object. */
 inline clNoData & clNoData::operator = (ctNoData &) { return (*this); }
 //----------------------------------------------------------------------------------------------Out
 /*METHOD clNoData */ /* Writes the object into a stream. */
 inline void clNoData::out(clOutStream & agStream,tyBoolean) const {
  agStream << private_area::goNoDataFlag;
  if (agStream.fail()) send_inline_error(erStreamWriting,"noData::out");
 }
}

// R e a l D a t a  Inline //-----------------------------------------------------------------------
namespace public_area {
 //---------------------------------------------------------------------------------NegativeInfinity
 /*METHOD clRealData */
 /* Returns the value that represents the negative infinity. Static method. */
 inline tyReal clRealData::negativeInfinity(void) { return (atNegativeInfinity); }
 //---------------------------------------------------------------------------------PositiveInfinity
 /*METHOD clRealData */
 /* Returns the value that represents the positive infinity. Static method. */
 inline tyReal clRealData::positiveInfinity(void) { return (atPositiveInfinity); }
 //--------------------------------------------------------------------------------------Constructor
 /*METHOD clRealData */ /* Builds a null value. */
 inline clRealData::clRealData(void) : atValue(0.0) {}
 //--------------------------------------------------------------------------------------Constructor
 /*METHOD clRealData */ /* Builds a data from a real number. */
 inline clRealData::clRealData(tyReal agReal) : atValue(agReal) {}
 //--------------------------------------------------------------------------------------Constructor
 /*METHOD clRealData */ /* Builds and copies a data. */
 inline clRealData::clRealData(const clRealData & agData) : atValue(agData.atValue) {}
 //--------------------------------------------------------------------------------------Constructor
 /*METHOD clRealData */ /* Builds a data from a stream. */
 inline clRealData::clRealData(clInStream & agStream,tyBoolean) : atValue() {
  agStream >> atValue;
  if (agStream.fail()) send_inline_error(erStreamReading,"realData::constructor");
 }
 //---------------------------------------------------------------------------------------Destructor
 /*METHOD clRealData */ /* Destructs the data. */
 inline clRealData::~clRealData(void) {}
 //---------------------------------------------------------------------------------------Operator =
 /*METHOD clRealData */ /* Copies a data. */
 inline clRealData & clRealData::operator = (ctRealData & agData) {
  atValue=agData.atValue;
  return (*this);
 }
 //----------------------------------------------------------------------------------------------Out
 /*METHOD clRealData */ /* Writes the data into a stream. */
 inline void clRealData::out(clOutStream & agStream,tyBoolean) const {
  agStream << atValue;
  if (agStream.fail()) send_inline_error(erStreamWriting,"realData::out");
 }
}

// R e a l I n t e r v a l D a t a  Inline //-------------------------------------------------------
namespace public_area {
 //---------------------------------------------------------------------------------NegativeInfinity
 /*METHOD clRealIntervalData */
 /* Returns the value that represents the negative infinity. Static method. */
 inline tyReal clRealIntervalData::negativeInfinity(void) { return (atNegativeInfinity); }
 //---------------------------------------------------------------------------------PositiveInfinity
 /*METHOD clRealIntervalData */
 /* Returns the value that represents the positive infinity. Static method. */
 inline tyReal clRealIntervalData::positiveInfinity(void) { return (atPositiveInfinity); }
 //--------------------------------------------------------------------------------------Constructor
 /*METHOD clRealIntervalData */ /* Builds a [-oo;+oo] interval. */
 inline clRealIntervalData::clRealIntervalData(void)
 : atMinimum(negativeInfinity()),atMaximum(positiveInfinity()),atValue(0.0) {}
 //--------------------------------------------------------------------------------------Constructor
 /*METHOD clRealIntervalData */ /* Builds a data from an upper bound and a lower bound. */
 inline clRealIntervalData::clRealIntervalData(tyReal agMinimum,tyReal agMaximum,tyReal agValue)
 : atMinimum(agMinimum),atMaximum(agMaximum),atValue(agValue) {}
 //--------------------------------------------------------------------------------------Constructor
 /*METHOD clRealIntervalData */ /* Builds and copies a data. */
 inline clRealIntervalData::clRealIntervalData(const clRealIntervalData & agData)
 : atMinimum(agData.atMinimum),atMaximum(agData.atMaximum),atValue(agData.atValue) {}
 //--------------------------------------------------------------------------------------Constructor
 /*METHOD clRealIntervalData */ /* Destructs the data. */
 inline clRealIntervalData::~clRealIntervalData(void) {}
}

// S t a n d a r d D a t a  Inline //---------------------------------------------------------------
namespace public_area {
 //--------------------------------------------------------------------------------------Constructor
 /*METHOD clStandardData */ /* Builds a data with the default value. */
 template <class prData> inline clStandardData<prData>::clStandardData(void) : atValue() {}
 //--------------------------------------------------------------------------------------Constructor
 /*METHOD clStandardData */ /* Builds a data from a value. */
 template <class prData>
 inline clStandardData<prData>::clStandardData(const prData & agValue) : atValue(agValue) {}
 //--------------------------------------------------------------------------------------Constructor
 /*METHOD clStandardData */ /* Builds and copies a data. */
 template <class prData>
 inline clStandardData<prData>::clStandardData(const clStandardData<prData> & agData)
 : atValue(agData.atValue) {}
 //--------------------------------------------------------------------------------------Constructor
 /*METHOD clStandardData */ /* Builds a data from a stream. */
 template <class prData>
 inline clStandardData<prData>::clStandardData(clInStream & agStream,tyBoolean) : atValue() {
  agStream >> atValue;
  if (agStream.fail()) send_inline_error(erStreamReading,"standardData::constructor");
 }
 //---------------------------------------------------------------------------------------Destructor
 /*METHOD clStandardData */ /* Destructs the data. */
 template <class prData> inline clStandardData<prData>::~clStandardData(void) {}
 //---------------------------------------------------------------------------------------Operator =
 /*METHOD clStandardData */ /* Copies a data. */
 template <class prData> inline clStandardData<prData> &
 clStandardData<prData>::operator = (const clStandardData<prData> & agData) {
  atValue=agData.atValue;
  return (*this);
 }
 //----------------------------------------------------------------------------------------------Out
 /*METHOD clStandardData */ /* Writes the data into a stream. */
 template <class prData>
 inline void clStandardData<prData>::out(clOutStream & agStream,tyBoolean) const {
  agStream << atValue;
  if (agStream.fail()) send_inline_error(erStreamWriting,"standardData::out");
 }
}

// End //-------------------------------------------------------------------------------------------
}
#undef dll_export
#undef public_area
#undef private_area
#endif
 
//==================================================================================================
// D a t a _ s t r u c t u r e                                                       Implementation
// D a t a _ t e m p l a t e
//                                                                                By Bruno Bachelet
//==================================================================================================
// Copyright (c) 1999-2016
// Bruno Bachelet - bruno@nawouak.net - http://www.nawouak.net
//
// This file is part of the B++ Library. This library is free software; you can redistribute it
// and/or modify it under the terms of the GNU Library General Public License as published by the
// Free Software Foundation; either version 2 of the License, or (at your option) any later
// version.
//
// This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
// without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
// the GNU Library General Public License for more details (http://www.gnu.org).

// File Name //-------------------------------------------------------------------------------------
#line __LINE__ "data_structure/data_template.cpp"

// DLL Belonging //---------------------------------------------------------------------------------
#define DATA_STRUCTURE_DLL

// Headers //---------------------------------------------------------------------------------------
#include <bpp/data_structure/data_template.hpp> /*INTERFACE*/

namespace bpp {

// Namespaces //------------------------------------------------------------------------------------
#define public_area  dataStructureDataTemplate
#define private_area dataStructureDataTemplate_private
#define dll_export   DLL_EXPORT

namespace public_area  {}
namespace private_area {}

static_module_name("Data_structure/Data_template");

// Initialization //--------------------------------------------------------------------------------
#undef iniDataStructureDataTemplate
static_constant(private_area::clInitializer,goInitializer);

// Errors //----------------------------------------------------------------------------------------
namespace public_area { static_error erNegativeFlowCapacity; }

// Constants & Variables //-------------------------------------------------------------------------
static_constant(tcString,goNegativeInfinityFlag);
static_constant(tcString,goNoDataFlag);
static_constant(tcString,goPositiveInfinityFlag);
static_constant(tcString,goUnsolvedValueFlag);

// Static Members //--------------------------------------------------------------------------------
namespace public_area {
 property tyReal clCommodityData::atPositiveInfinity;

 property tyReal clCostData::atNegativeInfinity;
 property tyReal clCostData::atPositiveInfinity;

 property tyReal clFlowData::atPositiveInfinity;

 property tyReal clLengthData::atNegativeInfinity;
 property tyReal clLengthData::atPositiveInfinity;

 property tyReal clRealData::atNegativeInfinity;
 property tyReal clRealData::atPositiveInfinity;

 property tyReal clRealIntervalData::atNegativeInfinity;
 property tyReal clRealIntervalData::atPositiveInfinity;
}

namespace private_area {}

// Functions Implementation //----------------------------------------------------------------------
namespace public_area  {}
namespace private_area {}

// F l o w D a t a  Implementation //---------------------------------------------------------------
namespace public_area {
 //--------------------------------------------------------------------------------------Constructor
 /*METHOD clFlowData */
 /* Builds a data from a stream. The flow value is not read from the stream if the second argument
    is set to <CODE>false</CODE>. */
 property clFlowData::clFlowData(clInStream & agStream,tyBoolean agSolved) {
  method_name("flowData::constructor");

  clString lcString;

  agStream >> lcString;

  if (lcString==private_area::goPositiveInfinityFlag)
   atMaximum=atPositiveInfinity;
  else atMaximum=standardMaths::real(lcString.data());

  if (atMaximum<0.0) send_error(erNegativeFlowCapacity);

  if (agSolved) agStream >> lcString >> atFlow;
  else {
   agStream >> lcString >> lcString;
   atFlow=0.0;
  }

  if (agStream.fail()) send_error(erStreamReading);
 }
 //----------------------------------------------------------------------------------------------Out
 /*METHOD clFlowData */
 /* Writes the data into a stream. The flow value is not stored into the stream if the second
    argument is set to <CODE>false</CODE>. */
 property void clFlowData::out(clOutStream & agStream,tyBoolean agSolved) const {
  method_name("flowData::out");

  if (atMaximum==positiveInfinity()) agStream << private_area::goPositiveInfinityFlag;
  else agStream << atMaximum;

  if (agSolved) agStream << " ; " << atFlow;
  else agStream << " ; " << private_area::goUnsolvedValueFlag;

  if (agStream.fail()) send_error(erStreamWriting);
 }
}

// G e n e r i c D a t a  Implementation //---------------------------------------------------------
namespace public_area {
 //--------------------------------------------------------------------------------------Constructor
 /*METHOD clGenericData */ /* Builds a data from a stream. */
 property clGenericData::clGenericData(clInStream & agStream,tyBoolean) : atString("") {
  method_name("genericData::constructor");

  tyBoolean lcFirst = true;

  clString lcString;

  while (not getString(agStream,lcString)) {
   if (lcFirst) {
    atString=lcString;
    lcFirst=false;
   }
   else atString=atString+" "+lcString;
  }

  if (lcString!="") {
   if (lcFirst) atString=lcString;
   else atString=atString+" "+lcString;
  }

  if (agStream.fail()) send_error(erStreamReading);
 }
}

// R e a l I n t e r v a l D a t a  Implementation //-----------------------------------------------
namespace public_area {
 //--------------------------------------------------------------------------------------Constructor
 /*METHOD clRealIntervalData */
 /* Builds a data from a stream. The real value is not read from the stream if the second
    argument is set to <CODE>false</CODE>. */
 property clRealIntervalData::clRealIntervalData(clInStream & agStream,tyBoolean agSolved)
 : atMinimum(),atMaximum(),atValue() {
  method_name("realIntervalData::constructor");

  clString lcString;

  agStream >> lcString;

  if (lcString==private_area::goNegativeInfinityFlag) atMinimum=negativeInfinity();
  else atMinimum=standardMaths::real(lcString.data());

  agStream >> lcString >> lcString;

  if (lcString==private_area::goPositiveInfinityFlag) atMaximum=positiveInfinity();
  else atMaximum=standardMaths::real(lcString.data());

  if (agSolved) agStream >> lcString >> atValue;
  else agStream >> lcString >> lcString;

  if (agStream.fail()) send_error(erStreamReading);
 }
 //---------------------------------------------------------------------------------------Operator =
 /*METHOD clRealIntervalData */ /* Copies a data. */
 property clRealIntervalData & clRealIntervalData::operator = (ctRealIntervalData & agInterval) {
  atMinimum=agInterval.atMinimum;
  atMaximum=agInterval.atMaximum;
  atValue=agInterval.atValue;
  return (*this);
 }
 //----------------------------------------------------------------------------------------------out
 /*METHOD clRealIntervalData */
 /* Writes the data into a stream. The real value is not stored into the stream if the second
    argument is set to <CODE>false</CODE>. */
 property void clRealIntervalData::out(clOutStream & agStream,tyBoolean agSolved) const {
  method_name("realIntervalData::out");

  if (atMinimum==atNegativeInfinity) agStream << private_area::goNegativeInfinityFlag;
  else agStream << atMinimum;

  agStream << " , ";

  if (atMaximum==atPositiveInfinity) agStream << private_area::goPositiveInfinityFlag;
  else agStream << atMaximum;

  if (agSolved) agStream << " ; " << atValue;
  else agStream << " ; " << private_area::goUnsolvedValueFlag;

  if (agStream.fail()) send_error(erStreamWriting);
 }
}

// I n i t i a l i z e r  Implementation //---------------------------------------------------------
namespace private_area {
 //--------------------------------------------------------------------------------------------Start
 property void clInitializer::start(void) {
  if (atCounter++ == 0) {
   try {
    #include <bpp/modules.hpp> /*NEED*/
    registerStop(this);
    environment::informInitialization(goModuleName);

    erNegativeFlowCapacity.create("Data Structure - A flow capacity is negative.");

    goNegativeInfinityFlag = "-oo";
    goNoDataFlag           = "X";
    goPositiveInfinityFlag = "+oo";
    goUnsolvedValueFlag    = "?";

    clCommodityData::atPositiveInfinity    = realMax();
    clCostData::atPositiveInfinity         = realMax();
    clCostData::atNegativeInfinity         = realMin();
    clFlowData::atPositiveInfinity         = realMax();
    clLengthData::atPositiveInfinity       = realMax();
    clLengthData::atNegativeInfinity       = realMin();
    clRealIntervalData::atNegativeInfinity = realMin();
    clRealIntervalData::atPositiveInfinity = realMax();
    clRealData::atNegativeInfinity         = realMin();
    clRealData::atPositiveInfinity         = realMax();
   }

   initializer_catch;
  }
 }
 //---------------------------------------------------------------------------------------------Stop
 property void clInitializer::stop(void) { environment::informTermination(goModuleName); }
}

// End //-------------------------------------------------------------------------------------------
}