// genDElement - An abstract data element library
// Copyright (C) 2013-2026 Eric Bechet, Frederic Duboeuf
//
// See the LICENSE file for license information.
// Please report all bugs and problems to <bechet@cadxfem.org> or <duboeuf@outlook.com>.
//
// Initial design: Frederic Duboeuf (rev.1501)


#ifndef _GEN_DATA_ENTITY_H_
#define _GEN_DATA_ENTITY_H_

#include "genData.h"
#include "GEntity.h"

template<class E> class DElementBase;

class DataEntity : public genData
{
public :
  GEntity* entity;

public :
  template<class E> DataEntity(const char* s, DElementBase<E>* de) : genData(s,de), entity(0) {}
  virtual ~DataEntity() {}
  virtual int getNumEntity() const {return entity->tag();}
  virtual GEntity* getEntity() const {return entity;}
  virtual void setEntity(GEntity* entity_) {entity=entity_;}
  virtual int getNumPhysicals() const {return entity->physicals.size();}
  virtual int getPhysical(int i) const {return entity->physicals[i];}
  virtual std::vector<int> getPhysicals() const {return entity->getPhysicalEntities();}
  virtual void print(std::ostream &os) const;
};

void DataEntity::print(std::ostream &os) const
{
  std::streamsize width = os.width();
  os.width(width); os <<"";
  os << "Entity : " << getNumEntity() << "\n";
  os.width(width); os <<"";
  os << "Physicals[" << getNumPhysicals() << "] :";
  for (int i=0; i<getNumPhysicals(); ++i)
  {
    os << " " << getPhysical(i);
  }
  os << "\n";
}

#endif // _GEN_DATA_ENTITY_H_