Fire Core  8.0.0.alpha
GIS framework per tutti gli usi
 Tutto Classi Namespace Funzioni Variabili Ridefinizioni di tipo (typedef) Tipi enumerati (enum) Valori del tipo enumerato Friend
Object.hpp
1 // Copyright 2015 GEOSYSTEMS SRL
2 // All Rights Reserved.
3 
4 #ifndef FIRE_OBJECT_HPP_INCLUDED
5 #define FIRE_OBJECT_HPP_INCLUDED
6 
7 #include <boost/property_tree/ptree.hpp>
8 #include <boost/property_tree/json_parser.hpp>
9 #include <boost/thread.hpp>
10 
11 #include <exception>
12 #include <string>
13 #include <cstddef>
14 
15 #include "fire/export.hpp"
16 
17 #include "fire/Groupable.hpp"
18 #include "fire/Class.hpp"
19 
24 namespace fire {
29 class FIRE_ENGINE_DLL Object : public fire::Groupable< Object > {
30  public:
35  typedef boost::unique_lock< boost::mutex > LockGuard;
36 
37  private:
42  mutable boost::condition_variable conditionVariable;
43 
44  protected:
49  mutable boost::mutex mutex;
57  Object* clone() const;
62  void finalize();
63 
64  public:
69  Object();
77  Object(const Object& object);
88  fire::Object& operator=(const fire::Object& object);
93  virtual ~Object();
101  virtual fire::Class< fire::Object >* getClass() const;
112  virtual bool equals(const Object& object) const;
123  virtual bool operator==(const Object& object) const;
131  std::size_t hashCode() const;
136  void notify() const;
141  void notifyAll() const;
149  virtual std::string toString() const;
154  void wait() const;
162  void waitFor(std::size_t timeout) const;
173  void waitFor(std::size_t timeout, int nanos) const;
184  virtual bool operator<(const Object& object) const;
198  friend std::ostream& operator<<(std::ostream& outputStream, const Object& object) {
199  try {
200  boost::property_tree::ptree tree;
201  fire::Class< fire::Object >* clazz = object.getClass();
202  tree.put< std::string >("class", clazz->getName());
203  delete clazz;
204  std::stringstream stringStream;
205  boost::property_tree::write_json(stringStream, tree);
206  outputStream << stringStream.str();
207  } catch (const std::exception& exception) {
208  throw;
209  }
210  return outputStream;
211  }
225  friend std::istream& operator>>(std::istream& inputStream, Object&) {
226  try {
227  std::string string;
228  inputStream >> string;
229  boost::property_tree::ptree tree;
230  std::stringstream stringStream;
231  stringStream.str(string);
232  boost::property_tree::read_json(stringStream, tree);
233  } catch (const std::exception& exception) {
234  throw;
235  }
236  return inputStream;
237  }
238 };
239 
240 } // namespace fire
241 
242 #endif
friend std::ostream & operator<<(std::ostream &outputStream, const Object &object)
Operatore di uscita.
Definition: Object.hpp:198
Classe per la gestione di un oggetto.
Definition: Object.hpp:29
boost::unique_lock< boost::mutex > LockGuard
Guardia per la sincronizzazione dell'oggetto.
Definition: Object.hpp:35
boost::mutex mutex
Variabile per la sincronizzazione dell'oggetto.
Definition: Object.hpp:49
Classe per la gestione di una classe contenente le informazioni di una classe.
Definition: Class.hpp:33
friend std::istream & operator>>(std::istream &inputStream, Object &)
Operatore di ingresso.
Definition: Object.hpp:225
std::string getName() const
Restituisce il nome della classe.
Definition: Class.hpp:99
Interfaccia per la gestione di un oggetto raggruppabile.
Definition: Groupable.hpp:20