Resource_impl.h
Go to the documentation of this file.
1 /*
2  * This file is protected by Copyright. Please refer to the COPYRIGHT file
3  * distributed with this source distribution.
4  *
5  * This file is part of REDHAWK core.
6  *
7  * REDHAWK core is free software: you can redistribute it and/or modify it
8  * under the terms of the GNU Lesser General Public License as published by the
9  * Free Software Foundation, either version 3 of the License, or (at your
10  * option) any later version.
11  *
12  * REDHAWK core is distributed in the hope that it will be useful, but WITHOUT
13  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
15  * for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public License
18  * along with this program. If not, see http://www.gnu.org/licenses/.
19  */
20 
21 
22 #ifndef RESOURCE_IMPL_H
23 #define RESOURCE_IMPL_H
24 
25 #include <string>
26 #include <map>
27 #include "Logging_impl.h"
28 #include "Port_impl.h"
29 #include "LifeCycle_impl.h"
30 #include "PortSupplier_impl.h"
31 #include "PropertySet_impl.h"
32 #include "TestableObject_impl.h"
33 #include "ossie/logging/loghelpers.h"
34 #include "ossie/ossieSupport.h"
35 #include "ossie/prop_helpers.h"
36 #include "ossie/Containers.h"
37 #include "ossie/PropertyMap.h"
38 #include "ossie/Autocomplete.h"
39 
41 #ifdef BEGIN_AUTOCOMPLETE_IGNORE
42  public virtual POA_CF::Resource,
43 #endif
45 {
46  ENABLE_LOGGING
47 
48 public:
49  template<class T>
50  static void start_component(T*& component, int argc, char* argv[]) {
51  // Initialize the component pointer to quiet warnings--it's not obvious
52  // to the compiler that it eventually gets set before being read
53  component = 0;
54 
55  // Bind the constructor adapter make_component() with the template type
56  // and the component argument (explicitly by reference, so that the
57  // caller gets the updated value) and pass along to the real
58  // implementation
59  start_component(boost::bind(&Resource_impl::make_component<T>,boost::ref(component),_1,_2), argc, argv);
60  }
61 
62  virtual ~Resource_impl ();
63  Resource_impl (const char* _uuid);
64  Resource_impl (const char* _uuid, const char *label);
65 
66  /*
67  * REDHAWK constructor. All properties are initialized before this constructor is called
68  */
69  virtual void constructor ();
70 
71  void setParentId( const std::string &parentid ) { _parent_id = parentid; };
72 
73 
74  void start () throw (CF::Resource::StartError, CORBA::SystemException);
75  void stop () throw (CF::Resource::StopError, CORBA::SystemException);
76  void initialize () throw (CF::LifeCycle::InitializeError, CORBA::SystemException);
77  void releaseObject() throw (CORBA::SystemException, CF::LifeCycle::ReleaseError);
78  char* identifier () throw (CORBA::SystemException);
79  CORBA::Boolean started() throw (CORBA::SystemException);
80  char* softwareProfile () throw (CORBA::SystemException);
81 
82  virtual void run ();
83  virtual void halt ();
84 
85  virtual void setCurrentWorkingDirectory(std::string& cwd);
86  virtual std::string& getCurrentWorkingDirectory();
87 
88  virtual void setAdditionalParameters(std::string &softwareProfile, std::string &application_registrar_ior, std::string &nic);
89  /*
90  * Return a pointer to the Domain Manager that the Resource is deployed on
91  */
92  redhawk::DomainManagerContainer* getDomainManager() {
93  return this->_domMgr;
94  }
95 
96  /*
97  * Globally unique identifier for this Resource
98  */
99  std::string _identifier;
100  /*
101  * Name used to bind this Resource to the Naming Service
102  */
103  std::string naming_service_name;
104  std::string _parent_id;
105 
106 protected:
107 
108  /*
109  * Boolean describing whether or not this Resource is started
110  */
111  bool _started;
112  /*
113  * Filename for the Resource's SPD file
114  */
115  std::string _softwareProfile;
116 
118  omni_condition component_running;
119 
120 private:
121  Resource_impl(); // No default constructor
122  Resource_impl(Resource_impl&); // No copying
123 
124  // Adapter template function for component constructors. This is the only
125  // part of component creation that requires type-specific knowledge.
126  template <class T>
127  static Resource_impl* make_component(T*& component, const std::string& identifier, const std::string& name)
128  {
129  component = new T(identifier.c_str(), name.c_str());
130  return component;
131  }
132 
133  // Generic implementation of start_component, taking a function pointer to
134  // a component constructor (via make_component).
135  typedef boost::function<Resource_impl* (const std::string&, const std::string&)> ctor_type;
136  static void start_component(ctor_type ctor, int argc, char* argv[]);
137  std::string currentWorkingDirectory;
138  redhawk::DomainManagerContainer *_domMgr;
139  bool _initialized;
140 };
141 #endif
std::string _parent_id
Definition: Resource_impl.h:104
omni_condition component_running
Definition: Resource_impl.h:118
void initialize()
CORBA::Boolean started()
char * identifier()
static void start_component(T *&component, int argc, char *argv[])
Definition: Resource_impl.h:50
virtual void constructor()
virtual ~Resource_impl()
virtual void setCurrentWorkingDirectory(std::string &cwd)
std::string naming_service_name
Definition: Resource_impl.h:103
redhawk::DomainManagerContainer * getDomainManager()
Definition: Resource_impl.h:92
Definition: Logging_impl.h:31
char * softwareProfile()
Definition: TestableObject_impl.h:32
void releaseObject()
Definition: Resource_impl.h:40
void setParentId(const std::string &parentid)
Definition: Resource_impl.h:71
std::string _softwareProfile
Definition: Resource_impl.h:115
virtual std::string & getCurrentWorkingDirectory()
virtual void run()
std::string _identifier
Definition: Resource_impl.h:99
bool _started
Definition: Resource_impl.h:111
virtual void setAdditionalParameters(std::string &softwareProfile, std::string &application_registrar_ior, std::string &nic)
virtual void halt()
Definition: PropertySet_impl.h:39
Definition: PortSupplier_impl.h:37
omni_mutex component_running_mutex
Definition: Resource_impl.h:117
Definition: LifeCycle_impl.h:35