OpenShot Library | libopenshot  0.1.1
ZmqLogger.h
Go to the documentation of this file.
1 /**
2  * @file
3  * @brief Header file for ZeroMQ-based Logger class
4  * @author Jonathan Thomas <jonathan@openshot.org>
5  *
6  * @section LICENSE
7  *
8  * Copyright (c) 2008-2014 OpenShot Studios, LLC
9  * <http://www.openshotstudios.com/>. This file is part of
10  * OpenShot Library (libopenshot), an open-source project dedicated to
11  * delivering high quality video editing and animation solutions to the
12  * world. For more information visit <http://www.openshot.org/>.
13  *
14  * OpenShot Library (libopenshot) is free software: you can redistribute it
15  * and/or modify it under the terms of the GNU Lesser General Public License
16  * as published by the Free Software Foundation, either version 3 of the
17  * License, or (at your option) any later version.
18  *
19  * OpenShot Library (libopenshot) is distributed in the hope that it will be
20  * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
21  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22  * GNU Lesser General Public License for more details.
23  *
24  * You should have received a copy of the GNU Lesser General Public License
25  * along with OpenShot Library. If not, see <http://www.gnu.org/licenses/>.
26  */
27 
28 #ifndef OPENSHOT_LOGGER_H
29 #define OPENSHOT_LOGGER_H
30 
31 
32 #include "JuceLibraryCode/JuceHeader.h"
33 #include <iostream>
34 #include <stdlib.h>
35 #include <string>
36 #include <sstream>
37 #include <zmq.hpp>
38 #include <unistd.h>
39 
40 
41 using namespace std;
42 
43 namespace openshot {
44 
45  /**
46  * @brief This abstract class is the base class, used by all readers in libopenshot.
47  *
48  * Readers are types of classes that read video, audio, and image files, and
49  * return openshot::Frame objects. The only requirements for a 'reader', are to
50  * derive from this base class, implement the GetFrame method, and call the InitFileInfo() method.
51  */
52  class ZmqLogger {
53  private:
54  CriticalSection loggerCriticalSection;
55  string connection;
56 
57  /// ZMQ Context
58  zmq::context_t *context;
59 
60  /// ZMQ Socket
61  zmq::socket_t *publisher;
62 
63  /// Default constructor
64  ZmqLogger(){}; // Don't allow user to create an instance of this singleton
65 
66  /// Default copy method
67  ZmqLogger(ZmqLogger const&){}; // Don't allow the user to copy this instance
68 
69  /// Default assignment operator
70  ZmqLogger & operator=(ZmqLogger const&){}; // Don't allow the user to assign this instance
71 
72  /// Private variable to keep track of singleton instance
73  static ZmqLogger * m_pInstance;
74 
75  public:
76  /// Create or get an instance of this logger singleton (invoke the class with this method)
77  static ZmqLogger * Instance();
78 
79  /// Set or change connection info for logger (i.e. tcp://*:5556)
80  void Connection(string new_connection);
81 
82  /// Log message to all subscribers of this logger (if any)
83  void Log(string message);
84  };
85 
86 }
87 
88 #endif
This abstract class is the base class, used by all readers in libopenshot.
Definition: ZmqLogger.h:52