-
Notifications
You must be signed in to change notification settings - Fork 1
/
structure-db.h
43 lines (40 loc) · 1.66 KB
/
structure-db.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
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
#pragma once
#include "molecule.h"
#include <string>
#include <vector>
#include <map>
#include <ostream>
class StructureDb {
enum {STACK_SZ = 3}; // how far are we looking out
private: // structs
class AtomSignature;
class MoleculeSignature : public std::vector<AtomSignature> { // an array of AtomSignature objects
public:
bool operator<(const MoleculeSignature &other) const;
void sort();
friend std::ostream& operator<<(std::ostream &os, const MoleculeSignature &ms);
}; // MoleculeSignature
class AtomSignature {
Element elt; // atom element
std::vector<AtomSignature> neighbors;
public:
AtomSignature(Element newElt) : elt(newElt) { }
void addNeighbor(const AtomSignature &neighbor) {neighbors.push_back(neighbor);}
bool operator<(const AtomSignature &other) const;
void sort();
friend std::ostream& operator<<(std::ostream &os, const AtomSignature &as);
}; // AtomSignature
private: // data
std::map<MoleculeSignature, std::string> signatures;
public: // constr/iface
StructureDb();
void add(const Molecule *m, const std::string &id);
std::string find(const Molecule *m);
size_t size() const {return signatures.size();}
static const MoleculeSignature computeMoleculeSignature(const Molecule *m);
private: // internals
static const AtomSignature computeAtomSignature(const Atom *m);
static const AtomSignature computeAtomNeighborSignature(const Atom *m, std::array<const Atom*, STACK_SZ> &stack, unsigned depth, unsigned maxDepth);
friend std::ostream& operator<<(std::ostream &os, const MoleculeSignature &ms);
friend std::ostream& operator<<(std::ostream &os, const AtomSignature &as);
}; // StructureDb