1 // Copyright (c) 2020 OPEN CASCADE SAS 2 // 3 // This file is part of the examples of the Open CASCADE Technology software library. 4 // 5 // Permission is hereby granted, free of charge, to any person obtaining a copy 6 // of this software and associated documentation files (the "Software"), to deal 7 // in the Software without restriction, including without limitation the rights 8 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 // copies of the Software, and to permit persons to whom the Software is 10 // furnished to do so, subject to the following conditions: 11 // 12 // The above copyright notice and this permission notice shall be included in all 13 // copies or substantial portions of the Software. 14 // 15 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE 21 22 #ifndef BASESAMPLE_H 23 #define BASESAMPLE_H 24 25 #include <sstream> 26 27 #include <AIS_InteractiveObject.hxx> 28 #include <NCollection_Vector.hxx> 29 #include <TCollection_AsciiString.hxx> 30 31 //! Base class for specified category classes 32 class BaseSample: public Standard_Transient 33 { DEFINE_STANDARD_RTTI_INLINE(BaseSample,Standard_Transient)34 DEFINE_STANDARD_RTTI_INLINE(BaseSample, Standard_Transient) 35 public: 36 BaseSample (const TCollection_AsciiString& theSampleSourcePath, 37 const Handle(AIS_InteractiveContext)& theContext) 38 : myCodePath (theSampleSourcePath), 39 myContext (theContext) 40 { 41 // 42 } 43 44 void Clear(); 45 void AppendCube(); 46 IsProcessed()47 Standard_Boolean IsProcessed() const { return myIsProcessed; } 48 Get2dObjects()49 const NCollection_Vector<Handle(AIS_InteractiveObject)>& Get2dObjects() const { return myObject2d; } 50 Get3dObjects()51 const NCollection_Vector<Handle(AIS_InteractiveObject)>& Get3dObjects() const { return myObject3d; } 52 53 TCollection_AsciiString GetResult(); 54 GetCode()55 TCollection_AsciiString GetCode() const { return myCode; } 56 57 virtual void Process (const TCollection_AsciiString& theSampleName); 58 59 protected: 60 virtual void ExecuteSample (const TCollection_AsciiString& theSampleName) = 0; 61 62 void FindSourceCode (const TCollection_AsciiString& theSampleName); 63 void TraceError (const TCollection_AsciiString& theErrorMessage); 64 65 protected: 66 67 Standard_Boolean myIsProcessed; 68 NCollection_Vector<Handle(AIS_InteractiveObject)> myObject2d; 69 NCollection_Vector<Handle(AIS_InteractiveObject)> myObject3d; 70 71 std::ostringstream myResult; 72 TCollection_AsciiString myCode; 73 TCollection_AsciiString myCodePath; 74 Handle(AIS_InteractiveContext) myContext; 75 76 protected: 77 static const TCollection_AsciiString FILE_EXTENSION; 78 79 private: 80 Standard_Integer findEndOfPhrase (const TCollection_AsciiString& theText, 81 const TCollection_AsciiString& theRegexpTemplate); 82 Standard_Integer findClosingBracket (const TCollection_AsciiString& theText, 83 Standard_Integer theOpeningBracketIndex, 84 Standard_Character theClosingBracketSymbol); 85 }; 86 87 #endif //BASESAMPLE_H 88