componentrange.h 2.07 KB
Newer Older
jcl's avatar
jcl committed
1
// ============================================================================
2
// Copyright Jean-Charles LAMBERT - 2008-2016
jclamber's avatar
jclamber committed
3 4 5
//           Centre de donneeS Astrophysiques de Marseille (CeSAM)           
// e-mail:   Jean-Charles.Lambert@lam.fr                                      
// address:  Aix Marseille Universite, CNRS, LAM 
jcl's avatar
jcl committed
6 7 8 9
//           Laboratoire d'Astrophysique de Marseille                          
//           Pole de l'Etoile, site de Chateau-Gombert                         
//           38, rue Frederic Joliot-Curie                                     
//           13388 Marseille cedex 13 France                                   
jclamber's avatar
jclamber committed
10
//           CNRS UMR 7326                                       
jcl's avatar
jcl committed
11 12 13 14
// ============================================================================
#ifndef UNSCOMPONENTRANGE_H
#define UNSCOMPONENTRANGE_H
/**
jclamber's avatar
jclamber committed
15
	@author Jean-Charles Lambert <jean-charles.lambert@lam.fr>
jcl's avatar
jcl committed
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57
*/
#include <vector>
#include <string>

namespace uns {

class ComponentRange;

typedef std::vector <ComponentRange> ComponentRangeVector;

class ComponentRange{
public:
    ComponentRange();
    ComponentRange(const ComponentRange&);  // copy constructor
    ~ComponentRange();

  void setData(const int _f,const  int _l, const std::string _type="");
  void setType(std::string _type) { type = _type; }
  void setPosition(const int _pos) { position = _pos;}
  static int getIndexMatchType(const ComponentRangeVector * crv, const std::string type, 
                               int & offset,bool crvuser=false);
  static void list(const ComponentRangeVector * crv);
  static int print(const ComponentRangeVector * crv, std::string select);
  static bool compareFirst(const ComponentRange &a ,const ComponentRange &b) {
    return a.first < b.first;
  };
  static bool comparePos(const ComponentRange &a ,const ComponentRange &b) {
    return a.position < b.position;
  };
  
  std::string range,   // "0:99999"
               type;    // "all", "halo", "disk", "bulge", "gas", "other"....
   int first,last,n;
   int position;
  private:
    int computeN();
    void buildRange();
};

}

#endif