libstorage-ng
 All Classes Namespaces Functions Typedefs Enumerations Enumerator Friends Pages
Holder.h
1 /*
2  * Copyright (c) [2014-2015] Novell, Inc.
3  *
4  * All Rights Reserved.
5  *
6  * This program is free software; you can redistribute it and/or modify it
7  * under the terms of version 2 of the GNU General Public License as published
8  * by the Free Software Foundation.
9  *
10  * This program is distributed in the hope that it will be useful, but WITHOUT
11  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13  * more details.
14  *
15  * You should have received a copy of the GNU General Public License along
16  * with this program; if not, contact Novell, Inc.
17  *
18  * To contact Novell about this file by physical or electronic mail, you may
19  * find current contact information at www.novell.com.
20  */
21 
22 
23 #ifndef STORAGE_HOLDER_H
24 #define STORAGE_HOLDER_H
25 
26 
27 #include <libxml/tree.h>
28 #include <memory>
29 #include <boost/noncopyable.hpp>
30 
31 #include "storage/Devices/Device.h"
32 
33 
34 namespace storage
35 {
36  class Devicegraph;
37  class Device;
38 
39 
40  struct HolderHasWrongType : public Exception
41  {
42  HolderHasWrongType(const char* seen, const char* expected);
43  };
44 
45 
46  // abstract class
47 
48  class Holder : private boost::noncopyable
49  {
50  public:
51 
52  virtual ~Holder();
53 
54  sid_t get_source_sid() const;
55  sid_t get_target_sid() const;
56 
57  bool operator==(const Holder& rhs) const;
58  bool operator!=(const Holder& rhs) const;
59 
60  public:
61 
62  class Impl;
63 
64  Impl& get_impl() { return *impl; }
65  const Impl& get_impl() const { return *impl; }
66 
67  virtual Holder* clone() const = 0;
68 
69  void save(xmlNode* node) const;
70 
71  friend std::ostream& operator<<(std::ostream& out, const Holder& holder);
72 
73  protected:
74 
75  Holder(Impl* impl);
76 
77  void create(Devicegraph* devicegraph, const Device* source, const Device* target);
78  void load(Devicegraph* devicegraph, const xmlNode* node);
79 
80  private:
81 
82  void add_to_devicegraph(Devicegraph* devicegraph, const Device* source,
83  const Device* target);
84 
85  const std::unique_ptr<Impl> impl;
86 
87  };
88 
89 }
90 
91 #endif
The master container of the libstorage.
Definition: Devicegraph.h:133
An abstract base class of storage devices, and a vertex in the Devicegraph.
Definition: Device.h:73
Definition: Holder.h:48
Definition: Holder.h:40
Base class for storage exceptions.
Definition: Exception.h:113
The storage namespace.
Definition: Actiongraph.h:36
unsigned int sid_t
An integer storage ID.
Definition: Device.h:64