source: molecuilder/src/Descriptors/AtomDescriptor_impl.hpp@ 0f55b2

Last change on this file since 0f55b2 was 78b9d9, checked in by Tillmann Crueger <crueger@…>, 15 years ago

Improved Doxygen documentation

  • Property mode set to 100644
File size: 3.9 KB
Line 
1#ifndef ATOMDESCRIPTOR_IMPL_HPP
2#define ATOMDESCRIPTOR_IMPL_HPP
3
4#include "Descriptors/AtomDescriptor.hpp"
5
6/************************ Declarations of implementation Objects ************************/
7
8/**
9 * This class implements a general Base class for AtomDescriptors using the PIMPL-Idiom
10 *
11 * The predicate for this class is empty and should be implemented by derived classes.
12 * By the predicate it is described which atoms should be picked for a given descriptor.
13 */
14
15class AtomDescriptor_impl
16{
17 friend class AtomDescriptor;
18public:
19
20 AtomDescriptor_impl();
21 virtual ~AtomDescriptor_impl();
22
23 /**
24 * Implement this abstract Method to make a concrete AtomDescriptor pick certain Atoms
25 */
26 virtual bool predicate(std::pair<atomId_t,atom*>)=0;
27
28protected:
29
30 /**
31 * This method is called when the Descriptor is used to find the first matching
32 * Atom. Walks through all Atoms and stops on the first match. Can be implemented
33 * when the searched Atom can be found in a more efficient way. Calculated
34 * Atomdescriptors will always use this method, so no improvement there.
35 */
36 virtual atom* find();
37
38 /**
39 * This method is called when the Descriptor is used to find all matching Atoms.
40 * Walks through all Atoms and tests the predicate on each one. A vector of all
41 * matching Atoms is returned.
42 */
43 virtual std::vector<atom*> findAll();
44
45 /**
46 * This method is used internally to query the Set of Atoms from the world.
47 * By using this method derived classes can also access the Internal World Datastructre.
48 * Implemented in full in the Base Descriptor Implementation, so only this one method
49 * needs to be friend with the World class.
50 */
51 World::AtomSet& getAtoms();
52};
53
54/************************** Universe and Emptyset *****************/
55
56/**
57 * A simple AtomDescriptor that will always match all Atoms present in the World.
58 */
59class AtomAllDescriptor_impl : public AtomDescriptor_impl {
60public:
61 AtomAllDescriptor_impl();
62 virtual ~AtomAllDescriptor_impl();
63
64 /**
65 * Always returns true for any Atom
66 */
67 virtual bool predicate(std::pair<atomId_t,atom*>);
68};
69
70
71/**
72 * An AtomDescriptor that never matches any Atom in the World.
73 */
74class AtomNoneDescriptor_impl : public AtomDescriptor_impl {
75public:
76 AtomNoneDescriptor_impl();
77 virtual ~AtomNoneDescriptor_impl();
78
79 /**
80 * Always returns false for any Atom
81 */
82 virtual bool predicate(std::pair<atomId_t,atom*>);
83};
84
85/************************** Operator stuff ************************/
86
87/**
88 * Intersection of two AtomDescriptors
89 */
90class AtomAndDescriptor_impl : public AtomDescriptor_impl
91{
92public:
93 AtomAndDescriptor_impl(AtomDescriptor::impl_ptr _lhs, AtomDescriptor::impl_ptr _rhs);
94 ~AtomAndDescriptor_impl();
95
96 /**
97 * This predicate uses the predicate from the first && the predicate from the
98 * second Descriptor to decide if an Atom should be selected.
99 */
100 virtual bool predicate(std::pair<atomId_t,atom*>);
101
102private:
103 AtomDescriptor::impl_ptr lhs;
104 AtomDescriptor::impl_ptr rhs;
105};
106
107/**
108 * Union of two AtomDescriptors
109 */
110class AtomOrDescriptor_impl : public AtomDescriptor_impl
111{
112public:
113 AtomOrDescriptor_impl(AtomDescriptor::impl_ptr _lhs, AtomDescriptor::impl_ptr _rhs);
114 virtual ~AtomOrDescriptor_impl();
115
116 /**
117 * This predicate uses the predicate form the first || the predicate from the
118 * second Descriptor to decide if an Atom should be selected.
119 */
120 virtual bool predicate(std::pair<atomId_t,atom*>);
121
122private:
123 AtomDescriptor::impl_ptr lhs;
124 AtomDescriptor::impl_ptr rhs;
125};
126
127/**
128 * Set Inversion of a Descriptor
129 */
130class AtomNotDescriptor_impl : public AtomDescriptor_impl
131{
132public:
133 AtomNotDescriptor_impl(AtomDescriptor::impl_ptr _arg);
134 virtual ~AtomNotDescriptor_impl();
135
136 /**
137 * Opposite of the given descriptor predicate.
138 */
139 virtual bool predicate(std::pair<atomId_t,atom*>);
140
141private:
142 AtomDescriptor::impl_ptr arg;
143};
144
145#endif //ATOMDESCRIPTOR_IMPL_HPP
Note: See TracBrowser for help on using the repository browser.