//
// Created by Kyle Cook on 6/24/17.
//

#ifndef AG_GEN_EDGE_H
#define AG_GEN_EDGE_H

#include "assetgroup.h"
#include "exploit.h"

#include <boost/archive/tmpdir.hpp>
#include <boost/archive/text_iarchive.hpp>
#include <boost/archive/text_oarchive.hpp>

#include <boost/serialization/base_object.hpp>
#include <boost/serialization/utility.hpp>
#include <boost/serialization/list.hpp>
#include <boost/serialization/assume_abstract.hpp>
#include <boost/serialization/string.hpp>
#include <boost/serialization/vector.hpp>


/** Edge class
 * @brief Edge of the graph based on integer id.
 */
class Edge {
    static int edge_current_id;
    int id;
    //int from_node;
    //int to_node;
    unsigned long from_node;
    unsigned long to_node;
    Exploit exploit;
    AssetGroup assetGroup;
    bool deleted;

    friend std::ostream & operator << (std::ostream &os, const Edge &ed);
    friend class boost::serialization::access;

    template<class Archive>
    void serialize(Archive &ar, const unsigned int version){
        ar & edge_current_id & id & from_node & to_node & exploit & assetGroup & deleted;
    }

  public:
    Edge(int, int, Exploit &, AssetGroup &);
    Edge(unsigned long, unsigned long, Exploit &, AssetGroup &);
    Edge();

    std::string get_query();
    std::string get_asset_query();

    int get_id() const;
    int set_id();
    //int get_from_id();
    //int get_to_id();
    unsigned long get_from_id() const;
    unsigned long get_to_id() const; 
    void force_from_id(unsigned long i);
    void force_to_id(unsigned long i);
    int get_exploit_id() const;
    void set_deleted();
    bool is_deleted();
    bool comparator(Edge& ed2);
    bool operator==(const Edge& ed2);
	void force_set_id(int i);
    size_t hash();
};

#endif // AG_GEN_EDGE_H
