RxDock 0.1.0
A fast, versatile, and open-source program for docking ligands to proteins and nucleic acids
Loading...
Searching...
No Matches
BaseObject.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// Base class for all workspace observers which have named parameters and
14// handle arbitrary requests (i.e. scoring functions and transforms)
15
16#ifndef _RBTBASEOBJECT_H_
17#define _RBTBASEOBJECT_H_
18
19#include "rxdock/Config.h"
20#include "rxdock/Observer.h"
21#include "rxdock/ParamHandler.h"
22#include "rxdock/RequestHandler.h"
23
24#include <nlohmann/json.hpp>
25
26using json = nlohmann::json;
27
28namespace rxdock {
29
30class WorkSpace; // forward definition
31
32class BaseObject : public ParamHandler, public Observer, public RequestHandler {
33public:
34 // Class type string
35 static const std::string _CT;
36 // Parameter names
37 static const std::string _CLASS;
38 static const std::string _NAME;
39 static const std::string _ENABLED;
40
41 friend void to_json(json &j, const BaseObject &baseObject);
42 friend void from_json(const json &j, BaseObject &baseObject);
43
45 // Constructors/destructors
46 virtual ~BaseObject();
47
49 // Public methods
51 // Class name (e.g. ConstSF)
52 std::string GetClass() const;
53 // Short name (e.g. HBOND)
54 std::string GetName() const;
55 void SetName(const std::string &);
56 // Fully qualified name (should be overridden by subclasses which can be
57 // aggregated to prefix the name with the parent's name)
58 virtual std::string GetFullName() const;
59 void Enable();
60 void Disable();
61 bool isEnabled() const;
62
63 // WorkSpace handling methods
64 // Register scoring function with a workspace
65 // Base class version just registers itself
66 virtual void Register(WorkSpace *);
67 // Unregister with a workspace
68 // Base class version just unregisters itself
69 virtual void Unregister();
70 // Get workspace pointer
71 WorkSpace *GetWorkSpace() const;
72
73 // Override Observer method
74 // Notify observer that subject is about to be deleted
75 virtual void Deleted(Subject *theDeletedSubject);
76
77 // Request Handling method
78 virtual void HandleRequest(RequestPtr spRequest);
79
80 // Virtual function for dumping parameters to an output stream
81 // Called by operator <<
82 virtual void Print(std::ostream &s) const;
83
84protected:
86 // Protected methods
88 BaseObject(const std::string &strClass, const std::string &strName);
89 BaseObject();
90
91 // DM 25 Oct 2000 - track changes to parameter values in local data members
92 // ParameterUpdated is invoked by ParamHandler::SetParameter
93 void ParameterUpdated(const std::string &strName);
94
95private:
97 // Private methods
99 BaseObject(const BaseObject &); // Copy constructor disabled by default
100 BaseObject &
101 operator=(const BaseObject &); // Copy assignment disabled by default
102
103protected:
105 // Protected data
107
108private:
110 // Private data
112 WorkSpace *m_workspace;
113 bool m_enabled;
114};
115
116void to_json(json &j, const BaseObject &baseObject);
117void from_json(const json &j, BaseObject &baseObject);
118
119// Useful typedefs
120typedef std::vector<BaseObject *> BaseObjectList; // Vector of smart pointers
121typedef BaseObjectList::iterator BaseObjectListIter;
122typedef BaseObjectList::const_iterator BaseObjectListConstIter;
123
124} // namespace rxdock
125
126#endif //_RBTBASEOBJECT_H_
Definition BaseObject.h:32
Definition Observer.h:33
Definition ParamHandler.h:30
Definition RequestHandler.h:24
Definition Subject.h:35
Definition WorkSpace.h:38