1 /* 2 * CInstance.hh 3 * 4 * Copyright 2014-2018 D. Mitch Bailey cvc at shuharisystem dot com 5 * 6 * This file is part of cvc. 7 * 8 * cvc is free software: you can redistribute it and/or modify 9 * it under the terms of the GNU General Public License as published by 10 * the Free Software Foundation, either version 3 of the License, or 11 * (at your option) any later version. 12 * 13 * cvc is distributed in the hope that it will be useful, 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 * GNU General Public License for more details. 17 * 18 * You should have received a copy of the GNU General Public License 19 * along with cvc. If not, see <http://www.gnu.org/licenses/>. 20 * 21 * You can download cvc from https://github.com/d-m-bailey/cvc.git 22 */ 23 24 #ifndef CINSTANCE_HH_ 25 #define CINSTANCE_HH_ 26 27 #include "Cvc.hh" 28 29 #include <unordered_map> 30 #include "CCircuit.hh" 31 32 class CCvcDb; 33 34 class CInstance { 35 public: 36 deviceId_t firstDeviceId = 0; 37 instanceId_t firstSubcircuitId = 0; 38 netId_t firstNetId = 0; 39 union { 40 instanceId_t parallelInstanceCount = 0; // parallel (maybe) instances kept 41 instanceId_t parallelInstanceId; // for parallel instances deleted 42 }; 43 44 CNetIdVector localToGlobalNetId_v; 45 46 /* The CInstance structure also doubles as a hash. 47 Each master has a vector of instances. 48 */ 49 instanceId_t nextHashedInstanceId = UNKNOWN_DEVICE; 50 51 instanceId_t parentId = 0; 52 CCircuit * master_p = NULL; 53 bool isMasked = false; 54 55 void AssignTopGlobalIDs(CCvcDb * theCvcDb_p, CCircuit * theMaster_p); 56 void AssignGlobalIDs(CCvcDb * theCvcDb_p, const instanceId_t theInstanceId, CDevice * theSubcircuit_p, const instanceId_t theParentId, 57 CInstance * theParent_p, bool isParallel); IsParallelInstance()58 bool IsParallelInstance() { return (localToGlobalNetId_v.size() == 0); }; 59 60 void Print(const instanceId_t theInstanceId, const string theIndentation = ""); 61 }; 62 63 class CInstancePtrVector : public vector<CInstance *> { 64 public: 65 ~CInstancePtrVector(); 66 void Clear(); 67 }; 68 69 #endif /* CINSTANCE_HH_ */ 70