IMP logo
IMP Reference Guide  develop.d97d4ead1f,2024/11/21
The Integrative Modeling Platform
DataObject.h
Go to the documentation of this file.
1 /**
2  * \file IMP/core/DataObject.h
3  * \brief Helper class for creating an IMP object storing some data.
4  *
5  * Copyright 2007-2022 IMP Inventors. All rights reserved.
6  *
7  */
8 
9 #ifndef IMPCORE_DATA_OBJECT_H
10 #define IMPCORE_DATA_OBJECT_H
11 
12 #include <IMP/core/core_config.h>
13 #include <IMP/Object.h>
14 
15 IMPCORE_BEGIN_NAMESPACE
16 
17 //! Helper class for creating an IMP object storing some data.
18 /** This can be used to, eg, add the data to a particle as part of a cache.
19 
20  This class is C++ only.
21  */
22 template <class Data>
23 class DataObject : public IMP::Object {
24  Data data_;
25 
26  public:
27  DataObject(const Data &d, std::string name = "DataObject %1%")
28  : Object(name), data_(d) {}
29  const Data &get_data() const { return data_; }
30  Data &access_data() { return data_; }
32 };
33 
34 IMPCORE_END_NAMESPACE
35 
36 #endif /* IMPCORE_DATA_OBJECT_H */
Helper class for creating an IMP object storing some data.
Definition: DataObject.h:23
#define IMP_OBJECT_METHODS(Name)
Define the basic things needed by any Object.
Definition: object_macros.h:25
Common base class for heavy weight IMP objects.
Definition: Object.h:111
A shared base class to help in debugging and things.