RxDock 0.1.0
A fast, versatile, and open-source program for docking ligands to proteins and nucleic acids
Loading...
Searching...
No Matches
Request.h
1/***********************************************************************
2 * The rDock program was developed from 1998 - 2006 by the software team
3 * at RiboTargets (subsequently Vernalis (R&D) Ltd).
4 * In 2006, the software was licensed to the University of York for
5 * maintenance and distribution.
6 * In 2012, Vernalis and the University of York agreed to release the
7 * program as Open Source software.
8 * This version is licensed under GNU-LGPL version 3.0 with support from
9 * the University of Barcelona.
10 * http://rdock.sourceforge.net/
11 ***********************************************************************/
12
13// Simple struct to represent a request message
14// Stores a request ID (int) and an arbitrary length list of variant params
15// Base class cannot be instantiated.
16// Derived class constructors should set the ID and the param list accordingly
17
18#ifndef _RBTREQUEST_H_
19#define _RBTREQUEST_H_
20
21#include "rxdock/Variant.h"
22
23#include <nlohmann/json.hpp>
24
25using json = nlohmann::json;
26
27namespace rxdock {
28
29typedef int RequestID;
30
31// Only check request assertions in debug build
32#ifdef _NDEBUG
33const Bool REQ_CHECK = false;
34#else
35const bool REQ_CHECK = true;
36#endif //_NDEBUG
37
38class Request {
39public:
41 // Constructors/destructors
42 virtual ~Request() {}
43
44 Request(json j) {
45 j.get_to(*this);
46 _RBTOBJECTCOUNTER_CONSTR_("Request");
47 }
48
49 friend void to_json(json &j, const Request &request) {
50 /*json variantList;
51 for (const auto &aIter : request.m_parameters) {
52 json request = *aIter;
53 variantList.push_back(request);
54 }*/
55 j = json{{"request-id", request.m_id},
56 {"variant-list", request.m_parameters}};
57 }
58
59 friend void from_json(const json &j, Request &request) {
60 j.at("request-id").get_to(request.m_id);
61 j.at("variant-list").get_to(request.m_parameters);
62 }
63
65 // Public methods
67 RequestID GetID() const { return m_id; }
68 unsigned int GetNumParameters() const { return m_parameters.size(); }
69 VariantList GetParameters() const { return m_parameters; }
70
72 // Protected methods
74 // Protected constructor to be used by derived classes to set request ID
75 Request(RequestID id) : m_id(id) {}
76 // AddParameter can be used by derived classes to add parameters to list
77 void AddParameter(const Variant &v) { m_parameters.push_back(v); }
78
79private:
81 // Private data
83 RequestID m_id;
84 VariantList m_parameters;
85};
86
87// Useful typedefs
89typedef std::vector<RequestPtr> RequestList;
90typedef RequestList::iterator RequestListIter;
91typedef RequestList::const_iterator RequestListConstIter;
92
93} // namespace rxdock
94
95#endif //_RBTREQUEST_H_
Definition Request.h:38
Definition SmartPointer.h:48
Definition Variant.h:30