UniSet  2.6.0
LProcessor.h
00001 /*
00002  * Copyright (c) 2015 Pavel Vainerman.
00003  *
00004  * This program is free software: you can redistribute it and/or modify
00005  * it under the terms of the GNU Lesser General Public License as
00006  * published by the Free Software Foundation, version 2.1.
00007  *
00008  * This program is distributed in the hope that it will be useful, but
00009  * WITHOUT ANY WARRANTY; without even the implied warranty of
00010  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
00011  * Lesser General Lesser Public License for more details.
00012  *
00013  * You should have received a copy of the GNU Lesser General Public License
00014  * along with this program. If not, see <http://www.gnu.org/licenses/>.
00015  */
00016 // --------------------------------------------------------------------------
00017 #ifndef LProcessor_H_
00018 #define LProcessor_H_
00019 // --------------------------------------------------------------------------
00103 // --------------------------------------------------------------------------
00104 #include <list>
00105 #include <atomic>
00106 #include "UniSetTypes.h"
00107 #include "UInterface.h"
00108 #include "Element.h"
00109 #include "Schema.h"
00110 // --------------------------------------------------------------------------
00111 namespace uniset
00112 {
00113 // --------------------------------------------------------------------------
00114 class LProcessor
00115 {
00116     public:
00117         explicit LProcessor( const std::string& name = "" );
00118         virtual ~LProcessor();
00119 
00120         void open( const std::string& lfile );
00121 
00122         inline bool isOpen() const
00123         {
00124             return !fSchema.empty();
00125         }
00126 
00127         virtual void execute( const std::string& lfile = "" );
00128 
00129         virtual void terminate()
00130         {
00131             canceled = true;
00132         }
00133 
00134         inline std::shared_ptr<SchemaXML> getSchema()
00135         {
00136             return sch;
00137         }
00138 
00139         inline int getSleepTime() const
00140         {
00141             return sleepTime;
00142         }
00143 
00144     protected:
00145 
00146         virtual void build( const string& lfile );
00147 
00148         virtual void step();
00149 
00150         virtual void getInputs();
00151         virtual void processing();
00152         virtual void setOuts();
00153 
00154         struct EXTInfo
00155         {
00156             uniset::ObjectId sid;
00157             UniversalIO::IOType iotype;
00158             bool state;
00159             std::shared_ptr<Element> el;
00160             int numInput = { -1};
00161         };
00162 
00163         struct EXTOutInfo
00164         {
00165             uniset::ObjectId sid;
00166             UniversalIO::IOType iotype;
00167             std::shared_ptr<Element> el;
00168         };
00169 
00170         typedef std::list<EXTInfo> EXTList;
00171         typedef std::list<EXTOutInfo> OUTList;
00172 
00173         EXTList extInputs;
00174         OUTList extOuts;
00175 
00176         std::shared_ptr<SchemaXML> sch;
00177 
00178         UInterface ui;
00179         timeout_t sleepTime = { 200 };
00180         timeout_t smReadyTimeout = { 30000 } ;     
00182         std::string logname = { "" };
00183 
00184         std::atomic_bool canceled = {false};
00185 
00186         std::string fSchema = {""};
00187 
00188     private:
00189 };
00190 // --------------------------------------------------------------------------
00191 } // end of namespace uniset
00192 // ---------------------------------------------------------------------------
00193 #endif